在web.xml文件中配置

问题:为什么DelegatingFilterProxy的filter-name必须是springSecurityFilterChain?

DelegatingFilterProxy并不是真正的Filter,在其initFilterBean方法中会从WebApplicationContext根据delegate来获取到

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) {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);}}}
}

在上这代码中this.targetBeanName=getFilterName()就是获取名称叫做springSecurityFilterChain

通过在doFilter就去中我们会发现真正干活的其实是delegate这个Filter,而delegate其实就是FilterChainProxy

public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)throws ServletException, IOException {// Lazily initialize the delegate if necessary.Filter delegateToUse = this.delegate;if (delegateToUse == null) {synchronized (this.delegateMonitor) {delegateToUse = this.delegate;if (delegateToUse == null) {WebApplicationContext wac = findWebApplicationContext();if (wac == null) {throw new IllegalStateException("No WebApplicationContext found: " +"no ContextLoaderListener or DispatcherServlet registered?");}delegateToUse = initDelegate(wac);}this.delegate = delegateToUse;}}// Let the delegate perform the actual doFilter operation.invokeDelegate(delegateToUse, request, response, filterChain);}

FilterChainProxy是spring在解析配置文件时装配到上下文中,并且beanName为springSecurityFilterChain,

因此在web.xml中需要配置filter-name为springSecurityFilterChain

springSecurity源码分析-springSecurityFilterChain相关推荐

  1. springSecurity源码分析——DelegatingFilterProxy类的作用

    http://www.cnblogs.com/hzhuxin/archive/2011/12/19/2293730.html 使用过springSecurity的朋友都知道,首先需要在web.xml进 ...

  2. springSecurity源码分析-spring-security.xml文件配置

    在spring-security.xml文件中配置 在配置文件中我们主要使用标签来过多成配置 <!-- 配置不拦截的资源 --> <security:http pattern=&qu ...

  3. Spring Security源码分析四:Spring Social实现微信社交登录

    2019独角兽企业重金招聘Python工程师标准>>> 社交登录又称作社会化登录(Social Login),是指网站的用户可以使用腾讯QQ.人人网.开心网.新浪微博.搜狐微博.腾讯 ...

  4. SpringSecurity 源码解析 | 加JWT 实战 之 授权流程源码分析

    前两篇分析了SpringSecurity 认证源码和自定义认证流程,本片主要讲下另一个核心授权. 简单理解: 登录认证是用来确认用户是否能访问系统. 授权就是:你认证通过之后,还要检查是你是否满足资源 ...

  5. Spring Cloud部分源码分析Eureka,Ribbon,Feign,Zuul

    Eureka SpringCloud Eureka使用NetFlix Eureka来实现的,它包括了服务端组件和客户端组件,并且都是用java 编写的. Eureka服务端就是服务注册中心, Eure ...

  6. Spring Security(四) —— 核心过滤器源码分析

    摘要: 原创出处 https://www.cnkirito.moe/spring-security-4/ 「老徐」欢迎转载,保留摘要,谢谢! 4 过滤器详解 前面的部分,我们关注了Spring Sec ...

  7. Spring Security CSRF防御源码分析

    一.CSRF简介 1.CSRF是什么? CSRF(Cross-site request forgery),也被称为:one click attack/session riding,中文名称:跨站请求伪 ...

  8. 【Spring实战】----Security4.1.3鉴权之美--基于投票的AccessDecisionManager实现及源码分析

    一.背景知识 Spring实战篇系列----Security4.1.3认证过程源码分析和Spring实战篇系列----Security4.1.3实现根据请求跳转不同登录页以及登录后根据权限跳转到不同页 ...

  9. 【Golang源码分析】Go Web常用程序包gorilla/mux的使用与源码简析

    目录[阅读时间:约10分钟] 一.概述 二.对比: gorilla/mux与net/http DefaultServeMux 三.简单使用 四.源码简析 1.NewRouter函数 2.HandleF ...

最新文章

  1. list,numpy,tensor之间相互转换的方法
  2. java网关限流_网关限流使用
  3. Visual Studio 2008在设计视图和代码视图切换的快捷键F7
  4. 在ASP.NET MVC 中获取当前URL、controller、action
  5. java 返回js_如何基于java或js获取URL返回状态码
  6. 数据库实例:用户登录
  7. 单链表的增、删、查、改、python实现,超详细讲解
  8. 【C语言】Find The Single Dog(标志变量的使用)
  9. 有了PSD分层模板|花卉海报设计其实很简单!
  10. hashmap是线程安全的吗?怎么解决?_线程安全及三种解决方案
  11. 量子计算机美国华裔科学家,量子计算机很神?18岁华裔少年用经典计算机算得一样快...
  12. Python 结构体数组初始化代码示例
  13. wordpress调用the_excerpt()不带p标签
  14. 49. 把字符串转换成整数
  15. 安卓跳转应用市场评论
  16. 2022.9.19 自学计算机
  17. 快70倍!新一代JS构建工具:ESBuild SWC浅析
  18. 操作系统--(Linux)LinuxThread vs NPTL
  19. 计算机网络总复习(一)——选择篇
  20. 前端鼠标触碰实现遮罩方法

热门文章

  1. Struts2(一)— 入门
  2. 为什么有如此多的C++测试框架 - from Google Testing Blog
  3. 【大话数据结构算法】归并排序
  4. (十)HTML5本地存储——SQLLite实现web留言本
  5. 《妥协的完美主义—优秀产品经理的实践指南(卷一)》一2.4 分工常见的错误...
  6. 前端学HTTP之字符集
  7. 史诗级pg脚本,亲测好使
  8. UVA11324-- The Largest Clique(SCC+DP)
  9. 关于mysql存储大数据的问题
  10. Linux中cut命令的使用