diff options
author | Olivier Lamy <olamy@apache.org> | 2012-12-13 20:05:51 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-12-13 20:05:51 +0000 |
commit | a7d8f294a89f7bac3695658302c5b9014dc0bed9 (patch) | |
tree | 9bd3914d8f81b35c03a5bd42ce4c852b5a8538cc | |
parent | 9eaa2cc5537ed5a5d999d3698df31459ecb709b5 (diff) | |
download | archiva-a7d8f294a89f7bac3695658302c5b9014dc0bed9.tar.gz archiva-a7d8f294a89f7bac3695658302c5b9014dc0bed9.zip |
reload authenticators when configuration has changed
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1421476 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 32 insertions, 8 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java index 867e451c0..edff21d5a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java @@ -22,6 +22,8 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; +import org.apache.archiva.redback.authentication.AuthenticationException; +import org.apache.archiva.redback.authentication.Authenticator; import org.apache.archiva.redback.common.ldap.connection.LdapConnection; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory; @@ -121,8 +123,20 @@ public class DefaultArchivaRuntimeConfigurationService cookieSettings.initialize(); } + Collection<Authenticator> authenticators = + applicationContext.getBeansOfType( Authenticator.class ).values(); + + for ( Authenticator authenticator : authenticators ) + { + authenticator.initialize(); + } + return Boolean.TRUE; } + catch ( AuthenticationException e ) + { + throw new ArchivaRestServiceException( e.getMessage(), e ); + } catch ( RepositoryAdminException e ) { throw new ArchivaRestServiceException( e.getMessage(), e ); diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java index 8a8e54d78..8f51bc109 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaUserManagerAuthenticator.java @@ -20,6 +20,7 @@ package org.apache.archiva.web.security; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; +import org.apache.archiva.redback.authentication.AbstractAuthenticator; import org.apache.archiva.redback.authentication.AuthenticationConstants; import org.apache.archiva.redback.authentication.AuthenticationDataSource; import org.apache.archiva.redback.authentication.AuthenticationException; @@ -52,8 +53,9 @@ import java.util.Map; * @author Olivier Lamy * @since 1.4-M4 */ -@Service( "authenticator#archiva" ) +@Service("authenticator#archiva") public class ArchivaUserManagerAuthenticator + extends AbstractAuthenticator implements Authenticator { private Logger log = LoggerFactory.getLogger( getClass() ); @@ -70,17 +72,25 @@ public class ArchivaUserManagerAuthenticator private List<UserManager> userManagers; @PostConstruct - protected void initialize() - throws RepositoryAdminException + @Override + public void initialize() + throws AuthenticationException { - List<String> userManagerImpls = - archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls(); + try + { + List<String> userManagerImpls = + archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls(); - userManagers = new ArrayList<UserManager>( userManagerImpls.size() ); + userManagers = new ArrayList<UserManager>( userManagerImpls.size() ); - for ( String beanId : userManagerImpls ) + for ( String beanId : userManagerImpls ) + { + userManagers.add( applicationContext.getBean( "userManager#" + beanId, UserManager.class ) ); + } + } + catch ( RepositoryAdminException e ) { - userManagers.add( applicationContext.getBean( "userManager#" + beanId, UserManager.class ) ); + throw new AuthenticationException( e.getMessage(), e ); } } |