mirror of https://github.com/apache/archiva.git
[MRM-1807] Archiva wrapper fail to start
This commit is contained in:
parent
ae9b109306
commit
021bbaf5a1
|
@ -27,6 +27,11 @@ import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
|
|||
*/
|
||||
public interface RedbackRuntimeConfigurationAdmin
|
||||
{
|
||||
|
||||
static final String DEFAULT_RBAC_MANAGER_IMPL = "jdo";
|
||||
|
||||
static final String DEFAULT_USER_MANAGER_IMPL = "jdo";
|
||||
|
||||
RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
|
||||
throws RepositoryAdminException;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ import java.util.Set;
|
|||
* @author Olivier Lamy
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
@Service("redbackRuntimeConfigurationAdmin#default")
|
||||
@Service( "redbackRuntimeConfigurationAdmin#default" )
|
||||
public class DefaultRedbackRuntimeConfigurationAdmin
|
||||
extends AbstractRepositoryAdmin
|
||||
implements RedbackRuntimeConfigurationAdmin, UserConfiguration
|
||||
|
@ -68,9 +68,9 @@ public class DefaultRedbackRuntimeConfigurationAdmin
|
|||
|
||||
@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;
|
||||
|
@ -92,7 +92,8 @@ public class DefaultRedbackRuntimeConfigurationAdmin
|
|||
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, ',' );
|
||||
|
@ -101,9 +102,14 @@ public class DefaultRedbackRuntimeConfigurationAdmin
|
|||
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 ) )
|
||||
{
|
||||
|
@ -113,6 +119,10 @@ public class DefaultRedbackRuntimeConfigurationAdmin
|
|||
redbackRuntimeConfiguration.getRbacManagerImpls().add( impl );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
redbackRuntimeConfiguration.getRbacManagerImpls().add( DEFAULT_RBAC_MANAGER_IMPL );
|
||||
}
|
||||
|
||||
// now ldap
|
||||
|
||||
|
@ -132,16 +142,13 @@ public class DefaultRedbackRuntimeConfigurationAdmin
|
|||
|
||||
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(
|
||||
|
|
|
@ -98,6 +98,11 @@ public class ArchivaRbacManager
|
|||
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() );
|
||||
|
@ -111,7 +116,7 @@ public class ArchivaRbacManager
|
|||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
// revert to a default one ?
|
||||
|
||||
log.error( e.getMessage(), e );
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
|
@ -126,7 +131,9 @@ public class ArchivaRbacManager
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue