erase-credentials配置
2024-08-29 13:25:55
转自:Spring Security怎样不让默认的ProviderManager清除密码等信息
<authentication-manager erase-credentials="false">
...
</authentication-manager>
erase-credentials默认为true,会在ProviderManager(默认的AuthenticationManager实现)的方法
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()清楚这些信息。
最新文章
- 关于png、jpg、gif切图时的使用感悟
- Jsonp类
- 利用Spring创建定时任务
- PyOpenGL利用文泉驿正黑字体显示中文字体
- java.util.concurrent
- LCD驱动学习笔记
- Strtus2工作流程及原理
- 图片 Base64码 转换
- Android------>;TableLayout表格布局方式
- RAC日常管理
- 73. Set Matrix Zeroes(中等)
- 啊 B树
- MySQL 登陆
- docker简单入门之使用docker容器部署简单的java web开源项目jpress博客程序
- django的静态文件的引入
- js scroll函数
- VC++ 自定义控件的建立及使用方法
- Sqlite的安装和简单使用
- iOS:仿写探探App动画
- mybatis中使用in查询时的注意事项
热门文章
- CSDN CODE平台,中国版Github简要使用说明
- jQuery实现鼠标移上弹出提示框,移出消失
- WPF/Silverlight中的RichTextBox总结
- JSP和JavaBean
- PHP之-json转数组,支持多层嵌套json
- Erlang Resources 资讯小站
- head first--------------------template method pattern
- kubernetes入门之快速部署
- 深入理解HTTP Session
- 基于gulp编写的一个简单实用的前端开发环境好了,安装完Gulp后,接下来是你大展身手的时候了,在你自己的电脑上面随便哪个地方建一个目录,打开命令行,然后进入创建好的目录里面,开始撸代码,关于生成的json文件请点击这里https://docs.npmjs.com/files/package.json,打开的速度看你的网速了注意:以下是为了演示 ,我建的一个目录结构,你自己可以根据项目需求自己建目