12 changed files with 2249 additions and 641 deletions
@ -0,0 +1,39 @@ |
|||||||
|
package org.springframework.security.config.http; |
||||||
|
|
||||||
|
import org.springframework.beans.BeanMetadataElement; |
||||||
|
import org.springframework.beans.factory.config.BeanDefinition; |
||||||
|
import org.springframework.beans.factory.config.RuntimeBeanReference; |
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
||||||
|
import org.springframework.beans.factory.support.ManagedMap; |
||||||
|
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.config.BeanIds; |
||||||
|
import org.springframework.util.StringUtils; |
||||||
|
import org.w3c.dom.Element; |
||||||
|
|
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Injects the supplied {@code HttpFirewall} bean reference into the {@code FilterChainProxy}. |
||||||
|
* |
||||||
|
* @author Luke Taylor |
||||||
|
*/ |
||||||
|
public class HttpFirewallBeanDefinitionParser implements BeanDefinitionParser { |
||||||
|
|
||||||
|
@Override |
||||||
|
public BeanDefinition parse(Element element, ParserContext pc) { |
||||||
|
String ref = element.getAttribute("ref"); |
||||||
|
|
||||||
|
if (!StringUtils.hasText(ref)) { |
||||||
|
pc.getReaderContext().error("ref attribute is required", pc.extractSource(element)); |
||||||
|
} |
||||||
|
|
||||||
|
BeanDefinitionBuilder injector = BeanDefinitionBuilder.rootBeanDefinition(HttpFirewallInjectionBeanPostProcessor.class); |
||||||
|
injector.addConstructorArgValue(ref); |
||||||
|
|
||||||
|
pc.getReaderContext().registerWithGeneratedName(injector.getBeanDefinition()); |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
package org.springframework.security.config.http; |
||||||
|
|
||||||
|
import org.springframework.beans.BeansException; |
||||||
|
import org.springframework.beans.factory.BeanFactory; |
||||||
|
import org.springframework.beans.factory.BeanFactoryAware; |
||||||
|
import org.springframework.beans.factory.config.BeanPostProcessor; |
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
||||||
|
import org.springframework.security.config.BeanIds; |
||||||
|
import org.springframework.security.web.FilterChainProxy; |
||||||
|
import org.springframework.security.web.firewall.HttpFirewall; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Luke Taylor |
||||||
|
*/ |
||||||
|
public class HttpFirewallInjectionBeanPostProcessor implements BeanPostProcessor, BeanFactoryAware { |
||||||
|
private ConfigurableListableBeanFactory beanFactory; |
||||||
|
private String ref; |
||||||
|
|
||||||
|
public HttpFirewallInjectionBeanPostProcessor(String ref) { |
||||||
|
this.ref = ref; |
||||||
|
} |
||||||
|
|
||||||
|
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { |
||||||
|
if (BeanIds.FILTER_CHAIN_PROXY.equals(beanName)) { |
||||||
|
HttpFirewall fw = (HttpFirewall) beanFactory.getBean(ref); |
||||||
|
((FilterChainProxy)bean).setFirewall(fw); |
||||||
|
} |
||||||
|
|
||||||
|
return bean; |
||||||
|
} |
||||||
|
|
||||||
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { |
||||||
|
return bean; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { |
||||||
|
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue