Spring Delegatingfilterproxy Parsing

Source: Internet
Author: User

Previously Delegatingfilterproxy was configured in XML when it was necessary to use spring security, as follows:

<Filter>  <Filter-name>Springsecurityfilterchain</Filter-name>  <Filter-class>Org.springframework.web.filter.DelegatingFilterProxy</Filter-class> </Filter><filter-mapping>  <Filter-name>Springsecurityfilterchain</Filter-name>  <Url-pattern>/*</Url-pattern></filter-mapping>

So I always thought that this class is the class in spring security, and later found that this is not the case, this class is located in the Spring-web package, and security does not matter.

This class is actually a proxy class for the filter's delegate.

This configuration means that a spring-managed bean has a name called Springsecurityfilterchain and registers it in.

This is used in the Abstractsecuritywebapplicationinitializer of security:

/*** Registers the Springsecurityfilterchain *@paramServletContext the {@linkServletContext}*/    Private voidInsertspringsecurityfilterchain (ServletContext servletcontext) {String filtername=Default_filter_name; Delegatingfilterproxy Springsecurityfilterchain=NewDelegatingfilterproxy (filtername); String ContextAttribute=Getwebapplicationcontextattribute (); if(ContextAttribute! =NULL) {Springsecurityfilterchain.setcontextattribute (ContextAttribute); } registerfilter (ServletContext,true, FilterName, Springsecurityfilterchain); }

This is to configure filter as a bean, and let spring to the manager life cycle.

and Delegatingfilterproxy itself is a filter,>> genericfilterbean >> Filter

One of the parameter names is Targetbeanname, which is the filter name that requires the proxy, if the name is empty, you will find the name:

<filter-name>springSecurityFilterChain</filter-name>
The Bean.
There is an attribute targetfilterlifecycle that indicates whether to invoke the Init method of the proxy filter.
Called if true, otherwise it is not called.

Spring Delegatingfilterproxy Parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.