]> source.dussan.org Git - archiva.git/commitdiff
add a method to be able to test a LdapConnectionConfiguration
authorOlivier Lamy <olamy@apache.org>
Thu, 13 Dec 2012 20:02:47 +0000 (20:02 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 13 Dec 2012 20:02:47 +0000 (20:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1421463 13f79535-47bb-0310-9956-ffa450edef68

redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java
redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/LdapConnectionFactory.java

index 56a38fc6b00e31537e424f8e7ed71c45356f0f5c..ca4aced5b76daa9ec722cba5bdb56d39ab2b4427 100644 (file)
@@ -36,7 +36,7 @@ import java.util.Properties;
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  */
-@Service( "ldapConnectionFactory#configurable" )
+@Service("ldapConnectionFactory#configurable")
 public class ConfigurableLdapConnectionFactory
     implements LdapConnectionFactory
 {
@@ -63,7 +63,7 @@ public class ConfigurableLdapConnectionFactory
 
 
     @Inject
-    @Named( value = "userConfiguration#default" )
+    @Named(value = "userConfiguration#default")
     private UserConfiguration userConf;
 
     // ----------------------------------------------------------------------
@@ -75,14 +75,18 @@ public class ConfigurableLdapConnectionFactory
         try
         {
             ldapConnectionConfiguration = new LdapConnectionConfiguration();
-            ldapConnectionConfiguration.setHostname( userConf.getString( UserConfigurationKeys.LDAP_HOSTNAME, hostname ) );
+            ldapConnectionConfiguration.setHostname(
+                userConf.getString( UserConfigurationKeys.LDAP_HOSTNAME, hostname ) );
             ldapConnectionConfiguration.setPort( userConf.getInt( UserConfigurationKeys.LDAP_PORT, port ) );
             ldapConnectionConfiguration.setSsl( userConf.getBoolean( UserConfigurationKeys.LDAP_SSL, ssl ) );
-            ldapConnectionConfiguration.setBaseDn( userConf.getConcatenatedList( UserConfigurationKeys.LDAP_BASEDN, baseDn ) );
+            ldapConnectionConfiguration.setBaseDn(
+                userConf.getConcatenatedList( UserConfigurationKeys.LDAP_BASEDN, baseDn ) );
             ldapConnectionConfiguration.setContextFactory(
                 userConf.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, contextFactory ) );
-            ldapConnectionConfiguration.setBindDn( userConf.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, bindDn ) );
-            ldapConnectionConfiguration.setPassword( userConf.getString( UserConfigurationKeys.LDAP_PASSWORD, password ) );
+            ldapConnectionConfiguration.setBindDn(
+                userConf.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, bindDn ) );
+            ldapConnectionConfiguration.setPassword(
+                userConf.getString( UserConfigurationKeys.LDAP_PASSWORD, password ) );
             ldapConnectionConfiguration.setAuthenticationMethod(
                 userConf.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, authenticationMethod ) );
             ldapConnectionConfiguration.setExtraProperties( extraProperties );
@@ -115,6 +119,12 @@ public class ConfigurableLdapConnectionFactory
         return new LdapConnection( getLdapConnectionConfiguration(), bindDn, password );
     }
 
+    public LdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
+        throws LdapException
+    {
+        return new LdapConnection( ldapConnectionConfiguration, null );
+    }
+
     public LdapName getBaseDnLdapName()
         throws LdapException
     {
index a1cec39fbecdd461e369973b0db0f7c5f0ef216b..d81b3e2333a4024584cfcf603652c683b878092c 100644 (file)
@@ -33,6 +33,9 @@ public interface LdapConnectionFactory
     LdapConnection getConnection()
         throws LdapException;
 
+    LdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
+        throws LdapException;
+
     LdapConnection getConnection( Rdn subRdn )
         throws LdapException;