public synchronized boolean hasAdminPrivilege(UserEntity userEntity) {
    PrincipalEntity principalEntity = userEntity.getPrincipal();
    if (principalEntity != null) {
      Set<PrivilegeEntity> roles = principalEntity.getPrivileges();
      if (roles != null) {
        PermissionEntity adminPermission = permissionDAO.findAmbariAdminPermission();
        Integer adminPermissionId = (adminPermission == null) ? null : adminPermission.getId();

        if (adminPermissionId != null) {
          for (PrivilegeEntity privilegeEntity : roles) {
            PermissionEntity rolePermission = privilegeEntity.getPermission();
            if ((rolePermission != null) && (adminPermissionId.equals(rolePermission.getId()))) {
              return true;
            }
          }
        }
      }
    }

    return false;
  }
Test the user for Ambari Admistrator privileges.

@param userEntity the user to test
@return true if the user has Ambari Administrator privileges; otherwise false
ambari-server/src/main/java/org/apache/ambari/server/security/authorization/Users.java