From ca75905c3eda60aa5a134ed7ccd6ed51f9257d6c Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Thu, 31 Jan 2008 20:32:31 +0000 Subject: [PATCH] SEC-658: Add support for ldap-user-service to AuthenticationProviderBeanDefinitionParser. --- ...AuthenticationProviderBeanDefinitionParser.java | 3 +++ .../security/config/spring-security-2.0.xsd | 1 + ...nticationProviderBeanDefinitionParserTests.java | 14 ++++++++++++++ 3 files changed, 18 insertions(+) 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 6c1c79c3a7..2faaf1c1a5 100644 --- a/core/src/main/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParser.java +++ b/core/src/main/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParser.java @@ -40,6 +40,7 @@ class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser String ref = element.getAttribute(ATT_USER_DETAILS_REF); Element userServiceElt = DomUtils.getChildElementByTagName(element, Elements.USER_SERVICE); Element jdbcUserServiceElt = DomUtils.getChildElementByTagName(element, Elements.JDBC_USER_SERVICE); + Element ldapUserServiceElt = DomUtils.getChildElementByTagName(element, Elements.LDAP_USER_SERVICE); if (StringUtils.hasText(ref)) { if (userServiceElt != null || jdbcUserServiceElt != null) { @@ -59,6 +60,8 @@ class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser userDetailsService = new UserServiceBeanDefinitionParser().parse(userServiceElt, parserContext); } else if (jdbcUserServiceElt != null) { userDetailsService = new JdbcUserServiceBeanDefinitionParser().parse(jdbcUserServiceElt, parserContext); + } else if (ldapUserServiceElt != null) { + userDetailsService = new LdapUserServiceBeanDefinitionParser().parse(ldapUserServiceElt, parserContext); } else { throw new SecurityConfigurationException(Elements.AUTHENTICATION_PROVIDER + " requires a UserDetailsService" ); 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 32a1598262..d43310a612 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 @@ -631,6 +631,7 @@ + diff --git a/core/src/test/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParserTests.java b/core/src/test/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParserTests.java index ea2e475abb..e13cd7735f 100644 --- a/core/src/test/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParserTests.java +++ b/core/src/test/java/org/springframework/security/config/AuthenticationProviderBeanDefinitionParserTests.java @@ -71,6 +71,20 @@ public class AuthenticationProviderBeanDefinitionParserTests { getProvider().authenticate(bob); } + @Test + public void worksWithJdbcUserService() throws Exception { + setContext(" " + + " " + + " " + + " " + + " " + + " "); + + getProvider().authenticate(bob); + } + + + @Test public void externalUserServiceAndPasswordEncoderWork() throws Exception { setContext(" " +