From cf74f4eee2f3e495beaea38a006d6f00fc692e4b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 20 Feb 2013 22:39:53 +0000 Subject: [PATCH] reload rbac manager if changed git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1448448 13f79535-47bb-0310-9956-ffa450edef68 --- ...ultRedbackRuntimeConfigurationService.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index 0545452e7..9bb8bffd4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -58,7 +58,7 @@ import java.util.Properties; * @author Olivier Lamy * @since 1.4-M4 */ -@Service("redbackRuntimeConfigurationService#rest") +@Service( "redbackRuntimeConfigurationService#rest" ) public class DefaultRedbackRuntimeConfigurationService extends AbstractRestService implements RedbackRuntimeConfigurationService @@ -67,18 +67,22 @@ public class DefaultRedbackRuntimeConfigurationService private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin; @Inject - @Named(value = "userManager#configurable") + @Named( value = "userManager#configurable" ) private UserManager userManager; + @Inject + @Named( value = "rbacManager#default" ) + private RBACManager rbacManager; + @Inject private ApplicationContext applicationContext; @Inject - @Named(value = "ldapConnectionFactory#configurable") + @Named( value = "ldapConnectionFactory#configurable" ) private LdapConnectionFactory ldapConnectionFactory; @Inject - @Named(value = "cache#users") + @Named( value = "cache#users" ) private Cache usersCache; @Inject @@ -111,6 +115,13 @@ public class DefaultRedbackRuntimeConfigurationService userManagerChanged || ( redbackRuntimeConfiguration.getUserManagerImpls().toString().hashCode() != redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getUserManagerImpls().toString().hashCode() ); + boolean rbacManagerChanged = redbackRuntimeConfiguration.getRbacManagerImpls().size() + != redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls().size(); + + rbacManagerChanged = + rbacManagerChanged || ( redbackRuntimeConfiguration.getRbacManagerImpls().toString().hashCode() + != redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls().toString().hashCode() ); + redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration ); if ( userManagerChanged ) @@ -120,6 +131,13 @@ public class DefaultRedbackRuntimeConfigurationService userManager.initialize(); } + if ( rbacManagerChanged ) + { + log.info( "rbac manager changed to {} so reload it", + redbackRuntimeConfiguration.getRbacManagerImpls() ); + rbacManager.initialize(); + } + ldapConnectionFactory.initialize(); Collection passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values(); @@ -233,7 +251,7 @@ public class DefaultRedbackRuntimeConfigurationService throws ArchivaRestServiceException { return new RedbackImplementationsInformations( getUserManagerImplementationInformations(), - getRbacManagerImplementationInformations() ); + getRbacManagerImplementationInformations() ); } public Boolean checkLdapConnection()