我在解决如何使用SSHA哈希而不是纯文本在Apache DS LDAP中保存密码时遇到问题.据我所知,正确的方法应该是配置Apache DS以使用SSHA存储密码,然后在设置密码时只发送纯文本.但是,我无法弄清楚如何配置Apache DS来执行此操作.
我已将Hashed密码推送到LDAP(使用LDAP的管理界面),Apache DS正确地验证了正确的密码.但是我需要从Java应用程序中插入密码.这不是一个不寻常的请求所以我必须遗漏一些东西.
这是我使用org.springframework.ldap.core中的LdapTemplate接口从java设置密码的代码
public void storeNewPassword(final String userId, final String password) {
final DistinguishedName dn = new DistinguishedName("dc=users,dc=pms,dc=com");
dn.add("uid", userId);
Attribute pass = new BasicAttribute("userpassword", password);
final ModificationItem mi = new ModificationItem(
DirContext.REPLACE_ATTRIBUTE,
pass);
ldapTemplate.modifyAttributes(dn, new ModificationItem[] {mi});
}
上面的代码正确设置了密码,但是当我查看Apache DS Server时,我发现密码已经以纯文本格式保存:
请有人验证这是否是设置密码的正确方法,并建议我如何配置Apache DS以将SSHA应用于它接收的密码.
谢谢