Spring Security怎样不让默认的ProviderManager清除密码等信息
<authentication-manager erase-credentials="false">
...
</authentication-manager>
erase-credentials默认为true,会在
public Authentication authenticate(Authentication authentication) throws AuthenticationException
返回前调用 ((CredentialsContainer)result).eraseCredentials(); 清除credentials等信息,所以我们使用
SecurityContextImpl securityContextImpl = (SecurityContextImpl) request
.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
Authentication authentication = securityContextImpl.getAuthentication();
// 登录密码,未加密的
String password = (String)(authentication.getCredentials());
password总是为null。
将erase-credentials设置为false后,不会清除这些保密信息,但是建议在使用完之后自己调用eraseCredentials()清楚这些信息。
Spring Security怎样不让默认的ProviderManager清除密码等信息的更多相关文章
- Spring Security 5中的默认密码编码器
1.概述 在Spring Security 4中,可以使用内存中身份验证以纯文本格式存储密码. 对版本5中的密码管理过程进行了重大改进,为密码编码和解码引入了更安全的默认机制.这意味着如果您的Spri ...
- spring security进阶 使用数据库中的账户和密码认证
目录 spring security 使用数据库中的账户和密码认证 一.原理分析 二.代码实现 1.新建一个javaWeb工程 2.用户认证的实现 3.测试 三.总结 spring security ...
- SpringBoot集成Spring Security入门体验
一.前言 Spring Security 和 Apache Shiro 都是安全框架,为Java应用程序提供身份认证和授权. 二者区别 Spring Security:重量级安全框架 Apache S ...
- Spring Security(三十二):10. Core Services
Now that we have a high-level overview of the Spring Security architecture and its core classes, let ...
- Spring Security 案例实现和执行流程剖析
Spring Security Spring Security 是 Spring 社区的一个顶级项目,也是 Spring Boot 官方推荐使用的安全框架.除了常规的认证(Authentication ...
- Spring Security 5.0.x 参考手册 【翻译自官方GIT-2018.06.12】
源码请移步至:https://github.com/aquariuspj/spring-security/tree/translator/docs/manual/src/docs/asciidoc 版 ...
- Spring Boot:整合Spring Security
综合概述 Spring Security 是 Spring 社区的一个顶级项目,也是 Spring Boot 官方推荐使用的安全框架.除了常规的认证(Authentication)和授权(Author ...
- Spring Security Architecture and Implementation(架构和实现)学习笔记
Spring Security 关于spring-security的官网文档学习笔记,主要是第8章 Architecture and Implementation(架构和实现)内容 参考: https ...
- 一文带你了解 OAuth2 协议与 Spring Security OAuth2 集成!
OAuth 2.0 允许第三方应用程序访问受限的HTTP资源的授权协议,像平常大家使用Github.Google账号来登陆其他系统时使用的就是 OAuth 2.0 授权框架,下图就是使用Github账 ...
随机推荐
- 2018数学建模国赛总结(A题/编程选手视角)
2018数学建模已经告一段落了,先说说基本情况吧,我们队伍专业分别为:金融(A),会计(B),计算机(我),配置还算可以,他们俩会数据分析软件也会写论文,我可以写代码,画图.他们俩打过美赛(M奖),我 ...
- 一个简单的Samba服务
上次给大家认识了下,搭建一个服务大概的一个认识. 这次给大家搭建一个Samba服务认识下. 项目准备: 虚拟机一个(Centos6.5版本) 项目目标: 进行samba最简单的配置 项目难度: ❤❤ ...
- (转)2-SAT小结
2-sat小结 原文作者:老K 原文传送门 2-sat是什么 一类问题是这样的: (两个符号的意思 \(\lor \ or,\land \ and\)) 有n个布尔变量,现在对它们做出限制,比如\(a ...
- socket长连接 GCDAsyncSocket
基础: http://www.2cto.com/kf/201609/546974.html 转自: http://blog.csdn.net/u013282507/article/details/52 ...
- Python之freshman08 Socket
1. Socket介绍 概念 A network socket is an endpoint of a connection across a computer network. Today, mos ...
- vue 阻止冒泡弹窗小案例( 知识点:@click.stop=''")
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Android 文字转语音(TTS)
1.介绍 2.xml文件布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xml ...
- sharepoint_study_4
描述:如何向sharepoint自定义列表,新建(编辑)页面的网站栏后,添加一个快捷方式? 如图示: 解决: 1.在SharePoint Designer中打开该自定义列表 2.右键NewForm.a ...
- 【算法笔记】B1027 打印沙漏
1027 打印沙漏 (20 分) 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇 ...
- C - 思考使用差分简化区间操作
FJ's N (1 ≤ N ≤ 10,000) cows conveniently indexed 1..N are standing in a line. Each cow has a positi ...