Package io.jenkins.plugins.authcommons
Class PrincipalSearch
java.lang.Object
io.jenkins.plugins.authcommons.PrincipalSearch
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intQueries shorter than this return no results. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanWhether any provider can search the current security realm.static Principallookup(String sid, PrincipalType type) Look up a principal by SID using the applicable providers.search(String query, Set<PrincipalType> types, int limit) Search all applicable providers.static org.kohsuke.stapler.HttpResponsesearchResponse(String query, String type, Integer limit) Build a JSON response for a search request, of the form{"results": [{"sid", "type", "displayName", "description"}]}.
-
Field Details
-
MIN_QUERY_LENGTH
public static final int MIN_QUERY_LENGTHQueries shorter than this return no results.- See Also:
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT- See Also:
-
MAX_LIMIT
public static final int MAX_LIMIT- See Also:
-
-
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 fortypes- the kinds of principals to return, an empty set means all kindslimit- the maximum number of results, capped atMAX_LIMIT- Returns:
- matching principals without duplicates, or an empty list if none could be found
-
lookup
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 fortype-USER,GROUP, or empty /nullfor bothlimit- the maximum number of results, ornullfor the default
-