public byte[] getShaPassword(final String clearPassword) { return PasswordUtil.createStoragePassword(clearPassword.getBytes(), LdapSecurityConstants.HASH_METHOD_SHA); }
/** * @see #createStoragePassword(byte[], LdapSecurityConstants) * * @param credentials The password * @param algorithm The algorithm to use * @return The resulting byte[] containing the paswword */ public static byte[] createStoragePassword( String credentials, LdapSecurityConstants algorithm ) { return createStoragePassword( Strings.getBytesUtf8( credentials ), algorithm ); }
/** * @see #createStoragePassword(byte[], LdapSecurityConstants) * * @param credentials The password * @param algorithm The algorithm to use * @return The resulting byte[] containing the paswword */ public static byte[] createStoragePassword( String credentials, LdapSecurityConstants algorithm ) { return createStoragePassword( Strings.getBytesUtf8( credentials ), algorithm ); }
/** * @see #createStoragePassword(byte[], LdapSecurityConstants) * * @param credentials The password * @param algorithm The algorithm to use * @return The resulting byte[] containing the paswword */ public static byte[] createStoragePassword( String credentials, LdapSecurityConstants algorithm ) { return createStoragePassword( Strings.getBytesUtf8( credentials ), algorithm ); }
values.add( PasswordUtil.createStoragePassword( bytes, algorithm ) );
/** * Modifies user password. * * @param session * the session. * @param username * the username. * @param password * the password. * @throws LdapException * if some error occurs. * @throws NoSuchAlgorithmException * the the algorithm doesn't exist. */ private void modifyUserPassword(final CoreSession session, final String username, final String password) throws LdapException, NoSuchAlgorithmException { LdapSecurityConstants algorithm = LdapSecurityConstants.getAlgorithm(ldapDigestAlgorithm); if (algorithm == null) { // default to PBKDF2-based encryption method algorithm = LdapSecurityConstants.HASH_METHOD_PKCS5S2; } final String passwordDigest = new String(PasswordUtil.createStoragePassword(password, algorithm)); session.modify(new Dn(getUserDN(username)), new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, USER_PASSWORD, passwordDigest)); }
byte[] hashedPassword = PasswordUtil.createStoragePassword( userPassword.getBytes(), algorithm );