From 9794c518d649d69f03ae6954d85512438826eecf Mon Sep 17 00:00:00 2001 From: Vishal Puri Date: Fri, 11 May 2007 00:09:56 +0000 Subject: [PATCH] SEC-271: Spring 2-based configuration simplification of Acegi Security --- .../adapters/AuthByAdapterProvider.java | 14 ++++++-- ...icationRepositoryBeanDefinitionParser.java | 4 +-- ...ontextIntegrationBeanDefinitionParser.java | 4 +-- .../RememberMeFilterBeanDefinitionParser.java | 12 +++---- .../config/SecurityNamespaceHandler.java | 1 + .../AnonymousAuthenticationProvider.java | 19 +++++++---- .../cas/CasAuthenticationProvider.java | 14 ++++++-- .../dao/DaoAuthenticationProvider.java | 16 ++++++++-- .../jaas/JaasAuthenticationProvider.java | 14 ++++++-- .../ldap/LdapAuthenticationProvider.java | 14 ++++++-- .../rcp/RemoteAuthenticationProvider.java | 14 ++++++-- .../RememberMeAuthenticationProvider.java | 14 ++++++-- .../SiteminderAuthenticationProvider.java | 14 +++++++- .../x509/X509AuthenticationProvider.java | 14 ++++++-- .../RunAsImplAuthenticationProvider.java | 14 ++++++-- .../config/spring-security-2.0.xsd | 32 +++++++++++++++++++ .../RememberMeBeanDefinitionParserTest.java | 1 + .../config/remember-me-defaults.xml | 22 ++++++++----- .../config/security-namespaces.xml | 4 +-- 19 files changed, 195 insertions(+), 46 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/adapters/AuthByAdapterProvider.java b/core/src/main/java/org/acegisecurity/adapters/AuthByAdapterProvider.java index bfb8b73388..d2708f7bd7 100644 --- a/core/src/main/java/org/acegisecurity/adapters/AuthByAdapterProvider.java +++ b/core/src/main/java/org/acegisecurity/adapters/AuthByAdapterProvider.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -38,15 +39,24 @@ import org.springframework.util.Assert; * AuthByAdapterProvider-configured key.

*

If the key does not match, a BadCredentialsException is thrown.

*/ -public class AuthByAdapterProvider implements InitializingBean, AuthenticationProvider, MessageSourceAware { +public class AuthByAdapterProvider implements InitializingBean, AuthenticationProvider, MessageSourceAware, Ordered { //~ Instance fields ================================================================================================ protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); private String key; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.notNull(key, "A Key is required and should match that configured for the adapters"); Assert.notNull(messages, "A message source must be set"); } diff --git a/core/src/main/java/org/acegisecurity/config/AuthenticationRepositoryBeanDefinitionParser.java b/core/src/main/java/org/acegisecurity/config/AuthenticationRepositoryBeanDefinitionParser.java index db925acce3..0993114955 100644 --- a/core/src/main/java/org/acegisecurity/config/AuthenticationRepositoryBeanDefinitionParser.java +++ b/core/src/main/java/org/acegisecurity/config/AuthenticationRepositoryBeanDefinitionParser.java @@ -25,7 +25,7 @@ import org.w3c.dom.NodeList; */ public class AuthenticationRepositoryBeanDefinitionParser extends AbstractBeanDefinitionParser { - // ~~ Instance Variables +// ~ Instance fields ================================================================================================ private static final String REPOSITORY_BEAN_REF = "repositoryBeanRef"; @@ -49,7 +49,7 @@ public class AuthenticationRepositoryBeanDefinitionParser extends AbstractBeanDe - // ~~ Methods +// ~ Method ================================================================================================ /** * TODO: Document Me !!! */ diff --git a/core/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java b/core/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java index 03b424e0ef..a58b5b5956 100644 --- a/core/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java +++ b/core/src/main/java/org/acegisecurity/config/ContextIntegrationBeanDefinitionParser.java @@ -34,13 +34,13 @@ public class ContextIntegrationBeanDefinitionParser extends AbstractSingleBeanDe private static final String NEVER = "never"; - @Override + protected Class getBeanClass(Element element) { return HttpSessionContextIntegrationFilter.class; } - @Override + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); diff --git a/core/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java b/core/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java index 518af7c2d4..0d56d8aa2e 100644 --- a/core/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java +++ b/core/src/main/java/org/acegisecurity/config/RememberMeFilterBeanDefinitionParser.java @@ -8,7 +8,6 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; -import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -19,16 +18,13 @@ import org.w3c.dom.Element; * *@since */ -public class RememberMeFilterBeanDefinitionParser extends AbstractBeanDefinitionParser implements - BeanDefinitionParser { +public class RememberMeFilterBeanDefinitionParser extends AbstractBeanDefinitionParser { private static final String REMEMBER_ME_SERVICES_REF = "rememberMeServicesBeanRef"; private static final String REMEMBER_ME_SERVICES = "rememberMeServices"; - /** - * - */ + protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { Assert.notNull(parserContext, "ParserContext must not be null"); @@ -45,5 +41,9 @@ public class RememberMeFilterBeanDefinitionParser extends AbstractBeanDefinition } return rememberMeFilterBeanDef; } + + + + } diff --git a/core/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java b/core/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java index 9d18e7018f..7a528ac79e 100644 --- a/core/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java +++ b/core/src/main/java/org/acegisecurity/config/SecurityNamespaceHandler.java @@ -21,6 +21,7 @@ public class SecurityNamespaceHandler extends NamespaceHandlerSupport { public void init() { registerBeanDefinitionParser("session-context-integration", new ContextIntegrationBeanDefinitionParser()); registerBeanDefinitionParser("authentication-repository", new AuthenticationRepositoryBeanDefinitionParser()); + registerBeanDefinitionParser("authentication-mechanism", new AuthenticationMechanismBeanDefinitionParser()); registerBeanDefinitionParser("authentication-remember-me-services", new RememberMeServicesBeanDefinitionParser()); registerBeanDefinitionParser("authentication-remember-me-filter", new RememberMeFilterBeanDefinitionParser()); } diff --git a/core/src/main/java/org/acegisecurity/providers/anonymous/AnonymousAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/anonymous/AnonymousAuthenticationProvider.java index 80ce3e5ec2..22b4a9123b 100644 --- a/core/src/main/java/org/acegisecurity/providers/anonymous/AnonymousAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/anonymous/AnonymousAuthenticationProvider.java @@ -19,18 +19,14 @@ import org.acegisecurity.AcegiMessageSource; import org.acegisecurity.Authentication; import org.acegisecurity.AuthenticationException; import org.acegisecurity.BadCredentialsException; - import org.acegisecurity.providers.AuthenticationProvider; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.beans.factory.InitializingBean; - import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.context.support.MessageSourceAccessor; - +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -40,7 +36,7 @@ import org.springframework.util.Assert; * {@link org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken#getKeyHash()} must match this class' * {@link #getKey()}.

*/ -public class AnonymousAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { +public class AnonymousAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware, Ordered { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(AnonymousAuthenticationProvider.class); @@ -49,10 +45,19 @@ public class AnonymousAuthenticationProvider implements AuthenticationProvider, protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); private String key; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.hasLength(key, "A Key is required"); Assert.notNull(this.messages, "A message source must be set"); } diff --git a/core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationProvider.java index 7bbdb1085a..5b5205aff5 100644 --- a/core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/cas/CasAuthenticationProvider.java @@ -35,6 +35,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -49,7 +50,7 @@ import org.springframework.util.Assert; * @author Ben Alex * @version $Id$ */ -public class CasAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { +public class CasAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware, Ordered { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(CasAuthenticationProvider.class); @@ -62,10 +63,19 @@ public class CasAuthenticationProvider implements AuthenticationProvider, Initia private StatelessTicketCache statelessTicketCache; private String key; private TicketValidator ticketValidator; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.notNull(this.casAuthoritiesPopulator, "A casAuthoritiesPopulator must be set"); Assert.notNull(this.ticketValidator, "A ticketValidator must be set"); Assert.notNull(this.casProxyDecider, "A casProxyDecider must be set"); diff --git a/core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationProvider.java index 3da097ad44..7ea66ad300 100644 --- a/core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationProvider.java @@ -27,6 +27,7 @@ import org.acegisecurity.providers.encoding.PlaintextPasswordEncoder; import org.acegisecurity.userdetails.UserDetails; import org.acegisecurity.userdetails.UserDetailsService; +import org.springframework.core.Ordered; import org.springframework.dao.DataAccessException; import org.springframework.util.Assert; @@ -38,13 +39,15 @@ import org.springframework.util.Assert; * @author Ben Alex * @version $Id$ */ -public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { +public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider implements Ordered { + //~ Instance fields ================================================================================================ private PasswordEncoder passwordEncoder = new PlaintextPasswordEncoder(); private SaltSource saltSource; private UserDetailsService userDetailsService; private boolean includeDetailsObject = true; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== @@ -95,7 +98,6 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication throw new AuthenticationServiceException( "UserDetailsService returned null, which is an interface contract violation"); } - return loadedUser; } @@ -131,4 +133,14 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication public void setIncludeDetailsObject(boolean includeDetailsObject) { this.includeDetailsObject = includeDetailsObject; } + + public void setOrder(int order) { + this.order = order; + } + + public int getOrder() { + return order ; + } + + } diff --git a/core/src/main/java/org/acegisecurity/providers/jaas/JaasAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/jaas/JaasAuthenticationProvider.java index e51733dd19..747a39579f 100644 --- a/core/src/main/java/org/acegisecurity/providers/jaas/JaasAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/jaas/JaasAuthenticationProvider.java @@ -41,6 +41,7 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; +import org.springframework.core.Ordered; import org.springframework.core.io.Resource; import org.springframework.util.Assert; @@ -141,7 +142,7 @@ import javax.security.auth.login.LoginException; * @version $Id$ */ public class JaasAuthenticationProvider implements AuthenticationProvider, InitializingBean, ApplicationContextAware, - ApplicationListener { + ApplicationListener, Ordered { //~ Static fields/initializers ===================================================================================== protected static final Log log = LogFactory.getLog(JaasAuthenticationProvider.class); @@ -154,10 +155,19 @@ public class JaasAuthenticationProvider implements AuthenticationProvider, Initi private String loginContextName = "ACEGI"; private AuthorityGranter[] authorityGranters; private JaasAuthenticationCallbackHandler[] callbackHandlers; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.notNull(loginConfig, "loginConfig must be set on " + getClass()); Assert.hasLength(loginContextName, "loginContextName must be set on " + getClass()); diff --git a/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java index 8b59458ffb..2347b08f99 100644 --- a/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/ldap/LdapAuthenticationProvider.java @@ -32,6 +32,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import org.springframework.core.Ordered; import org.springframework.dao.DataAccessException; @@ -113,7 +114,7 @@ import org.springframework.dao.DataAccessException; * @see org.acegisecurity.providers.ldap.authenticator.BindAuthenticator * @see org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator */ -public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { +public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider implements Ordered { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(LdapAuthenticationProvider.class); @@ -123,10 +124,19 @@ public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticatio private LdapAuthenticator authenticator; private LdapAuthoritiesPopulator authoritiesPopulator; private boolean includeDetailsObject = true; + private int order = -1; // default: same as non-Ordered //~ Constructors =================================================================================================== - /** + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + /** * Create an initialized instance to the values passed as arguments * * @param authenticator the authentication strategy (bind, password comparison, etc) diff --git a/core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationProvider.java index 42c718663a..96f549e667 100644 --- a/core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/rcp/RemoteAuthenticationProvider.java @@ -23,6 +23,7 @@ import org.acegisecurity.providers.AuthenticationProvider; import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -43,14 +44,23 @@ import org.springframework.util.Assert; * @author Ben Alex * @version $Id$ */ -public class RemoteAuthenticationProvider implements AuthenticationProvider, InitializingBean { +public class RemoteAuthenticationProvider implements AuthenticationProvider, InitializingBean, Ordered { //~ Instance fields ================================================================================================ private RemoteAuthenticationManager remoteAuthenticationManager; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.notNull(this.remoteAuthenticationManager, "remoteAuthenticationManager is mandatory"); } diff --git a/core/src/main/java/org/acegisecurity/providers/rememberme/RememberMeAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/rememberme/RememberMeAuthenticationProvider.java index b07a8d196f..a978bb5d52 100644 --- a/core/src/main/java/org/acegisecurity/providers/rememberme/RememberMeAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/rememberme/RememberMeAuthenticationProvider.java @@ -30,6 +30,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -40,7 +41,7 @@ import org.springframework.util.Assert; * {@link org.acegisecurity.providers.rememberme.RememberMeAuthenticationToken#getKeyHash()} must match this class' * {@link #getKey()}.

*/ -public class RememberMeAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { +public class RememberMeAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware, Ordered { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(RememberMeAuthenticationProvider.class); @@ -49,10 +50,19 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider, protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); private String key; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.hasLength(key); Assert.notNull(this.messages, "A message source must be set"); } diff --git a/core/src/main/java/org/acegisecurity/providers/siteminder/SiteminderAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/siteminder/SiteminderAuthenticationProvider.java index c4f7042975..bdd09f4071 100644 --- a/core/src/main/java/org/acegisecurity/providers/siteminder/SiteminderAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/siteminder/SiteminderAuthenticationProvider.java @@ -28,6 +28,7 @@ import org.acegisecurity.userdetails.UserDetails; import org.acegisecurity.userdetails.UserDetailsService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.Ordered; import org.springframework.dao.DataAccessException; import org.springframework.util.Assert; @@ -37,7 +38,8 @@ import org.springframework.util.Assert; * @author Scott McCrory * @version $Id: SiteminderAuthenticationProvider.java 1582 2006-07-15 15:18:51Z smccrory $ */ -public class SiteminderAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { +public class SiteminderAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider implements Ordered { + /** * Our logging object @@ -50,6 +52,8 @@ public class SiteminderAuthenticationProvider extends AbstractUserDetailsAuthent * Our user details service (which does the real work of checking the user against a back-end user store). */ private UserDetailsService userDetailsService; + + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== @@ -129,4 +133,12 @@ public class SiteminderAuthenticationProvider extends AbstractUserDetailsAuthent this.userDetailsService = userDetailsService; } + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + } diff --git a/core/src/main/java/org/acegisecurity/providers/x509/X509AuthenticationProvider.java b/core/src/main/java/org/acegisecurity/providers/x509/X509AuthenticationProvider.java index 654ba16204..49eb021574 100644 --- a/core/src/main/java/org/acegisecurity/providers/x509/X509AuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/providers/x509/X509AuthenticationProvider.java @@ -33,6 +33,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -46,7 +47,7 @@ import java.security.cert.X509Certificate; * @author Luke Taylor * @version $Id$ */ -public class X509AuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware { +public class X509AuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware, Ordered { //~ Static fields/initializers ===================================================================================== private static final Log logger = LogFactory.getLog(X509AuthenticationProvider.class); @@ -56,10 +57,19 @@ public class X509AuthenticationProvider implements AuthenticationProvider, Initi protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); private X509AuthoritiesPopulator x509AuthoritiesPopulator; private X509UserCache userCache = new NullX509UserCache(); + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.notNull(userCache, "An x509UserCache must be set"); Assert.notNull(x509AuthoritiesPopulator, "An X509AuthoritiesPopulator must be set"); Assert.notNull(this.messages, "A message source must be set"); diff --git a/core/src/main/java/org/acegisecurity/runas/RunAsImplAuthenticationProvider.java b/core/src/main/java/org/acegisecurity/runas/RunAsImplAuthenticationProvider.java index c68997124c..2bb65eb7b6 100644 --- a/core/src/main/java/org/acegisecurity/runas/RunAsImplAuthenticationProvider.java +++ b/core/src/main/java/org/acegisecurity/runas/RunAsImplAuthenticationProvider.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceAware; import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.core.Ordered; import org.springframework.util.Assert; @@ -38,15 +39,24 @@ import org.springframework.util.Assert; * RunAsImplAuthenticationProvider-configured key.

*

If the key does not match, a BadCredentialsException is thrown.

*/ -public class RunAsImplAuthenticationProvider implements InitializingBean, AuthenticationProvider, MessageSourceAware { +public class RunAsImplAuthenticationProvider implements InitializingBean, AuthenticationProvider, MessageSourceAware, Ordered { //~ Instance fields ================================================================================================ protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor(); private String key; + private int order = -1; // default: same as non-Ordered //~ Methods ======================================================================================================== - public void afterPropertiesSet() throws Exception { + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } + + public void afterPropertiesSet() throws Exception { Assert.notNull(key, "A Key is required and should match that configured for the RunAsManagerImpl"); } diff --git a/core/src/main/resources/org/acegisecurity/config/spring-security-2.0.xsd b/core/src/main/resources/org/acegisecurity/config/spring-security-2.0.xsd index 51dbdc5599..b5d0d6f27e 100644 --- a/core/src/main/resources/org/acegisecurity/config/spring-security-2.0.xsd +++ b/core/src/main/resources/org/acegisecurity/config/spring-security-2.0.xsd @@ -123,6 +123,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/test/java/org/acegisecurity/config/RememberMeBeanDefinitionParserTest.java b/core/src/test/java/org/acegisecurity/config/RememberMeBeanDefinitionParserTest.java index 2c32686c41..e0ab90af94 100644 --- a/core/src/test/java/org/acegisecurity/config/RememberMeBeanDefinitionParserTest.java +++ b/core/src/test/java/org/acegisecurity/config/RememberMeBeanDefinitionParserTest.java @@ -10,6 +10,7 @@ public class RememberMeBeanDefinitionParserTest extends TestCase { public void testRememberMeDefaults() { ApplicationContext context = new ClassPathXmlApplicationContext("org/acegisecurity/config/remember-me-defaults.xml"); + } } diff --git a/core/src/test/resources/org/acegisecurity/config/remember-me-defaults.xml b/core/src/test/resources/org/acegisecurity/config/remember-me-defaults.xml index 8bd753b1d9..7355a57abd 100644 --- a/core/src/test/resources/org/acegisecurity/config/remember-me-defaults.xml +++ b/core/src/test/resources/org/acegisecurity/config/remember-me-defaults.xml @@ -14,8 +14,7 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc - + @@ -29,17 +28,24 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc If ProviderManager.setProvider(List) is never called, auto-detect all AuthenticationProviders from app ctx, using Ordered to resolve their order Every authentication mechanism OR provider must start with security:authentication-something Use appropriate attrs and elements depending on provider or mechanism - --> - + + + + + + + -