I am having problems working out how to save a password in an Apache DS LDAP in an SSHA hash instead of plain text. As far as I can tell, the correct way to go about it should be configuring Apache DS to use SSHA to store passwords and then when setting the password send only the plain Text. However, I can't work out how to configure Apache DS to do this.
I have pushed the Hashed password into the LDAP (Using an Admin interface to the LDAP) and Apache DS correctly authenticates against the correct password. However I need to insert the password from our Java application. This can't be an unusual request so I must be missing something.
Here is my code for setting the password from java using the LdapTemplate interface from org.springframework.ldap.core
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});
}
The Above code correctly sets the password, but when I look at the Apache DS Server I see that the password has been saved in plain text:
Please can someone verify whether this is the correct approach for setting passwords, and suggest how I can configure Apache DS to apply SSHA to passwords it receives.
Thanks