S - Spring Security Bad Principal Exception

项目中配置了Spring Security,通过自定义的UserDetailsService实现loadUserByName方法能够查出用户的信息,在继续运行至DaoAuthorityXXX时,在UsernamePasswordToken时,报出Bad Principal异常,检查之后是因为 在security 配置中

配置了

<s:authentication-manager alias="authenticationManager">

<s:authentication-provider user-service-ref="userDetailsService">

<s:password-encoder hash="md5" />

</s:authentication-provider>

</s:authentication-manager>

数据库中的密码没有加密,所以springsecurity在比较用户输入的用户名,密码时,密码不一致抛出 Bad Principal Exception

解决方法:

更改:<s:password-encoder hash="md5" /> 为 <s:password-encoder hash="plaintext" />,即没有加密处理。


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。