我整天都在尝试找出或谷歌,如何salt
在身份验证期间添加到我的哈希密码中,Spring 3 security
并使其全部协同工作。没有盐它工作得很好。
<!-- authentication from database -->
<security:authentication-manager>
<security:authentication-provider>
<security:password-encoder hash='md5'/>
<security:jdbc-user-service
data-source-ref='dataSource'
users-by-username-query="
select username,password, salt
from users where username=?"
authorities-by-username-query="
select u.username, ur.authority from users u, user_roles ur
where u.user_id = ur.user_id and u.username =? " />
</security:authentication-provider>
</security:authentication-manager>
如果我想创建加盐密码,只需user.setPassword(md5(somePassword+someSalt));
感谢您的任何建议即可完成。