public void validatePassword(String password, String userName) {
    validatePassword(password);
    if (StringUtils.isNotEmpty(userName) && Pattern.compile(Pattern.quote(userName), Pattern.CASE_INSENSITIVE).matcher(password).find()) {
      final String msg = "The password does not meet the Ambari user password policy : password cannot contain the username";
      throw new IllegalArgumentException(msg);
    }
  }
Validates the password meets configured requirements according ambari.properties and it does not contain the username.

<p>

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