add a method to be able to test a LdapConnectionConfiguration

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1421463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-13 20:02:47 +00:00
parent 626a747eac
commit ea77187178
2 changed files with 19 additions and 6 deletions

View 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
{

View File

@ -33,6 +33,9 @@ public interface LdapConnectionFactory
LdapConnection getConnection()
throws LdapException;
LdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
throws LdapException;
LdapConnection getConnection( Rdn subRdn )
throws LdapException;