archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1449089 - /archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java
Date Fri, 22 Feb 2013 16:04:29 GMT
Author: olamy
Date: Fri Feb 22 16:04:29 2013
New Revision: 1449089

URL: http://svn.apache.org/r1449089
Log:
ease users life for ldap setup make com.sun.jndi.ldap.LdapCtxFactory default if available.

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java?rev=1449089&r1=1449088&r2=1449089&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java
Fri Feb 22 16:04:29 2013
@@ -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 DefaultRedbackRuntimeConfig
     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 DefaultRedbackRuntimeConfig
                                                            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 DefaultRedbackRuntimeConfig
         }
     }
 
+    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()
);



Mime
View raw message