Class PrincipalSearch

java.lang.Object
io.jenkins.plugins.authcommons.PrincipalSearch

public final class PrincipalSearch extends Object
Entry point for authorization strategies to search the configured security realm for users and groups.

This class performs no permission checks. Callers must verify that the current user is allowed to configure access in the relevant context before exposing results, typically from a doXxx web method on their descriptor.

  • Field Details

  • Method Details

    • isAvailable

      public static boolean isAvailable()
      Whether any provider can search the current security realm.
    • search

      @NonNull public static List<Principal> search(@CheckForNull String query, @CheckForNull Set<PrincipalType> types, int limit)
      Search all applicable providers.
      Parameters:
      query - the text to search for
      types - the kinds of principals to return, an empty set means all kinds
      limit - the maximum number of results, capped at MAX_LIMIT
      Returns:
      matching principals without duplicates, or an empty list if none could be found
    • lookup

      @CheckForNull public static Principal lookup(@CheckForNull String sid, @NonNull PrincipalType type)
      Look up a principal by SID using the applicable providers.
      Returns:
      the first principal found, or null
    • searchResponse

      @NonNull public static org.kohsuke.stapler.HttpResponse searchResponse(@CheckForNull String query, @CheckForNull String type, @CheckForNull Integer limit)
      Build a JSON response for a search request, of the form {"results": [{"sid", "type", "displayName", "description"}]}.
      Parameters:
      query - the text to search for
      type - USER, GROUP, or empty / null for both
      limit - the maximum number of results, or null for the default