public void validatePassword(String password, String userName, String authenticationKey) {
    validatePassword(password, userName);
    boolean isMatched = false;
    String[] previousPasswords = StringUtils.split(authenticationKey, ",");
    for (String previousPassword : previousPasswords) {
      if (passwordEncoder.matches(password, previousPassword)) {
        isMatched = true;
        break;
      }
    }
    if (isMatched) {
      final String msg = "The password does not meet the Ambari user password policy : new password can not be same as previous " + configuration.getPasswordPolicyHistoryCount() + " passwords.";
      throw new IllegalArgumentException(msg);
    }
  }
Validates the password meets configured requirements according ambari.properties, does not contain the username and different from previous passwords

<p>

@param password the password
@param userName the username
@param authenticationKey the authenticationKey associated with previous passwords
@throws  IllegalArgumentException if password does not meet the password policy requirements
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java