spring security的springSecurityFilterChain怎么初始化的
2012-10-25 23:00
423 查看
了解springSecurityFilterChain怎么初始化之前有必要先了解下 spring 的namespacehandler
http://static.springsource.org/spring/docs/2.0.x/reference/extensible-xml.html
代码实现:
那么springSecurityFilterChain这个bean在哪里定义的呢
spring 的namespacehander在解析http://www.springframework.org/schema/security
命名空间的http元素时创建此bean的
参考:
http://static.springsource.org/spring/docs/2.0.x/reference/extensible-xml.html
<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>
代码实现:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException { // Lazily initialize the delegate if necessary. Filter delegateToUse = null; synchronized (this.delegateMonitor) { if (this.delegate == null) { WebApplicationContext wac = findWebApplicationContext(); if (wac == null) { throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); } this.delegate = initDelegate(wac); } delegateToUse = this.delegate; } // Let the delegate perform the actual doFilter operation. invokeDelegate(delegateToUse, request, response, filterChain); }
protected Filter initDelegate(WebApplicationContext wac) throws ServletException { Filter delegate = wac.getBean(getTargetBeanName(), Filter.class); if (isTargetFilterLifecycle()) { delegate.init(getFilterConfig()); } return delegate; }
//此方法在父类GenericFilterBean的init方法中调用的 @Override protected void initFilterBean() throws ServletException { synchronized (this.delegateMonitor) { if (this.delegate == null) { // If no target bean name specified, use filter name. if (this.targetBeanName == null) { //如果我们没有指定targetBeanName 将默认取filter的名字 即springSecurityFilterChain this.targetBeanName = getFilterName(); } // Fetch Spring root application context and initialize the delegate early, // if possible. If the root application context will be started after this // filter proxy, we'll have to resort to lazy initialization. WebApplicationContext wac = findWebApplicationContext(); if (wac != null) { this.delegate = initDelegate(wac); } } } }
那么springSecurityFilterChain这个bean在哪里定义的呢
spring 的namespacehander在解析http://www.springframework.org/schema/security
命名空间的http元素时创建此bean的
参考:
Spring Security3源码分析-http标签解析
相关文章推荐
- spring security源码分析之一springSecurityFilterChain
- spring security设置(springSecurityFilterChain与DelegatingFilterProxy)
- springSecurityFilterChain别名的由来
- No bean named 'springSecurityFilterChain' is defined
- No bean named 'springSecurityFilterChain' is defined 解决
- spring security filter chain
- Spring Security3源码分析-FilterChainProxy初始化
- No bean named 'springSecurityFilterChain' is defined
- No bean named 'springSecurityFilterChain' is defined
- 列出spring security的所有SecurityFilterChain
- No bean named 'springSecurityFilterChain' is defined 解决方法
- Spring Security Filter Chain Registration Using WebApplicationInitializer for Servlet 3.x
- No bean named 'springSecurityFilterChain' is defined 问题解决
- Spring Security4.0.3源码分析之FilterChainProxy初始化
- No bean named 'springSecurityFilterChain' is defined
- springboot tomcat8 duplicate springSecurityFilterChain and increasing the maximum size of the cache
- Spring Security Web Application 之 Security Filter Chain
- 严重 Exception starting filter springSecurityFilterChain org.springframework.beans.factory.NoSuchBeanD
- Spring Security3源码分析-FilterChainProxy初始化
- No bean named 'springSecurityFilterChain' is defined