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