Repository: archiva Updated Branches: refs/heads/master 229276f8d -> 1fd9c951e
Improving error handling for LDAP configuration Error is only displayed, if LDAP is used as repository. The error messages are more detailed and internationalized. Project: http://git-wip-us.apache.org/repos/asf/archiva/repo Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/1fd9c951 Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/1fd9c951 Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/1fd9c951 Branch: refs/heads/master Commit: 1fd9c951e19a30f7636f4a924cb9e2bf06af2861 Parents: 229276f Author: Martin Stockhammer <[email protected]> Authored: Sun Oct 2 15:20:56 2016 +0200 Committer: Martin Stockhammer <[email protected]> Committed: Sun Oct 2 15:20:56 2016 +0200 ---------------------------------------------------------------------- ...faultRedbackRuntimeConfigurationService.java | 42 +++++++++++++++++--- .../org/apache/archiva/i18n/default.properties | 5 +++ 2 files changed, 42 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/archiva/blob/1fd9c951/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java ---------------------------------------------------------------------- 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 5d3aa8e..e319c36 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 @@ -132,6 +132,20 @@ public class DefaultRedbackRuntimeConfigurationService rbacManagerChanged || ( redbackRuntimeConfiguration.getRbacManagerImpls().toString().hashCode() != redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls().toString().hashCode() ); + boolean ldapConfigured = false; + for (String um : redbackRuntimeConfiguration.getUserManagerImpls()) { + if (um.contains("ldap")) { + ldapConfigured=true; + } + } + if (!ldapConfigured) { + for (String rbm : redbackRuntimeConfiguration.getRbacManagerImpls()) { + if (rbm.contains("ldap")) { + ldapConfigured = true; + } + } + } + redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration ); if ( userManagerChanged ) @@ -149,8 +163,15 @@ public class DefaultRedbackRuntimeConfigurationService roleManager.initialize(); } - ldapConnectionFactory.initialize(); - + if (ldapConfigured) { + try { + ldapConnectionFactory.initialize(); + } catch (Exception e) { + ArchivaRestServiceException newEx = new ArchivaRestServiceException(e.getMessage(), e); + newEx.setErrorKey("error.ldap.connectionFactory.init.failed"); + throw newEx; + } + } Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values(); for ( PasswordRule passwordRule : passwordRules ) @@ -184,16 +205,27 @@ public class DefaultRedbackRuntimeConfigurationService usersCache.setMaxElementsOnDisk( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() ); - ldapUserMapper.initialize(); + if (ldapConfigured) { + try { + ldapUserMapper.initialize(); + } catch (Exception e) { + ArchivaRestServiceException newEx = new ArchivaRestServiceException(e.getMessage(), e); + newEx.setErrorKey("error.ldap.userMapper.init.failed"); + throw newEx; + } + } //check repositories roles are here !!! return Boolean.TRUE; } - catch ( Exception e ) + catch (ArchivaRestServiceException e) { + log.error(e.getMessage(), e); + throw e; + } catch ( Exception e ) { log.error( e.getMessage(), e ); - throw new ArchivaRestServiceException( e.getMessage(), e ); + throw new ArchivaRestServiceException(e.getMessage(), e); } } http://git-wip-us.apache.org/repos/asf/archiva/blob/1fd9c951/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 34672bd..b5784b6 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -612,6 +612,7 @@ redback-runtime-configuration.title=Redback Runtime Configuration redback-runtime-configuration.updated=Redback Runtime Configuration updated. archiva.redback.usermanager.ldap=LDAP User Manager archiva.redback.usermanager.jdo=Database User Manager +archiva.redback.usermanager.jpa=Database JPA User Manager redback.runtime.properties.help.title=Property Description security.policy.password.rule.alphacount.enabled.help.content=Minimum of letter characters in the password. security.policy.password.rule.reuse.enabled.help.content=Prevent reuse of previous passwords. @@ -672,6 +673,7 @@ redback.runtime.users.cache.title=Users Cache archiva.redback.rbacmanager.ldap=LDAP RBac Manager archiva.redback.rbacmanager.jdo=Database RBac Manager +archiva.redback.rbackmanager.jpa=Database JPA RBac Manager archiva.redback.rbacmanager.cached=Cached RBac Manager redback.runtime.rbac-managers.impls.chose=RbacManager(s) chosen redback.runtime.rbac-managers.impls.available=Available RbacManagers @@ -717,3 +719,6 @@ navigation.next=Next navigation.first=First navigation.last=Last +# Error messages for LDAP configuration +error.ldap.connectionFactory.init.failed=Could not initialize LDAP connection factory. Check your LDAP configuration. +error.ldap.userMapper.init.failed=Could not initialize LDAP user mapper. Check your LDAP configuration.
