문제

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