首页 > 其他 > 详细

erase-credentials配置

时间:2016-12-22 06:23:57      阅读:507      评论:0      收藏:0      [点我收藏+]

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

erase-credentials配置

原文:http://www.cnblogs.com/drizzlewithwind/p/6209526.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!