public static String getProxyUserName(Authentication authentication) {
    if (authentication==null){
      return null;
    }
    Object userDetails = authentication.getPrincipal();
    if (userDetails instanceof AmbariProxiedUserDetailsImpl) {
      AmbariProxiedUserDetailsImpl ambariProxiedUserDetails = (AmbariProxiedUserDetailsImpl) userDetails;
      return ambariProxiedUserDetails.getProxyUserDetails().getUsername();
    }
    return null;
  }
Gets the name of the logged-in proxy user, if any.

@param authentication
@return the name of the logged-in proxy user
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java