SEC-658: Add support for ldap-user-service to AuthenticationProviderBeanDefinitionParser.
This commit is contained in:
parent
2c6fb3d1c9
commit
ca75905c3e
|
@ -40,6 +40,7 @@ class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser
|
||||||
String ref = element.getAttribute(ATT_USER_DETAILS_REF);
|
String ref = element.getAttribute(ATT_USER_DETAILS_REF);
|
||||||
Element userServiceElt = DomUtils.getChildElementByTagName(element, Elements.USER_SERVICE);
|
Element userServiceElt = DomUtils.getChildElementByTagName(element, Elements.USER_SERVICE);
|
||||||
Element jdbcUserServiceElt = DomUtils.getChildElementByTagName(element, Elements.JDBC_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 (StringUtils.hasText(ref)) {
|
||||||
if (userServiceElt != null || jdbcUserServiceElt != null) {
|
if (userServiceElt != null || jdbcUserServiceElt != null) {
|
||||||
|
@ -59,6 +60,8 @@ class AuthenticationProviderBeanDefinitionParser implements BeanDefinitionParser
|
||||||
userDetailsService = new UserServiceBeanDefinitionParser().parse(userServiceElt, parserContext);
|
userDetailsService = new UserServiceBeanDefinitionParser().parse(userServiceElt, parserContext);
|
||||||
} else if (jdbcUserServiceElt != null) {
|
} else if (jdbcUserServiceElt != null) {
|
||||||
userDetailsService = new JdbcUserServiceBeanDefinitionParser().parse(jdbcUserServiceElt, parserContext);
|
userDetailsService = new JdbcUserServiceBeanDefinitionParser().parse(jdbcUserServiceElt, parserContext);
|
||||||
|
} else if (ldapUserServiceElt != null) {
|
||||||
|
userDetailsService = new LdapUserServiceBeanDefinitionParser().parse(ldapUserServiceElt, parserContext);
|
||||||
} else {
|
} else {
|
||||||
throw new SecurityConfigurationException(Elements.AUTHENTICATION_PROVIDER
|
throw new SecurityConfigurationException(Elements.AUTHENTICATION_PROVIDER
|
||||||
+ " requires a UserDetailsService" );
|
+ " requires a UserDetailsService" );
|
||||||
|
|
|
@ -631,6 +631,7 @@
|
||||||
<xs:choice>
|
<xs:choice>
|
||||||
<xs:element ref="security:user-service"/>
|
<xs:element ref="security:user-service"/>
|
||||||
<xs:element ref="security:jdbc-user-service"/>
|
<xs:element ref="security:jdbc-user-service"/>
|
||||||
|
<xs:element ref="security:ldap-user-service"/>
|
||||||
</xs:choice>
|
</xs:choice>
|
||||||
<xs:element ref="security:password-encoder"/>
|
<xs:element ref="security:password-encoder"/>
|
||||||
</xs:choice>
|
</xs:choice>
|
||||||
|
|
|
@ -71,6 +71,20 @@ public class AuthenticationProviderBeanDefinitionParserTests {
|
||||||
getProvider().authenticate(bob);
|
getProvider().authenticate(bob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void worksWithJdbcUserService() throws Exception {
|
||||||
|
setContext(" <authentication-provider>" +
|
||||||
|
" <password-encoder hash='{sha}'/>" +
|
||||||
|
" <user-service>" +
|
||||||
|
" <user name='bob' password='{SSHA}PpuEwfdj7M1rs0C2W4ssSM2XEN/Y6S5U' authorities='ROLE_A' />" +
|
||||||
|
" </user-service>" +
|
||||||
|
" </authentication-provider>");
|
||||||
|
|
||||||
|
getProvider().authenticate(bob);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void externalUserServiceAndPasswordEncoderWork() throws Exception {
|
public void externalUserServiceAndPasswordEncoderWork() throws Exception {
|
||||||
setContext(" <authentication-provider user-service-ref='customUserService'>" +
|
setContext(" <authentication-provider user-service-ref='customUserService'>" +
|
||||||
|
|
Loading…
Reference in New Issue