diff --git a/core/src/main/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecorator.java b/core/src/main/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecorator.java index dc5a5e72dc..a95dc47272 100644 --- a/core/src/main/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecorator.java +++ b/core/src/main/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecorator.java @@ -3,6 +3,7 @@ package org.springframework.security.config; import org.springframework.beans.factory.xml.BeanDefinitionDecorator; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.config.BeanDefinitionHolder; +import org.springframework.beans.factory.config.RuntimeBeanReference; import org.w3c.dom.Node; @@ -16,7 +17,7 @@ import org.w3c.dom.Node; */ public class CustomAuthenticationProviderBeanDefinitionDecorator implements BeanDefinitionDecorator { public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder holder, ParserContext parserContext) { - ConfigUtils.getRegisteredProviders(parserContext).add(holder.getBeanDefinition()); + ConfigUtils.getRegisteredProviders(parserContext).add(new RuntimeBeanReference(holder.getBeanName())); return holder; } diff --git a/core/src/test/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecoratorTests.java b/core/src/test/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecoratorTests.java index 93e4b40930..77175ce5d1 100644 --- a/core/src/test/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecoratorTests.java +++ b/core/src/test/java/org/springframework/security/config/CustomAuthenticationProviderBeanDefinitionDecoratorTests.java @@ -1,21 +1,32 @@ package org.springframework.security.config; +import static org.junit.Assert.*; + import org.junit.Test; +import org.springframework.security.providers.ProviderManager; import org.springframework.security.util.InMemoryXmlApplicationContext; public class CustomAuthenticationProviderBeanDefinitionDecoratorTests { @Test - public void decoratorParsesSuccessfully() { + public void decoratedProviderParsesSuccessfully() { InMemoryXmlApplicationContext ctx = new InMemoryXmlApplicationContext( - "" + - " " + - " " + - " " + - "" + HttpSecurityBeanDefinitionParserTests.AUTH_PROVIDER_XML + "" + + " " + + " " + + "" + + "" + + " " + + " " + + "" + ); - ctx.getBean("someBean"); + Object myProvider = ctx.getBean("myProvider"); + + ProviderManager authMgr = (ProviderManager) ctx.getBean(BeanIds.AUTHENTICATION_MANAGER); + + assertSame(myProvider, authMgr.getProviders().get(0)); } }