private static void rejectIfContainsAnyOf(String name, char[] forbiddenChars) {
    for (char each : forbiddenChars) {
      if (name.contains(Character.toString(each))) {
        throw new IllegalArgumentException("Invalid username: " + name + " Avoid characters " + Arrays.toString(forbiddenChars));
      }
    }
  }
Creates a UserName from the given string
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/UserName.java