/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */

plugins {
    id 'java-library'
    id 'org.apache.grails.gradle.grails-plugin'
}

group = 'org.apache.grails'

ext {
    publishArtifactId = 'grails-spring-security-rest'
    pomTitle = 'Grails Spring Security REST Plugin'
    pomDescription = 'Grails plugin to implement token-based, RESTful authentication using Spring Security'
    pomDevelopers = [
            alvarosanchez: 'Alvaro Sanchez-Mariscal',
            jameskleeh: 'James Kleeh',
            jdaugherty: 'James Daugherty'
    ]
}

dependencies {

    implementation platform("org.apache.grails:grails-bom:$grailsVersion")

    api project(':core-plugin'), {
        // api: NullAuthenticationEventPublisher, SecurityEventListener
        // impl: BeanTypeResolver, @Secured(runtime), SecurityFilterPosition, SpringSecurityUtils
    }
    api 'com.nimbusds:nimbus-jose-jwt:9.42', {
        // api: EncryptionMethod, JOSEException, JWEAlgorithm, JWSAlgorithm, JWSSigner, JWT, JWTClaimsSet
        // impl: EncryptedJWT, EncryptionMethod, JWEHeader, JWSHeader, JWTParser, MACSigner, MACVerifier, PlainJWT, RSADecrypter, RSAEncrypter, SignedJWT
    }
    api 'org.apache.grails.web:grails-web-url-mappings', {
        // api: LinkGenerator
    }
    api "org.pac4j:pac4j-core:$pac4jVersion", {
        // api: CallContext, CommonProfile, IndirectClient, UserProfile
        // impl: Credentials, RedirectionAction, WebContext
    }
    api 'org.springframework:spring-beans', {
        // api: InitializingBean
        // impl: BeanWrapperImpl
    }
    api 'org.springframework:spring-context', {
        // api: ApplicationContextAware, ApplicationEvent, ApplicationEventPublisher, ApplicationListener
    }
    api 'org.springframework:spring-web', {
        // api: GenericFilterBean
        // impl: HttpStatus, MediaType
    }
    api 'org.springframework.security:spring-security-core', {
        // api: AbstractAuthenticationToken, AccessDeniedException, Authentication, AuthenticationDetailsSource, AuthenticationEventPublisher,
        //      AuthenticationException, AuthenticationFailureHandler, AuthenticationManager, AuthenticationProvider,
        //      AuthenticationSuccessHandler, DefaultAuthenticationEventPublisher, GrantedAuthority, User, UserDetails,
        //      UserDetailsChecker, UserDetailsService, UsernameNotFoundException, UsernamePasswordAuthenticationToken
        // impl: SecurityContextHolder, SimpleGrantedAuthority
    }
    api 'org.springframework.security:spring-security-crypto', {
        // api: PasswordEncoder
        // impl: Argon2PasswordEncoder, BCryptPasswordEncoder, DelegatingPasswordEncoder, LdapShaPasswordEncoder,
        //       Md4PasswordEncoder, MessageDigestPasswordEncoder, NoOpPasswordEncoder, Pbkdf2PasswordEncoder,
        //       StandardPasswordEncoder, SCryptPasswordEncoder
    }
    api 'org.springframework.security:spring-security-web', {
        // api: AccessDeniedHandlerImpl, AuthenticationEntryPoint, RequestMatcher
        // impl: ExceptionTranslationFilter, Http403ForbiddenEntryPoint, NullRequestCache
    }

    implementation "org.apache.commons:commons-lang3", {
        // impl: RandomStringUtils
    }
    implementation 'com.google.guava:guava:33.3.1-jre', {
        // impl: CacheBuilder, LoadingCache
    }
    implementation 'commons-codec:commons-codec', {
        // impl: Base64
    }
    implementation 'org.apache.grails:grails-codecs', {
        // impl: URLCodec
    }
    implementation 'org.apache.grails:grails-converters', {
        // impl: JSON
    }
    implementation "org.pac4j:pac4j-jakartaee:$pac4jVersion", {
        // impl: JEEContext, JEESessionStore
    }
    implementation 'org.springframework:spring-core', {
        // impl: Assert
    }

    runtimeOnly 'org.apache.grails:grails-services', {
        // Project has services
    }

    compileOnly 'org.apache.groovy:groovy' // Provided as this is a Grails plugin
    compileOnly 'org.apache.grails:grails-core' // Provided as this is a Grails plugin
    compileOnly 'org.apache.grails:grails-controllers', {
        // ControllerTraitInjector
    }
    compileOnly 'jakarta.servlet:jakarta.servlet-api', { // Provided by Tomcat
        // api: FilterChain, HttpServletResponse, HttpServletRequest, ServletException, ServletRequest, ServletResponse
    }

    testImplementation "org.pac4j:pac4j-oauth:$pac4jVersion", {
        // impl: CasOAuthWrapperClient
    }
    testImplementation 'org.gperfutils:gbench:0.4.3-groovy-2.4'
    testImplementation 'org.apache.grails:grails-testing-support-datamapping'
    testImplementation 'org.apache.grails:grails-testing-support-web'
    testImplementation 'org.spockframework:spock-core'

    testRuntimeOnly 'net.bytebuddy:byte-buddy'
}

apply {
    from rootProject.layout.projectDirectory.file('gradle/plugin-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/groovydoc-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/publish-config.gradle')
    from rootProject.layout.projectDirectory.file('gradle/reproducible-config.gradle')
}