public Map<String,List<String>> getPermissionLabels(Authentication authentication) {
    Map<String,List<String>> permissionLabels = new HashMap<>();
    if (authentication.getAuthorities() != null) {
      for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) {
        if(!(grantedAuthority instanceof AmbariGrantedAuthority)) {
          continue;
        }
        AmbariGrantedAuthority ambariGrantedAuthority = (AmbariGrantedAuthority) grantedAuthority;

        PrivilegeEntity privilegeEntity = ambariGrantedAuthority.getPrivilegeEntity();

        String key = null;
        try {
          switch(privilegeEntity.getResource().getResourceType().getName()) {
            case "CLUSTER":
              key = clusterDAO.findByResourceId(privilegeEntity.getResource().getId()).getClusterName();
              break;
            case "AMBARI":
              key = "Ambari";
              break;
            default:
              key = viewInstanceDAO.findByResourceId(privilegeEntity.getResource().getId()).getLabel();
              break;
          }
        } catch (Throwable ignored) {
          LOG.warn("Error occurred when cluster or view is searched based on resource id", ignored);
        }

        if(key != null) {
          if(!permissionLabels.containsKey(key)) {
            permissionLabels.put(key, new LinkedList<>());
          }
          permissionLabels.get(key).add(privilegeEntity.getPermission().getPermissionLabel());
        }
      }
    }
    return permissionLabels;
  }
Retrieve permission labels based on the details of the authenticated user
@param authentication the authenticated user and associated access privileges
@return human-readable permissions
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/PermissionHelper.java