springSecurity源码分析-springSecurityFilterChain
在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相关推荐
- springSecurity源码分析——DelegatingFilterProxy类的作用
http://www.cnblogs.com/hzhuxin/archive/2011/12/19/2293730.html 使用过springSecurity的朋友都知道,首先需要在web.xml进 ...
- springSecurity源码分析-spring-security.xml文件配置
在spring-security.xml文件中配置 在配置文件中我们主要使用标签来过多成配置 <!-- 配置不拦截的资源 --> <security:http pattern=&qu ...
- Spring Security源码分析四:Spring Social实现微信社交登录
2019独角兽企业重金招聘Python工程师标准>>> 社交登录又称作社会化登录(Social Login),是指网站的用户可以使用腾讯QQ.人人网.开心网.新浪微博.搜狐微博.腾讯 ...
- SpringSecurity 源码解析 | 加JWT 实战 之 授权流程源码分析
前两篇分析了SpringSecurity 认证源码和自定义认证流程,本片主要讲下另一个核心授权. 简单理解: 登录认证是用来确认用户是否能访问系统. 授权就是:你认证通过之后,还要检查是你是否满足资源 ...
- Spring Cloud部分源码分析Eureka,Ribbon,Feign,Zuul
Eureka SpringCloud Eureka使用NetFlix Eureka来实现的,它包括了服务端组件和客户端组件,并且都是用java 编写的. Eureka服务端就是服务注册中心, Eure ...
- Spring Security(四) —— 核心过滤器源码分析
摘要: 原创出处 https://www.cnkirito.moe/spring-security-4/ 「老徐」欢迎转载,保留摘要,谢谢! 4 过滤器详解 前面的部分,我们关注了Spring Sec ...
- Spring Security CSRF防御源码分析
一.CSRF简介 1.CSRF是什么? CSRF(Cross-site request forgery),也被称为:one click attack/session riding,中文名称:跨站请求伪 ...
- 【Spring实战】----Security4.1.3鉴权之美--基于投票的AccessDecisionManager实现及源码分析
一.背景知识 Spring实战篇系列----Security4.1.3认证过程源码分析和Spring实战篇系列----Security4.1.3实现根据请求跳转不同登录页以及登录后根据权限跳转到不同页 ...
- 【Golang源码分析】Go Web常用程序包gorilla/mux的使用与源码简析
目录[阅读时间:约10分钟] 一.概述 二.对比: gorilla/mux与net/http DefaultServeMux 三.简单使用 四.源码简析 1.NewRouter函数 2.HandleF ...
最新文章
- list,numpy,tensor之间相互转换的方法
- java网关限流_网关限流使用
- Visual Studio 2008在设计视图和代码视图切换的快捷键F7
- 在ASP.NET MVC 中获取当前URL、controller、action
- java 返回js_如何基于java或js获取URL返回状态码
- 数据库实例:用户登录
- 单链表的增、删、查、改、python实现,超详细讲解
- 【C语言】Find The Single Dog(标志变量的使用)
- 有了PSD分层模板|花卉海报设计其实很简单!
- hashmap是线程安全的吗?怎么解决?_线程安全及三种解决方案
- 量子计算机美国华裔科学家,量子计算机很神?18岁华裔少年用经典计算机算得一样快...
- Python 结构体数组初始化代码示例
- wordpress调用the_excerpt()不带p标签
- 49. 把字符串转换成整数
- 安卓跳转应用市场评论
- 2022.9.19 自学计算机
- 快70倍!新一代JS构建工具:ESBuild SWC浅析
- 操作系统--(Linux)LinuxThread vs NPTL
- 计算机网络总复习(一)——选择篇
- 前端鼠标触碰实现遮罩方法