public static String getAuthenticatedName(String defaultUsername) {
    SecurityContext securityContext = SecurityContextHolder.getContext();

    Authentication auth = securityContext.getAuthentication();

    return (null == auth) ? defaultUsername : auth.getName();
  }
Gets the name of the logged-in user, if any.  Thread-safe due to use of
thread-local.

@param defaultUsername the value if there is no logged-in user
@return the name of the logged-in user, or the default
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java