* @author Olivier Lamy
* @since 1.4-M4
*/
-@Service("redbackRuntimeConfigurationAdmin#default")
+@Service( "redbackRuntimeConfigurationAdmin#default" )
public class DefaultRedbackRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements RedbackRuntimeConfigurationAdmin, UserConfiguration
@Inject
public DefaultRedbackRuntimeConfigurationAdmin( ArchivaConfiguration archivaConfiguration,//
- @Named(value = "userConfiguration#redback") //
+ @Named( value = "userConfiguration#redback" ) //
UserConfiguration userConfiguration,
- @Named(value = "cache#users") Cache usersCache )
+ @Named( value = "cache#users" ) Cache usersCache )
{
this.archivaConfiguration = archivaConfiguration;
this.userConfiguration = userConfiguration;
redbackRuntimeConfiguration = new RedbackRuntimeConfiguration();
// so migrate if available
String userManagerImpl =
- userConfiguration.getConcatenatedList( UserConfigurationKeys.USER_MANAGER_IMPL, "jdo" );
+ userConfiguration.getConcatenatedList( UserConfigurationKeys.USER_MANAGER_IMPL, //
+ DEFAULT_USER_MANAGER_IMPL );
if ( StringUtils.isNotEmpty( userManagerImpl ) )
{
String[] impls = StringUtils.split( userManagerImpl, ',' );
redbackRuntimeConfiguration.getUserManagerImpls().add( impl );
}
}
+ else
+ {
+ redbackRuntimeConfiguration.getUserManagerImpls().add( DEFAULT_USER_MANAGER_IMPL );
+ }
String rbacManagerImpls =
- userConfiguration.getConcatenatedList( UserConfigurationKeys.RBAC_MANAGER_IMPL, "jdo" );
+ userConfiguration.getConcatenatedList( UserConfigurationKeys.RBAC_MANAGER_IMPL, //
+ DEFAULT_RBAC_MANAGER_IMPL );
if ( StringUtils.isNotEmpty( rbacManagerImpls ) )
{
redbackRuntimeConfiguration.getRbacManagerImpls().add( impl );
}
}
+ else
+ {
+ redbackRuntimeConfiguration.getRbacManagerImpls().add( DEFAULT_RBAC_MANAGER_IMPL );
+ }
// now ldap
ldapConfiguration.setBaseGroupsDn(
userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_GROUPS_BASEDN,
- ldapConfiguration.getBaseDn() )
- );
+ ldapConfiguration.getBaseDn() ) );
ldapConfiguration.setContextFactory(
userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY,
isSunContextFactoryAvailable()
? "com.sun.jndi.ldap.LdapCtxFactory"
- : ""
- )
- );
+ : "" ) );
ldapConfiguration.setBindDn(
userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, null ) );
ldapConfiguration.setPassword(
List<String> rbacManagerIds =
redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls();
+ if ( rbacManagerIds.isEmpty() )
+ {
+ rbacManagerIds.add( RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL );
+ }
+
log.info( "use rbacManagerIds: '{}'", rbacManagerIds );
this.rbacManagersPerId = new LinkedHashMap<>( rbacManagerIds.size() );
}
catch ( RepositoryAdminException e )
{
- // revert to a default one ?
+
log.error( e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e );
}
return rbacManager;
}
}
- return this.rbacManagersPerId.values().iterator().next();
+ return this.rbacManagersPerId.isEmpty() ? applicationContext.getBean(
+ "rbacManager#" + RedbackRuntimeConfigurationAdmin.DEFAULT_RBAC_MANAGER_IMPL, RBACManager.class ) //
+ : this.rbacManagersPerId.values().iterator().next();
}
@Override
@Override
public Permission createPermission( String name, String operationName, String resourceIdentifier )
throws RbacManagerException
- {
+ {
return getRbacManagerForWrite().createPermission( name, operationName, resourceIdentifier );
}
if ( lastException != null && allFailed )
{
throw new RbacManagerException( lastException.getMessage(), lastException );
- }
+ }
}
@Override
return r;
}
}
- catch ( Exception e )
+ catch ( Exception e )
{
lastException = e;
}
{
userAssignment = rbacManager.saveUserAssignment( userAssignment );
allFailed = false;
- }
+ }
}
catch ( Exception e )
{
{
for ( RBACManager rbacManager : rbacManagersPerId.values() )
{
- try
+ try
{
boolean exists = rbacManager.userAssignmentExists( assignment );
if ( exists )
}
catch ( Exception e )
{
- lastException = e;
+ lastException = e;
}
}