<authentication-manager erase-credentials="false">加密
...spa
</authentication-manager>code
erase-credentials默认为true,会在blog
public Authentication authenticate(Authentication authentication) throws AuthenticationException get
返回前调用 ((CredentialsContainer)result).eraseCredentials(); 清除credentials等信息,因此咱们使用it
SecurityContextImpl securityContextImpl = (SecurityContextImpl) request .getSession().getAttribute("SPRING_SECURITY_CONTEXT"); Authentication authentication = securityContextImpl.getAuthentication(); // 登陆密码,未加密的 String password = (String)(authentication.getCredentials());
password老是为null。io
将erase-credentials设置为false后,不会清除这些保密信息,可是建议在使用完以后本身调用eraseCredentials()清楚这些信息。class