<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