S - Spring Security Bad Principal Exception

时间:2014-10-10 15:17:24   收藏:0   阅读:177

项目中配置了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" />,即没有加密处理。


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!