SEC-1830: Use constructor injection in namespace parsing code for creation of ProviderManager

This commit is contained in:
Luke Taylor 2011-09-26 18:24:36 +01:00
parent 9d66e1fac3
commit ac6ed671a1
4 changed files with 6 additions and 5 deletions

View File

@ -83,7 +83,7 @@ public class AuthenticationManagerBeanDefinitionParser implements BeanDefinition
providers.add(new RootBeanDefinition(NullAuthenticationProvider.class)); providers.add(new RootBeanDefinition(NullAuthenticationProvider.class));
} }
providerManagerBldr.addPropertyValue("providers", providers); providerManagerBldr.addConstructorArgValue(providers);
if ("false".equals(element.getAttribute(ATT_ERASE_CREDENTIALS))) { if ("false".equals(element.getAttribute(ATT_ERASE_CREDENTIALS))) {
providerManagerBldr.addPropertyValue("eraseCredentialsAfterAuthentication", false); providerManagerBldr.addPropertyValue("eraseCredentialsAfterAuthentication", false);

View File

@ -471,7 +471,7 @@ class HttpConfigurationBuilder {
voters.add(new RootBeanDefinition(AuthenticatedVoter.class)); voters.add(new RootBeanDefinition(AuthenticatedVoter.class));
} }
accessDecisionMgr = new RootBeanDefinition(AffirmativeBased.class); accessDecisionMgr = new RootBeanDefinition(AffirmativeBased.class);
accessDecisionMgr.getPropertyValues().addPropertyValue("decisionVoters", voters); accessDecisionMgr.getConstructorArgumentValues().addGenericArgumentValue(voters);
accessDecisionMgr.setSource(pc.extractSource(httpElt)); accessDecisionMgr.setSource(pc.extractSource(httpElt));
// Set up the access manager reference for http // Set up the access manager reference for http

View File

@ -187,8 +187,9 @@ public class HttpSecurityBeanDefinitionParser implements BeanDefinitionParser {
private BeanReference createAuthenticationManager(Element element, ParserContext pc, private BeanReference createAuthenticationManager(Element element, ParserContext pc,
ManagedList<BeanReference> authenticationProviders) { ManagedList<BeanReference> authenticationProviders) {
BeanDefinitionBuilder authManager = BeanDefinitionBuilder.rootBeanDefinition(ProviderManager.class); BeanDefinitionBuilder authManager = BeanDefinitionBuilder.rootBeanDefinition(ProviderManager.class);
authManager.addPropertyValue("parent", new RootBeanDefinition(AuthenticationManagerFactoryBean.class)); authManager.addConstructorArgValue(authenticationProviders);
authManager.addPropertyValue("providers", authenticationProviders); authManager.addConstructorArgValue(new RootBeanDefinition(AuthenticationManagerFactoryBean.class));
RootBeanDefinition clearCredentials = new RootBeanDefinition(MethodInvokingFactoryBean.class); RootBeanDefinition clearCredentials = new RootBeanDefinition(MethodInvokingFactoryBean.class);
clearCredentials.getPropertyValues().addPropertyValue("targetObject", new RootBeanDefinition(AuthenticationManagerFactoryBean.class)); clearCredentials.getPropertyValues().addPropertyValue("targetObject", new RootBeanDefinition(AuthenticationManagerFactoryBean.class));
clearCredentials.getPropertyValues().addPropertyValue("targetMethod", "isEraseCredentialsAfterAuthentication"); clearCredentials.getPropertyValues().addPropertyValue("targetMethod", "isEraseCredentialsAfterAuthentication");

View File

@ -247,7 +247,7 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
voters.add(new RootBeanDefinition(Jsr250Voter.class)); voters.add(new RootBeanDefinition(Jsr250Voter.class));
} }
accessMgrBuilder.addPropertyValue("decisionVoters", voters); accessMgrBuilder.addConstructorArgValue(voters);
BeanDefinition accessManager = accessMgrBuilder.getBeanDefinition(); BeanDefinition accessManager = accessMgrBuilder.getBeanDefinition();
String id = pc.getReaderContext().generateBeanName(accessManager); String id = pc.getReaderContext().generateBeanName(accessManager);