UsernamePasswordAuthenticationFilter是登陆用户密码验证过滤器,
2015-11-11 23:08
696 查看
UsernamePasswordAuthenticationFilter是登陆用户密码验证过滤器,它继承了AbstractAuthenticationProcessingFilter过滤器(真正的Filter),是spring security3的第4个过滤器。
UsernamePasswordAuthenticationFilter有3个表单参数,是我们需要知道的
1、usernameParameter:对应登录时的用户名需要传的参数名称,默认为j_username,比如你输入用户hello,表单提交时是这样的 j_username=hello
2、passwordParameter:对应登录时的密码提交时的参数名称,默认为j_password,比如你输入密码是123123,表单提交是这样的 j_password=123123
3、filterProcessesUrl(放在了AbstractAuthenticationProcessingFilter):表单提交地址,默认为/j_spring_security_check,这个地址才能被UsernamePasswordAuthenticationFilter所截取,进行登录认证。
UsernamePasswordAuthenticationFilter会将表单提交的用户密码以及一些用户的其他信息(比如remoteAddr,seesionId),先放入UsernamePasswordAuthenticationToken中
UsernamePasswordAuthenticationToken继承了AbstractAuthenticationToken,AbstractAuthenticationToken继承了Authentication(Authentication存放用户的所有的认证信息)
UsernamePasswordAuthenticationToken 中有2个参数Object principal(主要的身份认证信息),Object credentials(用于证明principal是正确的信息,比如密码)
在一个带有username和password的权限认证请求中,principal就会被赋值username,credentials就会被赋值password;在使用AuthenticationManager的时候,principal会被赋值更多具有丰富内容的信息,比如被赋值成一个UserDetails对象,credentials可能会被赋值密码类似的东西,比如一个特殊的类吧。
AbstractAuthenticationToken中有3个参数Object details,Collection<GrantedAuthority> authorities,boolean authenticated
1、details:额外的认证信息,比如被赋值用户的IP地址
2、authorities:授权信息,比如被赋值用户的角色信息
3、authenticated :是否被验证通过
上面的5个参数是Authentication(是一个接口)必须的
了解以上信息,对理解用户登陆权限的验证过程有很大帮助
UsernamePasswordAuthenticationFilter有3个表单参数,是我们需要知道的
1、usernameParameter:对应登录时的用户名需要传的参数名称,默认为j_username,比如你输入用户hello,表单提交时是这样的 j_username=hello
2、passwordParameter:对应登录时的密码提交时的参数名称,默认为j_password,比如你输入密码是123123,表单提交是这样的 j_password=123123
3、filterProcessesUrl(放在了AbstractAuthenticationProcessingFilter):表单提交地址,默认为/j_spring_security_check,这个地址才能被UsernamePasswordAuthenticationFilter所截取,进行登录认证。
UsernamePasswordAuthenticationFilter会将表单提交的用户密码以及一些用户的其他信息(比如remoteAddr,seesionId),先放入UsernamePasswordAuthenticationToken中
UsernamePasswordAuthenticationToken继承了AbstractAuthenticationToken,AbstractAuthenticationToken继承了Authentication(Authentication存放用户的所有的认证信息)
UsernamePasswordAuthenticationToken 中有2个参数Object principal(主要的身份认证信息),Object credentials(用于证明principal是正确的信息,比如密码)
在一个带有username和password的权限认证请求中,principal就会被赋值username,credentials就会被赋值password;在使用AuthenticationManager的时候,principal会被赋值更多具有丰富内容的信息,比如被赋值成一个UserDetails对象,credentials可能会被赋值密码类似的东西,比如一个特殊的类吧。
AbstractAuthenticationToken中有3个参数Object details,Collection<GrantedAuthority> authorities,boolean authenticated
1、details:额外的认证信息,比如被赋值用户的IP地址
2、authorities:授权信息,比如被赋值用户的角色信息
3、authenticated :是否被验证通过
上面的5个参数是Authentication(是一个接口)必须的
了解以上信息,对理解用户登陆权限的验证过程有很大帮助
相关文章推荐
- 状态图
- IOS单例模式(Singleton)
- Android各个版本API的区别
- javascript的DOM操作获取元素
- 赫夫曼\哈夫曼\霍夫曼编码 (Huffman Tree)
- 第二百二十三天 how can I 坚持
- CodeTyphon32中自带例子源码:物理定律的模拟演示,太逼真
- JAVA 复习(Think In Java, 4th) -- File I/O -- Part 1
- 图片上传
- 增强现实(AR)笔记2:Vuforia+Unity例程ObjectRecognition
- programming-challenges Slash Maze (110904) 题解
- poj 3259 Wormholes 图论 最短路 判负环
- Hadoop1.x程序升级到Hadoop2.x需要的依赖库,Cannot initialize Cluster.Please check your configuration for ma
- block定义详解
- PHP动态创建属性的get和set方法
- markdown语法
- 更改hosts后还是无法使用Google,Facebook,Twitter等服务怎么办?
- 信号槽
- Swift学习笔记
- lua开发--模板渲染