private static String validated(String userName) {
    if (StringUtils.isBlank(userName)) {
      throw new IllegalArgumentException("Username cannot be empty");
    }
    rejectIfContainsAnyOf(userName, FORBIDDEN_CHARS);
    return userName;
  }
Creates a UserName from the given string
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/UserName.java