moving configuration keys to a constant class

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1417396 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-05 12:56:48 +00:00
parent eef9c73382
commit 3c6f8dc455
5 changed files with 55 additions and 28 deletions

View File

@ -20,6 +20,7 @@ package org.apache.archiva.redback.common.ldap;
*/ */
import org.apache.archiva.redback.configuration.UserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.User;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -33,7 +34,6 @@ import java.util.Date;
/** /**
* @author <a href="jesse@codehaus.org"> jesse * @author <a href="jesse@codehaus.org"> jesse
*
*/ */
@Service( "userMapper#ldap" ) @Service( "userMapper#ldap" )
public class LdapUserMapper public class LdapUserMapper
@ -86,14 +86,17 @@ public class LdapUserMapper
@PostConstruct @PostConstruct
public void initialize() public void initialize()
{ {
emailAttribute = userConf.getString( "ldap.config.mapper.attribute.email", emailAttribute ); emailAttribute = userConf.getString( UserConfigurationKeys.LDAP_MAPPER_ATTRIBUTE_EMAIL, emailAttribute );
fullNameAttribute = userConf.getString( "ldap.config.mapper.attribute.fullname", fullNameAttribute ); fullNameAttribute =
passwordAttribute = userConf.getString( "ldap.config.mapper.attribute.password", passwordAttribute ); userConf.getString( UserConfigurationKeys.LDAP_MAPPER_ATTRIBUTE_FULLNAME, fullNameAttribute );
userIdAttribute = userConf.getString( "ldap.config.mapper.attribute.user.id", userIdAttribute ); passwordAttribute =
userConf.getString( UserConfigurationKeys.LDAP_MAPPER_ATTRIBUTE_PASSWORD, passwordAttribute );
userIdAttribute = userConf.getString( UserConfigurationKeys.LDAP_MAPPER_ATTRIBUTE_ID, userIdAttribute );
userBaseDn = userConf.getConcatenatedList( "ldap.config.mapper.attribute.user.base.dn", userBaseDn = userConf.getConcatenatedList( "ldap.config.mapper.attribute.user.base.dn",
userConf.getConcatenatedList( "ldap.config.base.dn", userBaseDn ) ); userConf.getConcatenatedList( "ldap.config.base.dn", userBaseDn ) );
userObjectClass = userConf.getString( "ldap.config.mapper.attribute.user.object.class", userObjectClass ); userObjectClass =
userFilter = userConf.getString( "ldap.config.mapper.attribute.user.filter", userFilter ); userConf.getString( UserConfigurationKeys.LDAP_MAPPER_ATTRIBUTE_OBJECT_CLASS, userObjectClass );
userFilter = userConf.getString( UserConfigurationKeys.LDAP_MAPPER_ATTRIBUTE_FILTER, userFilter );
maxResultCount = userConf.getInt( "ldap.config.max.result.count", maxResultCount ); maxResultCount = userConf.getInt( "ldap.config.max.result.count", maxResultCount );
} }

View File

@ -20,6 +20,7 @@ package org.apache.archiva.redback.common.ldap.connection;
*/ */
import org.apache.archiva.redback.configuration.UserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -34,7 +35,6 @@ import java.util.Properties;
/** /**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a> * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/ */
@Service( "ldapConnectionFactory#configurable" ) @Service( "ldapConnectionFactory#configurable" )
public class ConfigurableLdapConnectionFactory public class ConfigurableLdapConnectionFactory
@ -75,15 +75,16 @@ public class ConfigurableLdapConnectionFactory
try try
{ {
configuration = new LdapConnectionConfiguration(); configuration = new LdapConnectionConfiguration();
configuration.setHostname( userConf.getString( "ldap.config.hostname", hostname ) ); configuration.setHostname( userConf.getString( UserConfigurationKeys.LDAP_HOSTNAME, hostname ) );
configuration.setPort( userConf.getInt( "ldap.config.port", port ) ); configuration.setPort( userConf.getInt( "ldap.config.port", port ) );
configuration.setSsl( userConf.getBoolean( "ldap.config.ssl", ssl ) ); configuration.setSsl( userConf.getBoolean( "ldap.config.ssl", ssl ) );
configuration.setBaseDn( userConf.getConcatenatedList( "ldap.config.base.dn", baseDn ) ); configuration.setBaseDn( userConf.getConcatenatedList( "ldap.config.base.dn", baseDn ) );
configuration.setContextFactory( userConf.getString( "ldap.config.context.factory", contextFactory ) ); configuration.setContextFactory(
userConf.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY, contextFactory ) );
configuration.setBindDn( userConf.getConcatenatedList( "ldap.config.bind.dn", bindDn ) ); configuration.setBindDn( userConf.getConcatenatedList( "ldap.config.bind.dn", bindDn ) );
configuration.setPassword( userConf.getString( "ldap.config.password", password ) ); configuration.setPassword( userConf.getString( UserConfigurationKeys.LDAP_PASSWORD, password ) );
configuration.setAuthenticationMethod( configuration.setAuthenticationMethod(
userConf.getString( "ldap.config.authentication.method", authenticationMethod ) ); userConf.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, authenticationMethod ) );
configuration.setExtraProperties( extraProperties ); configuration.setExtraProperties( extraProperties );
} }
catch ( InvalidNameException e ) catch ( InvalidNameException e )

View File

@ -24,30 +24,52 @@ package org.apache.archiva.redback.configuration;
*/ */
public interface UserConfigurationKeys public interface UserConfigurationKeys
{ {
static final String USER_MANAGER_IMPL = "user.manager.impl"; String USER_MANAGER_IMPL = "user.manager.impl";
static final String DEFAULT_ADMIN = "redback.default.admin"; String DEFAULT_ADMIN = "redback.default.admin";
static final String EMAIL_FROM_ADDRESS = "email.from.address"; String EMAIL_FROM_ADDRESS = "email.from.address";
static final String EMAIL_FROM_NAME = "email.from.name"; String EMAIL_FROM_NAME = "email.from.name";
static final String EMAIL_FEEDBACK_PATH = "email.feedback.path"; String EMAIL_FEEDBACK_PATH = "email.feedback.path";
static final String APPLICATION_TIMESTAMP = "application.timestamp"; String APPLICATION_TIMESTAMP = "application.timestamp";
static final String PASSWORD_ENCODER = "security.policy.password.encoder"; String PASSWORD_ENCODER = "security.policy.password.encoder";
static final String EMAIL_VALIDATION_SUBJECT = "email.validation.subject"; String EMAIL_VALIDATION_SUBJECT = "email.validation.subject";
static final String REMEMBER_ME_PATH = "security.rememberme.path"; String REMEMBER_ME_PATH = "security.rememberme.path";
static final String REMEMBER_ME_DOMAIN = "security.rememberme.domain"; String REMEMBER_ME_DOMAIN = "security.rememberme.domain";
static final String SIGNON_DOMAIN = "security.signon.domain"; String SIGNON_DOMAIN = "security.signon.domain";
static final String SIGNON_PATH = "security.signon.path"; String SIGNON_PATH = "security.signon.path";
static final String USER_MANAGER_IMPL = "user.manager.impl"; String LDAP_HOSTNAME = "ldap.config.hostname";
String LDAP_CONTEX_FACTORY = "ldap.config.context.factory";
String LDAP_PASSWORD = "ldap.config.password";
String LDAP_AUTHENTICATION_METHOD = "ldap.config.authentication.method";
String APPLICATION_URL = "application.url";
String EMAIL_URL_PATH = "email.url.path";
String LDAP_MAPPER_ATTRIBUTE_EMAIL = "ldap.config.mapper.attribute.email";
String LDAP_MAPPER_ATTRIBUTE_FULLNAME = "ldap.config.mapper.attribute.fullname";
String LDAP_MAPPER_ATTRIBUTE_PASSWORD = "ldap.config.mapper.attribute.password";
String LDAP_MAPPER_ATTRIBUTE_ID = "ldap.config.mapper.attribute.user.id";
String LDAP_MAPPER_ATTRIBUTE_OBJECT_CLASS = "ldap.config.mapper.attribute.user.object.class";
String LDAP_MAPPER_ATTRIBUTE_FILTER = "ldap.config.mapper.attribute.user.filter";
} }

View File

@ -94,7 +94,7 @@ public class VelocityMailGenerator
{ {
VelocityContext context = new VelocityContext(); VelocityContext context = new VelocityContext();
context.put( "applicationUrl", config.getString( "application.url", appUrl ) ); context.put( "applicationUrl", config.getString( UserConfigurationKeys.APPLICATION_URL, appUrl ) );
String feedback = config.getString( UserConfigurationKeys.EMAIL_FEEDBACK_PATH ); String feedback = config.getString( UserConfigurationKeys.EMAIL_FEEDBACK_PATH );
@ -108,7 +108,8 @@ public class VelocityMailGenerator
context.put( "feedback", feedback ); context.put( "feedback", feedback );
} }
context.put( "urlPath", config.getString( "email.url.path", "security/login!login.action" ) ); context.put( "urlPath",
config.getString( UserConfigurationKeys.EMAIL_URL_PATH, "security/login!login.action" ) );
context.put( "authkey", authkey.getKey() ); context.put( "authkey", authkey.getKey() );

View File

@ -52,7 +52,7 @@ public class ConfigurableUserManager
@PostConstruct @PostConstruct
public void initialize() public void initialize()
{ {
String userManagerRole = config.getString(); String userManagerRole = config.getString( UserConfigurationKeys.USER_MANAGER_IMPL );
if ( userManagerRole == null ) if ( userManagerRole == null )
{ {