Package io.jenkins.plugins.authcommons
Class PrincipalSearchProvider
java.lang.Object
io.jenkins.plugins.authcommons.PrincipalSearchProvider
- All Implemented Interfaces:
ExtensionPoint
Looks up users and groups in a directory, so that authorization strategies can offer autocompletion
when choosing who gets access.
Typically implemented by plugins that provide a SecurityRealm, and consumed by authorization
strategy plugins through PrincipalSearch. Implementations do not need to check permissions;
callers are responsible for that.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<PrincipalSearchProvider> all()abstract booleanisApplicable(SecurityRealm realm) Whether this provider can search the given security realm.lookup(String sid, PrincipalType type) Look up a single principal by SID, so that a friendly name can be shown for SIDs that are not meaningful by themselves (such as object ids).search(String query, Set<PrincipalType> types, int limit) Search for principals matching a query.
-
Constructor Details
-
PrincipalSearchProvider
public PrincipalSearchProvider()
-
-
Method Details
-
isApplicable
Whether this provider can search the given security realm.- Parameters:
realm- the currently configured security realm
-
search
@NonNull public abstract List<Principal> search(@NonNull String query, @NonNull Set<PrincipalType> types, int limit) throws Exception Search for principals matching a query.- Parameters:
query- free text entered by the user, at leastPrincipalSearch.MIN_QUERY_LENGTHcharacterstypes- the kinds of principals to return, never emptylimit- the maximum number of results to return- Returns:
- matching principals, best matches first
- Throws:
Exception- if the directory could not be searched
-
lookup
@CheckForNull public Principal lookup(@NonNull String sid, @NonNull PrincipalType type) throws Exception Look up a single principal by SID, so that a friendly name can be shown for SIDs that are not meaningful by themselves (such as object ids).- Returns:
- the principal, or
nullif it is unknown or this provider does not support lookups - Throws:
Exception- if the directory could not be queried
-
all
-