I am using Apache LDAP API to set new attribute: userPassword in Oracle Internet Directory. I want to set this password with SHA encryption method. I currently have following code:

Attribute userPasswordAttribute = new DefaultAttribute("userPassword", "password"));
ModifyRequest modifyRequest = new ModifyRequestImpl();
modifyRequest.setName(dn);
modifyRequest.add(userPasswordAttribute);
ModifyResponse response = connection.modify(modifyRequest);

However this adds SSHA encrypted password along with some other attributes which I do not want (authpassword;oid). I have seen that there a class called EncryptionMethod in LDAP API but how to use it in my code?

有帮助吗?

解决方案

Try this

String newPassword = "password";
modifyRequest.replace("userPassword", PasswordUtil.createStoragePassword(
                            newPassword.getBytes(), LdapSecurityConstants.HASH_METHOD_SHA));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top