extract an interface to be able to override the impl in archiva

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1414452 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-27 22:50:13 +00:00
parent b23cf34cc0
commit 8bf7b14a83
17 changed files with 91 additions and 39 deletions

View File

@ -21,7 +21,7 @@ package org.apache.archiva.redback.authentication.ldap;
import org.apache.archiva.redback.common.ldap.UserMapper; import org.apache.archiva.redback.common.ldap.UserMapper;
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.archiva.redback.authentication.AuthenticationDataSource; import org.apache.archiva.redback.authentication.AuthenticationDataSource;
import org.apache.archiva.redback.authentication.AuthenticationException; import org.apache.archiva.redback.authentication.AuthenticationException;
@ -65,7 +65,7 @@ public class LdapBindAuthenticator
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration config; private UserConfiguration config;
@Inject @Inject
private LdapCacheService ldapCacheService; private LdapCacheService ldapCacheService;

View File

@ -20,7 +20,7 @@ package org.apache.archiva.redback.common.jdo;
*/ */
import org.apache.archiva.redback.components.jdo.DefaultConfigurableJdoFactory; import org.apache.archiva.redback.components.jdo.DefaultConfigurableJdoFactory;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
@ -48,7 +48,7 @@ public class UserConfigurableJdoFactory
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration config; private UserConfiguration config;
private String getConfigString( String key, String currentValue, String defaultValue ) private String getConfigString( String key, String currentValue, String defaultValue )
{ {
@ -116,12 +116,12 @@ public class UserConfigurableJdoFactory
super.initialize(); super.initialize();
} }
public DefaultUserConfiguration getConfig() public UserConfiguration getConfig()
{ {
return config; return config;
} }
public void setConfig( DefaultUserConfiguration config ) public void setConfig( UserConfiguration config )
{ {
this.config = config; this.config = config;
} }

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.common.ldap;
* under the License. * under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
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;
@ -81,7 +81,7 @@ public class LdapUserMapper
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration userConf; private UserConfiguration userConf;
@PostConstruct @PostConstruct
public void initialize() public void initialize()
@ -301,12 +301,12 @@ public class LdapUserMapper
getPasswordAttribute() }; getPasswordAttribute() };
} }
public DefaultUserConfiguration getUserConf() public UserConfiguration getUserConf()
{ {
return userConf; return userConf;
} }
public void setUserConf( DefaultUserConfiguration userConf ) public void setUserConf( UserConfiguration userConf )
{ {
this.userConf = userConf; this.userConf = userConf;
} }

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.common.ldap.connection;
* under the License. * under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -90,7 +90,7 @@ public class ConfigurableLdapConnectionFactory
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration userConf; private UserConfiguration userConf;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Component Lifecycle // Component Lifecycle
@ -267,12 +267,12 @@ public class ConfigurableLdapConnectionFactory
this.extraProperties = extraProperties; this.extraProperties = extraProperties;
} }
public DefaultUserConfiguration getUserConf() public UserConfiguration getUserConf()
{ {
return userConf; return userConf;
} }
public void setUserConf( DefaultUserConfiguration userConf ) public void setUserConf( UserConfiguration userConf )
{ {
this.userConf = userConf; this.userConf = userConf;
} }

View File

@ -43,6 +43,7 @@ import java.util.List;
*/ */
@Service( "userConfiguration" ) @Service( "userConfiguration" )
public class DefaultUserConfiguration public class DefaultUserConfiguration
implements UserConfiguration
{ {
private static final String DEFAULT_CONFIG_RESOURCE = "org/apache/archiva/redback/config-defaults.properties"; private static final String DEFAULT_CONFIG_RESOURCE = "org/apache/archiva/redback/config-defaults.properties";

View File

@ -0,0 +1,51 @@
package org.apache.archiva.redback.configuration;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.archiva.redback.components.registry.RegistryException;
import javax.annotation.PostConstruct;
import java.util.List;
/**
* @author Olivier Lamy
*/
public interface UserConfiguration
{
@PostConstruct
void initialize()
throws RegistryException;
String getString( String key );
String getString( String key, String defaultValue );
int getInt( String key );
int getInt( String key, int defaultValue );
boolean getBoolean( String key );
boolean getBoolean( String key, boolean defaultValue );
@SuppressWarnings( "unchecked" )
List<String> getList( String key );
String getConcatenatedList( String key, String defaultValue );
}

View File

@ -42,7 +42,7 @@ public class DefaultUserConfigurationTest
{ {
@Inject @Named(value = "test") @Inject @Named(value = "test")
DefaultUserConfiguration config; UserConfiguration config;
private void assertEmpty( String str ) private void assertEmpty( String str )
{ {

View File

@ -20,7 +20,7 @@ package org.apache.archiva.redback.integration.checks.security;
*/ */
import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource; import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.rbac.RBACManager; import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.role.RoleManager; import org.apache.archiva.redback.role.RoleManager;
import org.apache.archiva.redback.role.RoleManagerException; import org.apache.archiva.redback.role.RoleManagerException;
@ -68,7 +68,7 @@ public class AdminAutoCreateCheck
private UserManager userManager; private UserManager userManager;
@Inject @Inject
private DefaultUserConfiguration config; private UserConfiguration config;
@Inject @Inject
protected SecuritySystem securitySystem; protected SecuritySystem securitySystem;

View File

@ -33,7 +33,7 @@ import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.keys.AuthenticationKey; import org.apache.archiva.redback.keys.AuthenticationKey;
import org.apache.archiva.redback.policy.UserSecurityPolicy; import org.apache.archiva.redback.policy.UserSecurityPolicy;
import org.apache.archiva.redback.policy.UserValidationSettings; import org.apache.archiva.redback.policy.UserValidationSettings;
@ -66,7 +66,7 @@ public class MailerImpl
private SecuritySystem securitySystem; private SecuritySystem securitySystem;
@Inject @Named(value="userConfiguration") @Inject @Named(value="userConfiguration")
private DefaultUserConfiguration config; private UserConfiguration config;
public void sendAccountValidationEmail( Collection<String> recipients, AuthenticationKey authkey, String baseUrl ) public void sendAccountValidationEmail( Collection<String> recipients, AuthenticationKey authkey, String baseUrl )
{ {

View File

@ -19,13 +19,13 @@ package org.apache.archiva.redback.integration.mail;
* under the License. * under the License.
*/ */
import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.keys.AuthenticationKey; import org.apache.archiva.redback.keys.AuthenticationKey;
import org.apache.velocity.VelocityContext; import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.MethodInvocationException; import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -50,7 +50,7 @@ public class VelocityMailGenerator
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration config; private UserConfiguration config;
// FIXME use the spring directly // FIXME use the spring directly
@Inject @Inject
@ -130,12 +130,12 @@ public class VelocityMailGenerator
} }
public DefaultUserConfiguration getConfig() public UserConfiguration getConfig()
{ {
return config; return config;
} }
public void setConfig( DefaultUserConfiguration config ) public void setConfig( UserConfiguration config )
{ {
this.config = config; this.config = config;
} }

View File

@ -23,7 +23,7 @@ import net.sf.ehcache.CacheManager;
import org.apache.archiva.redback.authentication.AuthenticationException; import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource; import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource;
import org.apache.archiva.redback.components.cache.Cache; import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator; import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
import org.apache.archiva.redback.integration.mail.Mailer; import org.apache.archiva.redback.integration.mail.Mailer;
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
@ -87,7 +87,7 @@ public class DefaultUserService
private SecuritySystem securitySystem; private SecuritySystem securitySystem;
@Inject @Inject
private DefaultUserConfiguration config; private UserConfiguration config;
@Inject @Inject
private RoleManager roleManager; private RoleManager roleManager;

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.rest.services;
* under the License. * under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.rbac.RBACManager; import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.users.UserManager; import org.apache.archiva.redback.users.UserManager;
import org.apache.archiva.redback.role.RoleManager; import org.apache.archiva.redback.role.RoleManager;
@ -44,7 +44,7 @@ public class FakeCreateAdminServiceImpl
private UserManager userManager; private UserManager userManager;
@Inject @Inject
private DefaultUserConfiguration config; private UserConfiguration config;
@Inject @Inject
private RoleManager roleManager; private RoleManager roleManager;

View File

@ -22,7 +22,7 @@ package org.apache.archiva.redback.policy;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
/** /**
* Base class for cookie settings. These will only differ by their configuration keys. * Base class for cookie settings. These will only differ by their configuration keys.
@ -35,7 +35,7 @@ public abstract class AbstractCookieSettings
implements CookieSettings implements CookieSettings
{ {
@Inject @Named(value="userConfiguration") @Inject @Named(value="userConfiguration")
protected DefaultUserConfiguration config; protected UserConfiguration config;
/** /**
* Timeout (in minutes) for the sign on cookie. * Timeout (in minutes) for the sign on cookie.

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.policy;
* under the License. * under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.policy.rules.MustHavePasswordRule; import org.apache.archiva.redback.policy.rules.MustHavePasswordRule;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -65,7 +65,7 @@ public class DefaultUserSecurityPolicy
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration config; private UserConfiguration config;
@Inject @Inject
@Named( value = "passwordEncoder#sha256" ) @Named( value = "passwordEncoder#sha256" )
@ -402,12 +402,12 @@ public class DefaultUserSecurityPolicy
return signonCookieSettings; return signonCookieSettings;
} }
public DefaultUserConfiguration getConfig() public UserConfiguration getConfig()
{ {
return config; return config;
} }
public void setConfig( DefaultUserConfiguration config ) public void setConfig( UserConfiguration config )
{ {
this.config = config; this.config = config;
} }

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.policy;
* under the License. * under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -36,7 +36,7 @@ public class DefaultUserValidationSettings
implements UserValidationSettings implements UserValidationSettings
{ {
@Resource (name="userConfiguration") @Resource (name="userConfiguration")
private DefaultUserConfiguration config; private UserConfiguration config;
private boolean emailValidationRequired; private boolean emailValidationRequired;

View File

@ -16,7 +16,7 @@ package org.apache.archiva.redback.policy.rules;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.policy.PasswordRule; import org.apache.archiva.redback.policy.PasswordRule;
import javax.inject.Inject; import javax.inject.Inject;
@ -34,7 +34,7 @@ public abstract class AbstractPasswordRule
protected boolean enabled = true; protected boolean enabled = true;
@Inject @Named (value="userConfiguration") @Inject @Named (value="userConfiguration")
protected DefaultUserConfiguration config; protected UserConfiguration config;
public boolean isEnabled() public boolean isEnabled()
{ {

View File

@ -16,7 +16,7 @@ package org.apache.archiva.redback.users.configurable;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.archiva.redback.configuration.DefaultUserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.users.AbstractUserManager; import org.apache.archiva.redback.users.AbstractUserManager;
import org.apache.archiva.redback.users.User; import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.users.UserManager; import org.apache.archiva.redback.users.UserManager;
@ -40,7 +40,7 @@ public class ConfigurableUserManager
{ {
@Inject @Inject
@Named( value = "userConfiguration" ) @Named( value = "userConfiguration" )
private DefaultUserConfiguration config; private UserConfiguration config;
@Inject @Inject
private ApplicationContext applicationContext; private ApplicationContext applicationContext;