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.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.archiva.redback.authentication.AuthenticationDataSource;
import org.apache.archiva.redback.authentication.AuthenticationException;
@ -65,7 +65,7 @@ public class LdapBindAuthenticator
@Inject
@Named( value = "userConfiguration" )
private DefaultUserConfiguration config;
private UserConfiguration config;
@Inject
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.configuration.DefaultUserConfiguration;
import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.commons.lang.StringUtils;
import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
@ -48,7 +48,7 @@ public class UserConfigurableJdoFactory
@Inject
@Named( value = "userConfiguration" )
private DefaultUserConfiguration config;
private UserConfiguration config;
private String getConfigString( String key, String currentValue, String defaultValue )
{
@ -116,12 +116,12 @@ public class UserConfigurableJdoFactory
super.initialize();
}
public DefaultUserConfiguration getConfig()
public UserConfiguration getConfig()
{
return config;
}
public void setConfig( DefaultUserConfiguration config )
public void setConfig( UserConfiguration config )
{
this.config = config;
}

View File

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

View File

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

View File

@ -43,6 +43,7 @@ import java.util.List;
*/
@Service( "userConfiguration" )
public class DefaultUserConfiguration
implements UserConfiguration
{
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")
DefaultUserConfiguration config;
UserConfiguration config;
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.configuration.DefaultUserConfiguration;
import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.role.RoleManager;
import org.apache.archiva.redback.role.RoleManagerException;
@ -68,7 +68,7 @@ public class AdminAutoCreateCheck
private UserManager userManager;
@Inject
private DefaultUserConfiguration config;
private UserConfiguration config;
@Inject
protected SecuritySystem securitySystem;

View File

@ -33,7 +33,7 @@ import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
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.policy.UserSecurityPolicy;
import org.apache.archiva.redback.policy.UserValidationSettings;
@ -66,7 +66,7 @@ public class MailerImpl
private SecuritySystem securitySystem;
@Inject @Named(value="userConfiguration")
private DefaultUserConfiguration config;
private UserConfiguration config;
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.
*/
import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.keys.AuthenticationKey;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.archiva.redback.configuration.DefaultUserConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -50,7 +50,7 @@ public class VelocityMailGenerator
@Inject
@Named( value = "userConfiguration" )
private DefaultUserConfiguration config;
private UserConfiguration config;
// FIXME use the spring directly
@Inject
@ -130,12 +130,12 @@ public class VelocityMailGenerator
}
public DefaultUserConfiguration getConfig()
public UserConfiguration getConfig()
{
return config;
}
public void setConfig( DefaultUserConfiguration config )
public void setConfig( UserConfiguration 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.TokenBasedAuthenticationDataSource;
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.mail.Mailer;
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
@ -87,7 +87,7 @@ public class DefaultUserService
private SecuritySystem securitySystem;
@Inject
private DefaultUserConfiguration config;
private UserConfiguration config;
@Inject
private RoleManager roleManager;

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.rest.services;
* 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.users.UserManager;
import org.apache.archiva.redback.role.RoleManager;
@ -44,7 +44,7 @@ public class FakeCreateAdminServiceImpl
private UserManager userManager;
@Inject
private DefaultUserConfiguration config;
private UserConfiguration config;
@Inject
private RoleManager roleManager;

View File

@ -22,7 +22,7 @@ package org.apache.archiva.redback.policy;
import javax.inject.Inject;
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.
@ -35,7 +35,7 @@ public abstract class AbstractCookieSettings
implements CookieSettings
{
@Inject @Named(value="userConfiguration")
protected DefaultUserConfiguration config;
protected UserConfiguration config;
/**
* Timeout (in minutes) for the sign on cookie.

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.policy;
* 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.policy.rules.MustHavePasswordRule;
import org.slf4j.Logger;
@ -65,7 +65,7 @@ public class DefaultUserSecurityPolicy
@Inject
@Named( value = "userConfiguration" )
private DefaultUserConfiguration config;
private UserConfiguration config;
@Inject
@Named( value = "passwordEncoder#sha256" )
@ -402,12 +402,12 @@ public class DefaultUserSecurityPolicy
return signonCookieSettings;
}
public DefaultUserConfiguration getConfig()
public UserConfiguration getConfig()
{
return config;
}
public void setConfig( DefaultUserConfiguration config )
public void setConfig( UserConfiguration config )
{
this.config = config;
}

View File

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

View File

@ -16,7 +16,7 @@ package org.apache.archiva.redback.policy.rules;
* 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 javax.inject.Inject;
@ -34,7 +34,7 @@ public abstract class AbstractPasswordRule
protected boolean enabled = true;
@Inject @Named (value="userConfiguration")
protected DefaultUserConfiguration config;
protected UserConfiguration config;
public boolean isEnabled()
{

View File

@ -16,7 +16,7 @@ package org.apache.archiva.redback.users.configurable;
* 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.User;
import org.apache.archiva.redback.users.UserManager;
@ -40,7 +40,7 @@ public class ConfigurableUserManager
{
@Inject
@Named( value = "userConfiguration" )
private DefaultUserConfiguration config;
private UserConfiguration config;
@Inject
private ApplicationContext applicationContext;