private Set<UserAuthenticationSourceResponse> getUserAuthenticationSources(Set<UserAuthenticationSourceRequest> requests)
      throws AmbariException, AuthorizationException {

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

    for (UserAuthenticationSourceRequest request : requests) {

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

      // A user authentication source 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();
        }
      }

      Collection<UserAuthenticationEntity> authenticationEntities = users.getUserAuthenticationEntities(requestedUsername, request.getAuthenticationType());
      if (authenticationEntities != null) {
        for (UserAuthenticationEntity authenticationEntity : authenticationEntities) {
          responses.add(createUserAuthenticationSourceResponse(authenticationEntity));
        }
      }
    }

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

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