转自: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()清楚这些信息。

最新文章

  1. 关于png、jpg、gif切图时的使用感悟
  2. Jsonp类
  3. 利用Spring创建定时任务
  4. PyOpenGL利用文泉驿正黑字体显示中文字体
  5. java.util.concurrent
  6. LCD驱动学习笔记
  7. Strtus2工作流程及原理
  8. 图片 Base64码 转换
  9. Android------&gt;TableLayout表格布局方式
  10. RAC日常管理
  11. 73. Set Matrix Zeroes(中等)
  12. 啊 B树
  13. MySQL 登陆
  14. docker简单入门之使用docker容器部署简单的java web开源项目jpress博客程序
  15. django的静态文件的引入
  16. js scroll函数
  17. VC++ 自定义控件的建立及使用方法
  18. Sqlite的安装和简单使用
  19. iOS:仿写探探App动画
  20. mybatis中使用in查询时的注意事项

热门文章

  1. CSDN CODE平台,中国版Github简要使用说明
  2. jQuery实现鼠标移上弹出提示框,移出消失
  3. WPF/Silverlight中的RichTextBox总结
  4. JSP和JavaBean
  5. PHP之-json转数组,支持多层嵌套json
  6. Erlang Resources 资讯小站
  7. head first--------------------template method pattern
  8. kubernetes入门之快速部署
  9. 深入理解HTTP Session
  10. 基于gulp编写的一个简单实用的前端开发环境好了,安装完Gulp后,接下来是你大展身手的时候了,在你自己的电脑上面随便哪个地方建一个目录,打开命令行,然后进入创建好的目录里面,开始撸代码,关于生成的json文件请点击这里https://docs.npmjs.com/files/package.json,打开的速度看你的网速了注意:以下是为了演示 ,我建的一个目录结构,你自己可以根据项目需求自己建目