diff --git a/cas/cas-server/pom.xml b/cas/cas-server/pom.xml index bca48749b6653482abcaad084b2e113b082d6027..282462ba5d929710f73d3b42f9052400e47e7fca 100644 --- a/cas/cas-server/pom.xml +++ b/cas/cas-server/pom.xml @@ -138,26 +138,11 @@ <artifactId>cas-server-support-surrogate-authentication</artifactId> <version>${cas.version}</version> </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-surrogate-authentication-rest</artifactId> - <version>${cas.version}</version> - </dependency> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-support-surrogate-webflow</artifactId> <version>${cas.version}</version> </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-configuration</artifactId> - <version>${cas.version}</version> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-webflow</artifactId> - <version>${cas.version}</version> - </dependency> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-core-services-api</artifactId> diff --git a/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/authentication/IamSurrogateRestAuthenticationService.java b/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/authentication/IamSurrogateAuthenticationService.java similarity index 90% rename from cas/cas-server/src/main/java/fr/gouv/vitamui/cas/authentication/IamSurrogateRestAuthenticationService.java rename to cas/cas-server/src/main/java/fr/gouv/vitamui/cas/authentication/IamSurrogateAuthenticationService.java index 072a03748b0a42342ce3d6cf3dac0ecbe9e22ba2..24b7617541a7701a9a8bfc925cc52e88d6f0d854 100644 --- a/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/authentication/IamSurrogateRestAuthenticationService.java +++ b/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/authentication/IamSurrogateAuthenticationService.java @@ -52,20 +52,20 @@ import java.util.List; import lombok.val; /** - * Specific surrogate REST based on the IAM API. + * Specific surrogate service based on the IAM API. * * */ -public class IamSurrogateRestAuthenticationService extends BaseSurrogateAuthenticationService { +public class IamSurrogateAuthenticationService extends BaseSurrogateAuthenticationService { - private static final VitamUILogger LOGGER = VitamUILoggerFactory.getInstance(IamSurrogateRestAuthenticationService.class); + private static final VitamUILogger LOGGER = VitamUILoggerFactory.getInstance(IamSurrogateAuthenticationService.class); private final CasExternalRestClient casExternalRestClient; private final Utils utils; - public IamSurrogateRestAuthenticationService(final CasExternalRestClient casExternalRestClient, - final ServicesManager servicesManager, final Utils utils) { + public IamSurrogateAuthenticationService(final CasExternalRestClient casExternalRestClient, + final ServicesManager servicesManager, final Utils utils) { super(servicesManager); this.casExternalRestClient = casExternalRestClient; this.utils = utils; diff --git a/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/config/AppConfig.java b/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/config/AppConfig.java index a4635ed69b13e12c78b531f9a21784aad730302e..2c074020ce1ccd7e1bc1b8d7bbb48fe77e4954f5 100644 --- a/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/config/AppConfig.java +++ b/cas/cas-server/src/main/java/fr/gouv/vitamui/cas/config/AppConfig.java @@ -37,6 +37,8 @@ package fr.gouv.vitamui.cas.config; import fr.gouv.vitamui.cas.authentication.DelegatedSurrogateAuthenticationPostProcessor; +import fr.gouv.vitamui.cas.authentication.IamSurrogateAuthenticationService; +import lombok.SneakyThrows; import org.apereo.cas.audit.AuditableExecution; import org.apereo.cas.authentication.*; import org.apereo.cas.authentication.principal.PrincipalFactory; @@ -260,4 +262,11 @@ public class AppConfig extends BaseTicketCatalogConfigurer { metadata.getProperties().setStorageTimeout(apiTokenTtl); registerTicketDefinition(plan, metadata); } + + @RefreshScope + @Bean + @SneakyThrows + public SurrogateAuthenticationService surrogateAuthenticationService() { + return new IamSurrogateAuthenticationService(casRestClient(), servicesManager, utils()); + } } diff --git a/cas/cas-server/src/main/java/org/apereo/cas/config/SurrogateRestAuthenticationConfiguration.java b/cas/cas-server/src/main/java/org/apereo/cas/config/SurrogateRestAuthenticationConfiguration.java deleted file mode 100644 index c3c6586b93bc9f5910a4be70c96a0c8ebd5ab890..0000000000000000000000000000000000000000 --- a/cas/cas-server/src/main/java/org/apereo/cas/config/SurrogateRestAuthenticationConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apereo.cas.config; - -import fr.gouv.vitamui.cas.util.Utils; -import lombok.extern.slf4j.Slf4j; -import org.apereo.cas.authentication.surrogate.SurrogateAuthenticationService; -import org.apereo.cas.configuration.CasConfigurationProperties; -import org.apereo.cas.services.ServicesManager; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import fr.gouv.vitamui.cas.authentication.IamSurrogateRestAuthenticationService; -import fr.gouv.vitamui.iam.external.client.CasExternalRestClient; - -/** - * Overrides the configuration class from the CAS server, using the CasExternalRestClient. - * - * - */ -@Configuration(value = "surrogateRestAuthenticationConfiguration", proxyBeanMethods = false) -@EnableConfigurationProperties(CasConfigurationProperties.class) -@Slf4j -public class SurrogateRestAuthenticationConfiguration { - - @Autowired - @Qualifier("servicesManager") - private ObjectProvider<ServicesManager> servicesManager; - - // customisation: - @Autowired - private CasExternalRestClient casExternalRestClient; - - @Autowired - private Utils utils; - - @RefreshScope - @Bean - public SurrogateAuthenticationService surrogateAuthenticationService() { - // customisation: - return new IamSurrogateRestAuthenticationService(casExternalRestClient, servicesManager.getObject(), utils); - } -} diff --git a/cas/cas-server/src/test/java/fr/gouv/vitamui/cas/authentication/IamSurrogateRestAuthenticationServiceTest.java b/cas/cas-server/src/test/java/fr/gouv/vitamui/cas/authentication/IamSurrogateAuthenticationServiceTest.java similarity index 92% rename from cas/cas-server/src/test/java/fr/gouv/vitamui/cas/authentication/IamSurrogateRestAuthenticationServiceTest.java rename to cas/cas-server/src/test/java/fr/gouv/vitamui/cas/authentication/IamSurrogateAuthenticationServiceTest.java index 3407b165eb6f8a8233a03e9a517b9067360330de..b94dd0eebaf86397d646e35f186d04f136ce6564 100644 --- a/cas/cas-server/src/test/java/fr/gouv/vitamui/cas/authentication/IamSurrogateRestAuthenticationServiceTest.java +++ b/cas/cas-server/src/test/java/fr/gouv/vitamui/cas/authentication/IamSurrogateAuthenticationServiceTest.java @@ -26,20 +26,20 @@ import static org.junit.Assert.*; import lombok.val; /** - * Tests {@link IamSurrogateRestAuthenticationService}. + * Tests {@link IamSurrogateAuthenticationService}. * * */ @RunWith(SpringRunner.class) @ContextConfiguration(classes = ServerIdentityAutoConfiguration.class) @TestPropertySource(locations = "classpath:/application-test.properties") -public final class IamSurrogateRestAuthenticationServiceTest { +public final class IamSurrogateAuthenticationServiceTest { private static final String SURROGATE = "surrogate"; private static final String SU_ID = "id"; private static final String SU_EMAIL = "superUser"; - private IamSurrogateRestAuthenticationService service; + private IamSurrogateAuthenticationService service; private CasExternalRestClient casExternalRestClient; @@ -48,7 +48,7 @@ public final class IamSurrogateRestAuthenticationServiceTest { casExternalRestClient = mock(CasExternalRestClient.class); val utils = new Utils(casExternalRestClient, null, 0, null, null); - service = new IamSurrogateRestAuthenticationService(casExternalRestClient, mock(ServicesManager.class), utils); + service = new IamSurrogateAuthenticationService(casExternalRestClient, mock(ServicesManager.class), utils); } @Test