reload rbac manager if changed

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1448448 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-02-20 22:39:53 +00:00
parent 229a411720
commit cf74f4eee2
1 changed files with 23 additions and 5 deletions

View File

@ -58,7 +58,7 @@ import java.util.Properties;
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M4 * @since 1.4-M4
*/ */
@Service("redbackRuntimeConfigurationService#rest") @Service( "redbackRuntimeConfigurationService#rest" )
public class DefaultRedbackRuntimeConfigurationService public class DefaultRedbackRuntimeConfigurationService
extends AbstractRestService extends AbstractRestService
implements RedbackRuntimeConfigurationService implements RedbackRuntimeConfigurationService
@ -67,18 +67,22 @@ public class DefaultRedbackRuntimeConfigurationService
private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin; private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
@Inject @Inject
@Named(value = "userManager#configurable") @Named( value = "userManager#configurable" )
private UserManager userManager; private UserManager userManager;
@Inject
@Named( value = "rbacManager#default" )
private RBACManager rbacManager;
@Inject @Inject
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Inject @Inject
@Named(value = "ldapConnectionFactory#configurable") @Named( value = "ldapConnectionFactory#configurable" )
private LdapConnectionFactory ldapConnectionFactory; private LdapConnectionFactory ldapConnectionFactory;
@Inject @Inject
@Named(value = "cache#users") @Named( value = "cache#users" )
private Cache usersCache; private Cache usersCache;
@Inject @Inject
@ -111,6 +115,13 @@ public class DefaultRedbackRuntimeConfigurationService
userManagerChanged || ( redbackRuntimeConfiguration.getUserManagerImpls().toString().hashCode() userManagerChanged || ( redbackRuntimeConfiguration.getUserManagerImpls().toString().hashCode()
!= redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().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 ); redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
if ( userManagerChanged ) if ( userManagerChanged )
@ -120,6 +131,13 @@ public class DefaultRedbackRuntimeConfigurationService
userManager.initialize(); userManager.initialize();
} }
if ( rbacManagerChanged )
{
log.info( "rbac manager changed to {} so reload it",
redbackRuntimeConfiguration.getRbacManagerImpls() );
rbacManager.initialize();
}
ldapConnectionFactory.initialize(); ldapConnectionFactory.initialize();
Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values(); Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values();
@ -233,7 +251,7 @@ public class DefaultRedbackRuntimeConfigurationService
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
return new RedbackImplementationsInformations( getUserManagerImplementationInformations(), return new RedbackImplementationsInformations( getUserManagerImplementationInformations(),
getRbacManagerImplementationInformations() ); getRbacManagerImplementationInformations() );
} }
public Boolean checkLdapConnection() public Boolean checkLdapConnection()