Search in sources :

Example 1 with RequestCacheAwareFilter

use of org.springframework.security.web.savedrequest.RequestCacheAwareFilter in project spring-security by spring-projects.

the class RequestCacheConfigurer method configure.

@Override
public void configure(H http) throws Exception {
    RequestCache requestCache = getRequestCache(http);
    RequestCacheAwareFilter requestCacheFilter = new RequestCacheAwareFilter(requestCache);
    requestCacheFilter = postProcess(requestCacheFilter);
    http.addFilter(requestCacheFilter);
}
Also used : RequestCache(org.springframework.security.web.savedrequest.RequestCache) HttpSessionRequestCache(org.springframework.security.web.savedrequest.HttpSessionRequestCache) RequestCacheAwareFilter(org.springframework.security.web.savedrequest.RequestCacheAwareFilter)

Example 2 with RequestCacheAwareFilter

use of org.springframework.security.web.savedrequest.RequestCacheAwareFilter in project spring-security by spring-projects.

the class HttpConfigurationBuilder method createRequestCacheFilter.

private void createRequestCacheFilter() {
    Element requestCacheElt = DomUtils.getChildElementByTagName(httpElt, Elements.REQUEST_CACHE);
    if (requestCacheElt != null) {
        requestCache = new RuntimeBeanReference(requestCacheElt.getAttribute(ATT_REF));
    } else {
        BeanDefinitionBuilder requestCacheBldr;
        if (sessionPolicy == SessionCreationPolicy.STATELESS) {
            requestCacheBldr = BeanDefinitionBuilder.rootBeanDefinition(NullRequestCache.class);
        } else {
            requestCacheBldr = BeanDefinitionBuilder.rootBeanDefinition(HttpSessionRequestCache.class);
            requestCacheBldr.addPropertyValue("createSessionAllowed", sessionPolicy == SessionCreationPolicy.IF_REQUIRED);
            requestCacheBldr.addPropertyValue("portResolver", portResolver);
            if (csrfFilter != null) {
                BeanDefinitionBuilder requestCacheMatcherBldr = BeanDefinitionBuilder.rootBeanDefinition(AntPathRequestMatcher.class);
                requestCacheMatcherBldr.addConstructorArgValue("/**");
                requestCacheMatcherBldr.addConstructorArgValue("GET");
                requestCacheBldr.addPropertyValue("requestMatcher", requestCacheMatcherBldr.getBeanDefinition());
            }
        }
        BeanDefinition bean = requestCacheBldr.getBeanDefinition();
        String id = pc.getReaderContext().generateBeanName(bean);
        pc.registerBeanComponent(new BeanComponentDefinition(bean, id));
        this.requestCache = new RuntimeBeanReference(id);
    }
    requestCacheAwareFilter = new RootBeanDefinition(RequestCacheAwareFilter.class);
    requestCacheAwareFilter.getConstructorArgumentValues().addGenericArgumentValue(requestCache);
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) BeanMetadataElement(org.springframework.beans.BeanMetadataElement) Element(org.w3c.dom.Element) HttpSessionRequestCache(org.springframework.security.web.savedrequest.HttpSessionRequestCache) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) NullRequestCache(org.springframework.security.web.savedrequest.NullRequestCache) RequestCacheAwareFilter(org.springframework.security.web.savedrequest.RequestCacheAwareFilter)

Aggregations

HttpSessionRequestCache (org.springframework.security.web.savedrequest.HttpSessionRequestCache)2 RequestCacheAwareFilter (org.springframework.security.web.savedrequest.RequestCacheAwareFilter)2 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)1 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)1 NullRequestCache (org.springframework.security.web.savedrequest.NullRequestCache)1 RequestCache (org.springframework.security.web.savedrequest.RequestCache)1 Element (org.w3c.dom.Element)1