private Set<UserResponse> getUsers(Set<UserRequest> requests)
      throws AmbariException, AuthorizationException {

    Set<UserResponse> responses = new HashSet<>();

    for (UserRequest r : requests) {

      if (LOG.isDebugEnabled()) {
        LOG.debug("Received a getUsers request, userRequest={}", r.toString());
      }

      String requestedUsername = r.getUsername();
      String authenticatedUsername = AuthorizationHelper.getAuthenticatedName();

      // A user resource may be retrieved by an administrator or the same user.
      if (!AuthorizationHelper.isAuthorized(ResourceType.AMBARI, null, RoleAuthorization.AMBARI_MANAGE_USERS)) {
        if (null == requestedUsername) {
          // Since the authenticated user is not the administrator, force only that user's resource
          // to be returned
          requestedUsername = authenticatedUsername;
        } else if (!requestedUsername.equalsIgnoreCase(authenticatedUsername)) {
          // Since the authenticated user is not the administrator and is asking for a different user,
          // throw an AuthorizationException
          throw new AuthorizationException();
        }
      }

      // get them all
      if (null == requestedUsername) {
        for (UserEntity u : users.getAllUserEntities()) {
          responses.add(createUserResponse(u));
        }
      } else {

        UserEntity u = users.getUserEntity(requestedUsername);
        if (null == u) {
          if (requests.size() == 1) {
            // only throw exceptin if there is a single request
            // if there are multiple requests, this indicates an OR predicate
            throw new ObjectNotFoundException("Cannot find user '"
                + requestedUsername + "'");
          }
        } else {
          responses.add(createUserResponse(u));
        }
      }
    }

    return responses;
  }
Gets the users identified by the given request objects.

@param requests the request objects
@return a set of user responses
@throws AmbariException if the users could not be read
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java