From: Olivier Lamy Date: Fri, 22 Feb 2013 16:04:29 +0000 (+0000) Subject: ease users life for ldap setup make com.sun.jndi.ldap.LdapCtxFactory default if avail... X-Git-Tag: archiva-1.4-M4~136 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b7df9ae27ef66e30f88334934640d025062ac265;p=archiva.git ease users life for ldap setup make com.sun.jndi.ldap.LdapCtxFactory default if available. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1449089 13f79535-47bb-0310-9956-ffa450edef68 --- 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 7801ded47..e582f628e 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 @@ -53,7 +53,7 @@ import java.util.Set; * @author Olivier Lamy * @since 1.4-M4 */ -@Service( "userConfiguration#archiva" ) +@Service("userConfiguration#archiva") public class DefaultRedbackRuntimeConfigurationAdmin implements RedbackRuntimeConfigurationAdmin, UserConfiguration { @@ -64,11 +64,11 @@ public class DefaultRedbackRuntimeConfigurationAdmin private ArchivaConfiguration archivaConfiguration; @Inject - @Named( value = "userConfiguration#redback" ) + @Named(value = "userConfiguration#redback") UserConfiguration userConfiguration; @Inject - @Named( value = "cache#users" ) + @Named(value = "cache#users") private Cache usersCache; @PostConstruct @@ -128,7 +128,10 @@ public class DefaultRedbackRuntimeConfigurationAdmin ldapConfiguration.getBaseDn() ) ); ldapConfiguration.setContextFactory( - userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, null ) ); + userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, + isSunContextFactoryAvailable() + ? "com.sun.jndi.ldap.LdapCtxFactory" + : "" ) ); ldapConfiguration.setBindDn( userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, null ) ); ldapConfiguration.setPassword( @@ -226,6 +229,19 @@ public class DefaultRedbackRuntimeConfigurationAdmin } } + private boolean isSunContextFactoryAvailable() + { + try + { + return Thread.currentThread().getContextClassLoader().loadClass( "com.sun.jndi.ldap.LdapCtxFactory" ) + != null; + } + catch ( ClassNotFoundException e ) + { + return false; + } + } + public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() { return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() );