diff --git a/core/src/main/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParser.java b/core/src/main/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParser.java index 641f9435b8..899c15ba1c 100644 --- a/core/src/main/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParser.java +++ b/core/src/main/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParser.java @@ -1,11 +1,8 @@ package org.springframework.security.config; import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.security.providers.dao.DaoAuthenticationProvider; -import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; /** @@ -15,23 +12,7 @@ import org.w3c.dom.Element; class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser { public BeanDefinition parse(Element element, ParserContext parserContext) { - ConfigUtils.registerProviderManagerIfNecessary(parserContext); - - RootBeanDefinition authProvider; - // TODO: Proper implementation - Element userServiceElt = DomUtils.getChildElementByTagName(element, "user-service"); - - if (userServiceElt != null) { - authProvider = new RootBeanDefinition(DaoAuthenticationProvider.class); - BeanDefinition userDetailsService = new UserServiceBeanDefinitionParser().parse(userServiceElt, parserContext); - authProvider.getPropertyValues().addPropertyValue("userDetailsService", userDetailsService); - } else { - throw new IllegalArgumentException("Only support user-service provider at the moment."); - } - - ConfigUtils.getRegisteredProviders(parserContext).add(authProvider); - return null; } } diff --git a/core/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/core/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 7f477fcf90..1c122843fd 100644 --- a/core/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/core/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -14,7 +14,8 @@ public class SecurityNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionParser("ldap", new LdapBeanDefinitionParser()); registerBeanDefinitionParser("http", new HttpSecurityBeanDefinitionParser()); registerBeanDefinitionParser("user-service", new UserServiceBeanDefinitionParser()); - registerBeanDefinitionParser("authentication-provider", new AuthenticationProviderBeanDefinitionParser()); + registerBeanDefinitionParser("repository", new RepositoryBeanDefinitionParser()); + //registerBeanDefinitionParser("authentication-provider", new AuthenticationProviderBeanDefinitionParser()); registerBeanDefinitionDecorator("intercept-methods", new InterceptMethodsBeanDefinitionDecorator()); registerBeanDefinitionDecorator("filter-chain-map", new FilterChainMapBeanDefinitionDecorator()); } diff --git a/core/src/main/resources/org/springframework/security/config/spring-security-2.0.rnc b/core/src/main/resources/org/springframework/security/config/spring-security-2.0.rnc index 94ef1c949d..5ad85e4e4c 100644 --- a/core/src/main/resources/org/springframework/security/config/spring-security-2.0.rnc +++ b/core/src/main/resources/org/springframework/security/config/spring-security-2.0.rnc @@ -6,7 +6,7 @@ datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" default namespace = "http://www.springframework.org/schema/security" -start = http | ldap +start = http | ldap | repository # targetNamespace="http://www.springframework.org/schema/security" @@ -156,12 +156,14 @@ anonymous.attlist &= ## The granted authority that should be assigned to the anonymous request. Commonly this is used to assign the anonymous request particular roles, which can subsequently be used in authorization decisions. [ a:defaultValue = "ROLE_ANONYMOUS" ] attribute grantedAuthority {xsd:string}? -authentication-provider = - element authentication-provider {authentication-provider.attlist, (user-service | jdbc-user-service)} -authentication-provider.attlist &= empty +repository = + element repository {repository.attlist, (user-service | jdbc-user-service | custom-user-service)} +repository.attlist &= + ## Indicates the repository should have an authentication provider created. If unspecified, defaults to true. + attribute createProvider {"true" | "false"}? user-service = - element user-service {user-service.attlist, (user* | jdbc-user-service)} + element user-service {user-service.attlist, (user*)} user-service.attlist &= attribute properties {xsd:string}* @@ -175,6 +177,15 @@ user.attlist &= attribute authorities {xsd:string} jdbc-user-service = - element jdbc-user-service {jdbc-users.attlist, empty} -jdbc-users.attlist &= empty + ## Causes creation of a JDBC-based UserDetailsService. + element jdbc-user-service {jdbc-user-service.attlist} +jdbc-user-service.attlist &= + ## The bean ID of the DataSource which provides the required tables. + attribute dataSource {xsd:string} + +custom-user-service = + element custom-user-service {custom-user-service.attlist} +custom-user-service.attlist &= + ## The bean ID of your custom UserDetailsService implementation. + attribute id {xsd:string} diff --git a/core/src/main/resources/org/springframework/security/config/spring-security-2.0.xsd b/core/src/main/resources/org/springframework/security/config/spring-security-2.0.xsd index 67120b5d56..3ee288a637 100644 --- a/core/src/main/resources/org/springframework/security/config/spring-security-2.0.xsd +++ b/core/src/main/resources/org/springframework/security/config/spring-security-2.0.xsd @@ -317,20 +317,34 @@ - + + + + + + + Indicates the repository should have an authentication provider created. If unspecified, defaults to true. + + + + + + + + + - + - - + @@ -348,6 +362,30 @@ - + + Causes creation of a JDBC-based UserDetailsService. + + + + + + + + The bean ID of the DataSource which provides the required tables. + + + + + + + + + + + + The bean ID of your custom UserDetailsService implementation. + + + diff --git a/core/src/test/resources/org/springframework/security/config/http-security.xml b/core/src/test/resources/org/springframework/security/config/http-security.xml index e75a215d60..f7fa78a0c4 100644 --- a/core/src/test/resources/org/springframework/security/config/http-security.xml +++ b/core/src/test/resources/org/springframework/security/config/http-security.xml @@ -25,12 +25,12 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc - + - + diff --git a/core/src/test/resources/org/springframework/security/config/method-security.xml b/core/src/test/resources/org/springframework/security/config/method-security.xml index d34240fce4..38db19b452 100644 --- a/core/src/test/resources/org/springframework/security/config/method-security.xml +++ b/core/src/test/resources/org/springframework/security/config/method-security.xml @@ -16,11 +16,11 @@ http://www.springframework.org/schema/security http://www.springframework.org/sc - + - + \ No newline at end of file diff --git a/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security-ns.xml b/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security-ns.xml index fd52c7a797..0a26951570 100644 --- a/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security-ns.xml +++ b/samples/tutorial/src/main/webapp/WEB-INF/applicationContext-security-ns.xml @@ -23,16 +23,18 @@ - + - + + + + + + + + + \ No newline at end of file