From 8e5b125dfb39acec97d4233c16cdb45e729b5aaf Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 10 Dec 2012 22:33:25 +0000 Subject: [PATCH] make that more easy to override git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1419841 13f79535-47bb-0310-9956-ffa450edef68 --- .../ConfigurableLdapConnectionFactory.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java index c67da2e6..56a38fc6 100644 --- a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java +++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/connection/ConfigurableLdapConnectionFactory.java @@ -59,7 +59,7 @@ public class ConfigurableLdapConnectionFactory private Properties extraProperties; - private LdapConnectionConfiguration configuration; + private LdapConnectionConfiguration ldapConnectionConfiguration; @Inject @@ -74,18 +74,18 @@ public class ConfigurableLdapConnectionFactory { try { - configuration = new LdapConnectionConfiguration(); - configuration.setHostname( userConf.getString( UserConfigurationKeys.LDAP_HOSTNAME, hostname ) ); - configuration.setPort( userConf.getInt( UserConfigurationKeys.LDAP_PORT, port ) ); - configuration.setSsl( userConf.getBoolean( UserConfigurationKeys.LDAP_SSL, ssl ) ); - configuration.setBaseDn( userConf.getConcatenatedList( UserConfigurationKeys.LDAP_BASEDN, baseDn ) ); - configuration.setContextFactory( + ldapConnectionConfiguration = new LdapConnectionConfiguration(); + 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.setContextFactory( userConf.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, contextFactory ) ); - configuration.setBindDn( userConf.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, bindDn ) ); - configuration.setPassword( userConf.getString( UserConfigurationKeys.LDAP_PASSWORD, password ) ); - configuration.setAuthenticationMethod( + 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 ) ); - configuration.setExtraProperties( extraProperties ); + ldapConnectionConfiguration.setExtraProperties( extraProperties ); } catch ( InvalidNameException e ) { @@ -100,19 +100,19 @@ public class ConfigurableLdapConnectionFactory public LdapConnection getConnection() throws LdapException { - return new LdapConnection( configuration, null ); + return new LdapConnection( getLdapConnectionConfiguration(), null ); } public LdapConnection getConnection( Rdn subRdn ) throws LdapException { - return new LdapConnection( configuration, subRdn ); + return new LdapConnection( getLdapConnectionConfiguration(), subRdn ); } public LdapConnection getConnection( String bindDn, String password ) throws LdapException { - return new LdapConnection( configuration, bindDn, password ); + return new LdapConnection( getLdapConnectionConfiguration(), bindDn, password ); } public LdapName getBaseDnLdapName() @@ -130,12 +130,12 @@ public class ConfigurableLdapConnectionFactory public void addObjectFactory( Class objectFactoryClass ) { - configuration.getObjectFactories().add( objectFactoryClass ); + getLdapConnectionConfiguration().getObjectFactories().add( objectFactoryClass ); } public void addStateFactory( Class stateFactoryClass ) { - configuration.getStateFactories().add( stateFactoryClass ); + getLdapConnectionConfiguration().getStateFactories().add( stateFactoryClass ); } // ---------------------------------------------------------------------- @@ -144,12 +144,17 @@ public class ConfigurableLdapConnectionFactory public String toString() { - return "{ConfigurableLdapConnectionFactory: configuration: " + configuration + "}"; + return "{ConfigurableLdapConnectionFactory: configuration: " + getLdapConnectionConfiguration() + "}"; } - public LdapConnectionConfiguration getConfiguration() + public LdapConnectionConfiguration getLdapConnectionConfiguration() { - return configuration; + return ldapConnectionConfiguration; + } + + public void setLdapConnectionConfiguration( LdapConnectionConfiguration ldapConnectionConfiguration ) + { + this.ldapConnectionConfiguration = ldapConnectionConfiguration; } public String getHostname()