public static Authentication getAuthentication() {
    SecurityContext context = SecurityContextHolder.getContext();
    return (context == null) ? null : context.getAuthentication();
  }
Retrieves the authenticated user and authorization details from the application's security context.

@return the authenticated user and associated access privileges; or null if not available
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java