From: Olivier Lamy Date: Wed, 5 Nov 2014 10:39:00 +0000 (+1100) Subject: [MRM-1807] Archiva wrapper fail to start X-Git-Tag: archiva-2.2.0~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=021bbaf5a142c5ebbc5b1f9c4d30cc1aa796506e;p=archiva.git [MRM-1807] Archiva wrapper fail to start --- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java index 3bb9a1199..8fae6a66a 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/RedbackRuntimeConfigurationAdmin.java @@ -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; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index 2ff43b3d0..34ed1b606 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -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( diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java index 0628eb12b..143f3c21b 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java @@ -98,6 +98,11 @@ public class ArchivaRbacManager List 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 @@ -294,7 +301,7 @@ public class ArchivaRbacManager @Override public Permission createPermission( String name, String operationName, String resourceIdentifier ) throws RbacManagerException - { + { return getRbacManagerForWrite().createPermission( name, operationName, resourceIdentifier ); } @@ -418,7 +425,7 @@ public class ArchivaRbacManager if ( lastException != null && allFailed ) { throw new RbacManagerException( lastException.getMessage(), lastException ); - } + } } @Override @@ -609,7 +616,7 @@ public class ArchivaRbacManager return r; } } - catch ( Exception e ) + catch ( Exception e ) { lastException = e; } @@ -700,7 +707,7 @@ public class ArchivaRbacManager { userAssignment = rbacManager.saveUserAssignment( userAssignment ); allFailed = false; - } + } } catch ( Exception e ) { @@ -793,7 +800,7 @@ public class ArchivaRbacManager { for ( RBACManager rbacManager : rbacManagersPerId.values() ) { - try + try { boolean exists = rbacManager.userAssignmentExists( assignment ); if ( exists ) @@ -929,7 +936,7 @@ public class ArchivaRbacManager } catch ( Exception e ) { - lastException = e; + lastException = e; } }