Spring Security怎样不让默认的ProviderManager清除密码等信息
2024-09-27 18:35:56
<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()清楚这些信息。
最新文章
- Linux sort 命令
- Ubuntu菜鸟入门(四)—— 搜狗输入法
- 学习Maven之Properties Maven Plugin
- git恢复误删文件及省去密码提交
- hiho_1041 国庆出游
- saiku-添加数据源以及保证数据源的一致性
- chattr实现文件不可删除
- 一个实例明白AutoResetEvent和 ManulResetEvent的用法
- HTML5 <;Audio/>;标签Api整理(二)
- SIM卡尺寸及剪卡教程
- TreeSet()详解
- CSS概要
- 兼容低版本JS的Array.map方法
- GridView 多余字符显示省略号,并在Tooltip中显示完整信息
- 终止Docker容器
- Qt for Android开发总结
- fork()相关的源码解析
- Java 发送SOAP请求调用WebService,解析SOAP报文
- netty源码理解(三) 从channel读取数据
- mui 百度语音识别转换文字
热门文章
- Listview 利用Datapager进行分页
- CString::MakeLower Crash
- 如何从Spring官网下载Spring的jar包
- spring boot日志及Log4j日志配置
- 数据结构之BF算法,kmp算法,三元组,十字链表总结
- 使用IIS服务器部署网页,需要开启服务里的“ASP.NET 状态服务”
- 洛谷P4207 [NOI2005]月下柠檬树(计算几何+自适应Simpson法)
- 【Thread】线程工厂-ThreadFactory
- 2008R2 无法安装 HDP Apache 系列服务解决方案
- BDD 相关整理---介绍