Class CredentialsProvider
- All Implemented Interfaces:
ExtensionPoint
,Describable<CredentialsProvider>
,Saveable
,Loadable
,OnMaster
,IconSpec
- Direct Known Subclasses:
SystemCredentialsProvider.ProviderImpl
,UserCredentialsProvider
public abstract class CredentialsProvider
extends Descriptor<CredentialsProvider>
implements ExtensionPoint, Describable<CredentialsProvider>, IconSpec
An extension point for providing
Credentials
.-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Permission
The permission for adding credentials to aCredentialsStore
.static final Permission
The permission for removing credentials from aCredentialsStore
.static final PermissionGroup
The permission group for credentials.static final Permission
The permission for managing credential domains in aCredentialsStore
.static final CredentialsProvider
ACredentialsProvider
that does nothing for use as a markerstatic final Permission
The permission for updating credentials in aCredentialsStore
.static final Permission
Where an immediate action against a job requires that a credential be selected by the user triggering the action, this permission allows the user to select a credential from those credentials available within the scope of the job.static final Permission
Where an immediate action against a job requires that a credential be selected by the user triggering the action, this permission allows the user to select a credential from their private credential store.static final Permission
The permission for viewing credentials in aCredentialsStore
.Fields inherited from class hudson.model.Descriptor
clazz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_isApplicable
(Descriptor<?> descriptor) CredentialsProvider
subtypes can override this method to veto someDescriptor
s from being available from their store.static ExtensionList<CredentialsProvider>
all()
Returns the list of allCredentialsProvider
.Returns all the registeredCredentials
descriptors.static List<CredentialsProvider>
enabled()
Returns only thoseCredentialsProvider
that areisEnabled()
.static List<CredentialsProvider>
Returns only thoseCredentialsProvider
that areisEnabled()
within a specific context.static <C extends IdCredentials>
CfindCredentialById
(String id, Class<C> type, Run<?, ?> run) A common requirement for plugins is to resolve a specific credential by id in the context of a specific run.static <C extends IdCredentials>
CfindCredentialById
(String id, Class<C> type, Run<?, ?> run, DomainRequirement... domainRequirements) Deprecated.static <C extends IdCredentials>
CfindCredentialById
(String id, Class<C> type, Run<?, ?> run, List<DomainRequirement> domainRequirements) A common requirement for plugins is to resolve a specific credential by id in the context of a specific run.<C extends IdCredentials>
ListBoxModelgetCredentialIds
(Class<C> type, ItemGroup itemGroup, Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Deprecated.<C extends IdCredentials>
ListBoxModelgetCredentialIds
(Class<C> type, Item item, Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Deprecated.<C extends IdCredentials>
ListBoxModelgetCredentialIdsInItem
(Class<C> type, Item item, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Returns aListBoxModel
of the credentials provided by this provider which are available to the specifiedAuthentication
for the specifiedItem
and are appropriate for the specifiedDomainRequirement
s.<C extends IdCredentials>
ListBoxModelgetCredentialIdsInItemGroup
(Class<C> type, ItemGroup itemGroup, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Returns aListBoxModel
of the credentials provided by this provider which are available to the specifiedAuthentication
for items in the specifiedItemGroup
and are appropriate for the specifiedDomainRequirement
s.<C extends Credentials>
List<C>getCredentials
(Class<C> type, ItemGroup itemGroup, Authentication authentication) Deprecated.<C extends Credentials>
List<C>getCredentials
(Class<C> type, ItemGroup itemGroup, Authentication authentication, List<DomainRequirement> domainRequirements) Deprecated.<C extends Credentials>
List<C>getCredentials
(Class<C> type, Item item, Authentication authentication) Deprecated.<C extends Credentials>
List<C>getCredentials
(Class<C> type, Item item, Authentication authentication, List<DomainRequirement> domainRequirements) Deprecated.final List<CredentialsDescriptor>
Returns the list ofCredentialsDescriptor
instances that are applicable within thisCredentialsProvider
.<C extends Credentials>
List<C>getCredentialsInItem
(Class<C> type, Item item, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements) Returns the credentials provided by this provider which are available to the specifiedAuthentication
for the specifiedItem
and are appropriate for the specifiedDomainRequirement
s.<C extends Credentials>
List<C>getCredentialsInItemGroup
(Class<C> type, ItemGroup itemGroup, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements) Returns the credentials provided by this provider which are available to the specifiedAuthentication
for items in the specifiedItemGroup
and are appropriate for the specified.plugins.credentials.domains.DomainRequirement
s.static Fingerprint
Retrieves theFingerprint
for a specific credential.static Fingerprint
Creates a fingerprint that can be used to track the usage of a specific credential.getScopes
(ModelObject object) Returns the scopes allowed for credentials stored within the specified object ornull
if the object is not relevant for scopes and the object's container should be considered instead.getStore
(ModelObject object) Returns theCredentialsStore
that thisCredentialsProvider
maintains specifically for thisModelObject
ornull
if either the object is not a credentials container or thisCredentialsProvider
does not maintain a store specifically bound to thisModelObject
.final boolean
Checks if there is at least oneCredentialsDescriptor
applicable within thisCredentialsProvider
.static boolean
hasStores
(ModelObject context) Tests if the supplied context has any credentials stores associated with it.final boolean
isApplicable
(Descriptor<?> descriptor) final boolean
isApplicable
(Class<? extends Credentials> clazz) Returnstrue
if thisCredentialsProvider
can provide credentials of the supplied type.final boolean
Returnstrue
if thisCredentialsProvider
is enabled.boolean
Returnstrue
if thisCredentialsProvider
is enabled in the specified context.static <C extends IdCredentials>
ListBoxModellistCredentials
(Class<C> type, ItemGroup itemGroup, Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Deprecated.static <C extends IdCredentials>
ListBoxModellistCredentials
(Class<C> type, Item item, Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Deprecated.static <C extends IdCredentials>
ListBoxModellistCredentialsInItem
(Class<C> type, Item item, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Returns aListBoxModel
of all credentials which are available to the specifiedAuthentication
for use by the specifiedItem
.static <C extends IdCredentials>
ListBoxModellistCredentialsInItemGroup
(Class<C> type, ItemGroup itemGroup, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements, CredentialsMatcher matcher) Returns aListBoxModel
of all credentials which are available to the specifiedAuthentication
for use by theItem
s in the specifiedItemGroup
.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type) static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, Item item) Deprecated.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, ItemGroup itemGroup) Deprecated.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, ItemGroup itemGroup, Authentication authentication) Deprecated.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, ItemGroup itemGroup, Authentication authentication, DomainRequirement... domainRequirements) static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, ItemGroup itemGroup, Authentication authentication, List<DomainRequirement> domainRequirements) Deprecated.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, Item item, Authentication authentication) Deprecated.uselookupCredentialsInItem(Class, Item, Authentication)
instead.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, Item item, Authentication authentication, DomainRequirement... domainRequirements) static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, Item item, Authentication authentication, List<DomainRequirement> domainRequirements) Deprecated.static <C extends Credentials>
List<C>lookupCredentials
(Class<C> type, Authentication authentication) static <C extends Credentials>
List<C>lookupCredentialsInItem
(Class<C> type, Item item, org.springframework.security.core.Authentication authentication) Returns all credentials which are available to the specifiedAuthentication
for use by the specifiedItem
.static <C extends Credentials>
List<C>lookupCredentialsInItem
(Class<C> type, Item item, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements) Returns all credentials which are available to the specifiedAuthentication
for use by the specifiedItem
.static <C extends Credentials>
List<C>lookupCredentialsInItemGroup
(Class<C> type, ItemGroup itemGroup, org.springframework.security.core.Authentication authentication) static <C extends Credentials>
List<C>lookupCredentialsInItemGroup
(Class<C> type, ItemGroup itemGroup, org.springframework.security.core.Authentication authentication, List<DomainRequirement> domainRequirements) static Set<CredentialsScope>
lookupScopes
(ModelObject object) Returns the scopes allowed for credentials stored within the specified object ornull
if the object is not relevant for scopes and the object's container should be considered instead.static Iterable<CredentialsStore>
lookupStores
(ModelObject context) Returns a lazyIterable
of all theCredentialsStore
instances contributing credentials to the supplied object.static void
saveAll()
A helper method for Groovy Scripting to address use cases such as JENKINS-39317 where all credential stores need to be resaved.static <C extends Credentials>
Csnapshot
(C credential) Make a best effort to ensure that the supplied credential is a snapshot credential (i.e.static <C extends Credentials>
CMake a best effort to ensure that the supplied credential is a snapshot credential (i.e.static <C extends Credentials>
CTrack the usage of credentials in a specific item but not associated with a specific build, for example SCM polling.static <C extends Credentials>
CTrack the usage of credentials in a specific node.static <C extends Credentials>
CTrack the usage of credentials in a specific build.static <C extends Credentials>
List<C>Track the usage of credentials in a specific item but not associated with a specific build, for example SCM polling.static <C extends Credentials>
List<C>Track the usage of credentials in a specific item but not associated with a specific build, for example SCM polling.static <C extends Credentials>
List<C>Track the usage of credentials in a specific node.static <C extends Credentials>
List<C>Track the usage of credentials in a specific node.static <C extends Credentials>
List<C>Track the usage of credentials in a specific build.static <C extends Credentials>
List<C>Track the usage of credentials in a specific build.Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, configure, doHelp, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getStaticHelpUrl, getStaticHelpUrl, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Field Details
-
NONE
ACredentialsProvider
that does nothing for use as a marker- Since:
- 2.1.1
-
GROUP
The permission group for credentials.- Since:
- 1.8
-
USE_OWN
Where an immediate action against a job requires that a credential be selected by the user triggering the action, this permission allows the user to select a credential from their private credential store. Immediate actions could include: building with parameters, tagging a build, deploying artifacts, etc.- Since:
- 1.16
-
USE_ITEM
Where an immediate action against a job requires that a credential be selected by the user triggering the action, this permission allows the user to select a credential from those credentials available within the scope of the job. Immediate actions could include: building with parameters, tagging a build, deploying artifacts, etc. This permission is implied byItem.CONFIGURE
as anyone who can configure the job can configure the job to use credentials within the item scope anyway.- Since:
- 1.16
-
CREATE
The permission for adding credentials to aCredentialsStore
.- Since:
- 1.8
-
UPDATE
The permission for updating credentials in aCredentialsStore
.- Since:
- 1.8
-
VIEW
The permission for viewing credentials in aCredentialsStore
.- Since:
- 1.8
-
DELETE
The permission for removing credentials from aCredentialsStore
.- Since:
- 1.8
-
MANAGE_DOMAINS
The permission for managing credential domains in aCredentialsStore
.- Since:
- 1.8
-
-
Constructor Details
-
CredentialsProvider
public CredentialsProvider()Default constructor.
-
-
Method Details
-
allCredentialsDescriptors
public static DescriptorExtensionList<Credentials,CredentialsDescriptor> allCredentialsDescriptors()Returns all the registeredCredentials
descriptors.- Returns:
- all the registered
Credentials
descriptors.
-
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type) -
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable Authentication authentication) -
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable Item item) Deprecated. -
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup) Deprecated. -
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication) Deprecated. -
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable Item item, @Nullable Authentication authentication) Deprecated.uselookupCredentialsInItem(Class, Item, Authentication)
instead. -
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @Nullable DomainRequirement... domainRequirements) -
lookupCredentialsInItemGroup
@NonNull public static <C extends Credentials> List<C> lookupCredentialsInItemGroup(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable org.springframework.security.core.Authentication authentication) Returns all credentials which are available to the specifiedAuthentication
for use by theItem
s in the specifiedItemGroup
.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to get.itemGroup
- the item group.authentication
- the authentication.- Returns:
- the list of credentials.
- Since:
- TODO
-
lookupCredentials
@NonNull @Deprecated public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @Nullable List<DomainRequirement> domainRequirements) Deprecated. -
lookupCredentialsInItemGroup
@NonNull public static <C extends Credentials> List<C> lookupCredentialsInItemGroup(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable org.springframework.security.core.Authentication authentication, @Nullable List<DomainRequirement> domainRequirements) Returns all credentials which are available to the specifiedAuthentication
for use by theItem
s in the specifiedItemGroup
.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to get.itemGroup
- the item group.authentication
- the authentication.domainRequirements
- the credential domains to match.- Returns:
- the list of credentials.
- Since:
- TODO
-
listCredentials
@Deprecated public static <C extends IdCredentials> ListBoxModel listCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @Nullable List<DomainRequirement> domainRequirements, @Nullable CredentialsMatcher matcher) Deprecated. -
listCredentialsInItemGroup
public static <C extends IdCredentials> ListBoxModel listCredentialsInItemGroup(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable org.springframework.security.core.Authentication authentication, @Nullable List<DomainRequirement> domainRequirements, @Nullable CredentialsMatcher matcher) Returns aListBoxModel
of all credentials which are available to the specifiedAuthentication
for use by theItem
s in the specifiedItemGroup
.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to get.authentication
- the authentication.itemGroup
- the item group.domainRequirements
- the credential domains to match.matcher
- the additional filtering to apply to the credentials- Returns:
- the
ListBoxModel
ofIdCredentials.getId()
with the corresponding display names as provided byCredentialsNameProvider
. - Since:
- TODO
-
lookupCredentials
@Deprecated @NonNull public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable Item item, @Nullable Authentication authentication, DomainRequirement... domainRequirements) -
lookupCredentialsInItem
@NonNull public static <C extends Credentials> List<C> lookupCredentialsInItem(@NonNull Class<C> type, @Nullable Item item, @Nullable org.springframework.security.core.Authentication authentication) Returns all credentials which are available to the specifiedAuthentication
for use by the specifiedItem
.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to get.authentication
- the authentication.item
- the item.- Returns:
- the list of credentials.
- Since:
- TODO
-
lookupCredentials
@NonNull @Deprecated public static <C extends Credentials> List<C> lookupCredentials(@NonNull Class<C> type, @Nullable Item item, @Nullable Authentication authentication, @Nullable List<DomainRequirement> domainRequirements) Deprecated. -
lookupCredentialsInItem
@NonNull public static <C extends Credentials> List<C> lookupCredentialsInItem(@NonNull Class<C> type, @Nullable Item item, @Nullable org.springframework.security.core.Authentication authentication, @Nullable List<DomainRequirement> domainRequirements) Returns all credentials which are available to the specifiedAuthentication
for use by the specifiedItem
.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to get.authentication
- the authentication.item
- the item.domainRequirements
- the credential domains to match.- Returns:
- the list of credentials.
- Since:
- TODO
-
listCredentials
@NonNull @Deprecated public static <C extends IdCredentials> ListBoxModel listCredentials(@NonNull Class<C> type, @Nullable Item item, @Nullable Authentication authentication, @Nullable List<DomainRequirement> domainRequirements, @Nullable CredentialsMatcher matcher) Deprecated. -
listCredentialsInItem
@NonNull public static <C extends IdCredentials> ListBoxModel listCredentialsInItem(@NonNull Class<C> type, @Nullable Item item, @Nullable org.springframework.security.core.Authentication authentication, @Nullable List<DomainRequirement> domainRequirements, @Nullable CredentialsMatcher matcher) Returns aListBoxModel
of all credentials which are available to the specifiedAuthentication
for use by the specifiedItem
.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to get.authentication
- the authentication.item
- the item.domainRequirements
- the credential domains to match.matcher
- the additional filtering to apply to the credentials- Returns:
- the
ListBoxModel
ofIdCredentials.getId()
with the corresponding display names as provided byCredentialsNameProvider
. - Since:
- TODO
-
lookupScopes
Returns the scopes allowed for credentials stored within the specified object ornull
if the object is not relevant for scopes and the object's container should be considered instead.- Parameters:
object
- the object.- Returns:
- the set of scopes that are relevant for the object or
null
if the object is not a credentials container.
-
hasStores
Tests if the supplied context has any credentials stores associated with it.- Parameters:
context
- the context object.- Returns:
true
if and only if the supplied context has at least oneCredentialsStore
associated with it.- Since:
- 2.1.5
-
lookupStores
Returns a lazyIterable
of all theCredentialsStore
instances contributing credentials to the supplied object.- Parameters:
context
- theItem
orItemGroup
orUser
to get theCredentialsStore
s of.- Returns:
- a lazy
Iterable
of allCredentialsStore
instances. - Since:
- 1.8
-
snapshot
Make a best effort to ensure that the supplied credential is a snapshot credential (i.e. self-contained and does not reference any external stores). WARNING: May produce unusual results if presented an exotic credential that implements multiple distinct credential types at the same time, e.g. a credential that is simultaneously a TLS certificate and a SSH key pair and a GPG key pair all at the same time... unless the author of that credential type also provides aCredentialsSnapshotTaker
that can handle such a triple play.- Type Parameters:
C
- the type of credential.- Parameters:
credential
- the credential.- Returns:
- the credential or a snapshot of the credential.
- Since:
- 1.14
-
snapshot
Make a best effort to ensure that the supplied credential is a snapshot credential (i.e. self-contained and does not reference any external stores)- Type Parameters:
C
- the type of credential.- Parameters:
clazz
- the type of credential that we are trying to snapshot (specified so that if there is more than one type of snapshot able credential interface implemented by the credentials, then they can be separated out.credential
- the credential.- Returns:
- the credential or a snapshot of the credential.
- Since:
- 1.14
-
findCredentialById
@CheckForNull public static <C extends IdCredentials> C findCredentialById(@NonNull String id, @NonNull Class<C> type, @NonNull Run<?, ?> run) A common requirement for plugins is to resolve a specific credential by id in the context of a specific run. Given that the credential itself could be resulting from a build parameter expression and the complexities of determining the scope of items from which the credential should be resolved in a chain of builds, this method provides the correct answer.- Type Parameters:
C
- the credentials type.- Parameters:
id
- either the id of the credential to find or a parameter expression for the id.type
- the type of credential to find.run
- theRun
defining the context within which to find the credential.- Returns:
- the credential or
null
if either the credential cannot be found or the user triggering the run is not permitted to use the credential in the context of the run. - Since:
- TODO
-
findCredentialById
public static <C extends IdCredentials> C findCredentialById(@NonNull String id, @NonNull Class<C> type, @NonNull Run<?, ?> run, DomainRequirement... domainRequirements) Deprecated.UsefindCredentialById(String, Class, Run, List)
instead. -
findCredentialById
@CheckForNull public static <C extends IdCredentials> C findCredentialById(@NonNull String id, @NonNull Class<C> type, @NonNull Run<?, ?> run, @Nullable List<DomainRequirement> domainRequirements) A common requirement for plugins is to resolve a specific credential by id in the context of a specific run. Given that the credential itself could be resulting from a build parameter expression and the complexities of determining the scope of items from which the credential should be resolved in a chain of builds, this method provides the correct answer.- Type Parameters:
C
- the credentials type.- Parameters:
id
- either the id of the credential to find or a parameter expression for the id.type
- the type of credential to find.run
- theRun
defining the context within which to find the credential.domainRequirements
- the domain requirements of the credential.- Returns:
- the credential or
null
if either the credential cannot be found or the user triggering the run is not permitted to use the credential in the context of the run. - Since:
- 1.16
-
all
Returns the list of allCredentialsProvider
.- Returns:
- the list of all
CredentialsProvider
.
-
enabled
Returns only thoseCredentialsProvider
that areisEnabled()
.- Returns:
- a list of
CredentialsProvider
that areisEnabled()
. - Since:
- 2.0
-
enabled
Returns only thoseCredentialsProvider
that areisEnabled()
within a specific context.- Parameters:
context
- the context in which to get the list.- Returns:
- a list of
CredentialsProvider
that areisEnabled()
. - Since:
- 2.0
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<CredentialsProvider>
-
isEnabled
public final boolean isEnabled()Returnstrue
if thisCredentialsProvider
is enabled.- Returns:
true
if thisCredentialsProvider
is enabled.- Since:
- 2.0
-
isEnabled
Returnstrue
if thisCredentialsProvider
is enabled in the specified context.- Parameters:
context
- the context.- Returns:
true
if thisCredentialsProvider
is enabled in the specified context.- Since:
- 2.0
-
getDisplayName
- Overrides:
getDisplayName
in classDescriptor<CredentialsProvider>
-
getIconClassName
- Specified by:
getIconClassName
in interfaceIconSpec
-
getScopes
Returns the scopes allowed for credentials stored within the specified object ornull
if the object is not relevant for scopes and the object's container should be considered instead.- Parameters:
object
- the object.- Returns:
- the set of scopes that are relevant for the object or
null
if the object is not a credentials container.
-
getStore
Returns theCredentialsStore
that thisCredentialsProvider
maintains specifically for thisModelObject
ornull
if either the object is not a credentials container or thisCredentialsProvider
does not maintain a store specifically bound to thisModelObject
.- Parameters:
object
- theItem
orItemGroup
orUser
that the store is being requested of.- Returns:
- either
null
or a scopedCredentialsStore
whereCredentialsStore.getContext()
== object
. - Since:
- 1.8
-
getCredentials
@NonNull @Deprecated public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication) Deprecated. -
getCredentials
@Deprecated @NonNull public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) Deprecated. -
getCredentialsInItemGroup
@NonNull public <C extends Credentials> List<C> getCredentialsInItemGroup(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable org.springframework.security.core.Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) Returns the credentials provided by this provider which are available to the specifiedAuthentication
for items in the specifiedItemGroup
and are appropriate for the specified.plugins.credentials.domains.DomainRequirement
s.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to return.itemGroup
- the item group (ifnull
assumeJenkins.get()
.authentication
- the authentication (ifnull
assumeACL.SYSTEM2
.domainRequirements
- the credential domains to match (if theCredentialsProvider
does not supportDomainRequirement
s then it should assume the match is true).- Returns:
- the list of credentials.
- Since:
- TODO
-
getCredentialIds
@NonNull @Deprecated public <C extends IdCredentials> ListBoxModel getCredentialIds(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements, @NonNull CredentialsMatcher matcher) Deprecated. -
getCredentialIdsInItemGroup
@NonNull public <C extends IdCredentials> ListBoxModel getCredentialIdsInItemGroup(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable org.springframework.security.core.Authentication authentication, @NonNull List<DomainRequirement> domainRequirements, @NonNull CredentialsMatcher matcher) Returns aListBoxModel
of the credentials provided by this provider which are available to the specifiedAuthentication
for items in the specifiedItemGroup
and are appropriate for the specifiedDomainRequirement
s. NOTE: implementations are recommended to override this method if the actual secret information is being stored external from Jenkins and the non-secret information can be accessed with lesser traceability requirements. The default implementation just usesgetCredentialsInItem(Class, Item, Authentication, List)
to build theListBoxModel
. Handling theCredentialsMatcher
may require standing up a proxy instance to apply the matcher against ifCredentialsMatchers.describe(CredentialsMatcher)
returnsnull
- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to return.itemGroup
- the item group (ifnull
assumeJenkins.get()
.authentication
- the authentication (ifnull
assumeACL.SYSTEM2
.domainRequirements
- the credential domain to match.matcher
- the additional filtering to apply to the credentials- Returns:
- the
ListBoxModel
ofIdCredentials.getId()
with names provided byCredentialsNameProvider
. - Since:
- TODO
-
getCredentials
@Deprecated @NonNull public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @NonNull Item item, @Nullable Authentication authentication) Deprecated. -
getCredentials
@Deprecated @NonNull public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @NonNull Item item, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) Deprecated. -
getCredentialsInItem
@NonNull public <C extends Credentials> List<C> getCredentialsInItem(@NonNull Class<C> type, @NonNull Item item, @Nullable org.springframework.security.core.Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) Returns the credentials provided by this provider which are available to the specifiedAuthentication
for the specifiedItem
and are appropriate for the specifiedDomainRequirement
s.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to return.item
- the item.authentication
- the authentication (ifnull
assumeACL.SYSTEM2
.domainRequirements
- the credential domain to match.- Returns:
- the list of credentials.
- Since:
- TODO
-
getCredentialIds
@NonNull @Deprecated public <C extends IdCredentials> ListBoxModel getCredentialIds(@NonNull Class<C> type, @NonNull Item item, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements, @NonNull CredentialsMatcher matcher) Deprecated. -
getCredentialIdsInItem
@NonNull public <C extends IdCredentials> ListBoxModel getCredentialIdsInItem(@NonNull Class<C> type, @NonNull Item item, @Nullable org.springframework.security.core.Authentication authentication, @NonNull List<DomainRequirement> domainRequirements, @NonNull CredentialsMatcher matcher) Returns aListBoxModel
of the credentials provided by this provider which are available to the specifiedAuthentication
for the specifiedItem
and are appropriate for the specifiedDomainRequirement
s. NOTE: implementations are recommended to override this method if the actual secret information is being stored external from Jenkins and the non-secret information can be accessed with lesser traceability requirements. The default implementation just usesgetCredentialsInItem(Class, Item, Authentication, List)
to build theListBoxModel
. Handling theCredentialsMatcher
may require standing up a proxy instance to apply the matcher against.- Type Parameters:
C
- the credentials type.- Parameters:
type
- the type of credentials to return.item
- the item.authentication
- the authentication (ifnull
assumeACL.SYSTEM2
.domainRequirements
- the credential domain to match.matcher
- the additional filtering to apply to the credentials- Returns:
- the
ListBoxModel
ofIdCredentials.getId()
with names provided byCredentialsNameProvider
. - Since:
- TODO
-
isApplicable
Returnstrue
if thisCredentialsProvider
can provide credentials of the supplied type.- Parameters:
clazz
- the base type ofCredentials
to check.- Returns:
true
if and only if there is at least oneCredentialsDescriptor
matching the requiredCredentials
interface thatisApplicable(Descriptor)
.- Since:
- 2.0
-
isApplicable
- Parameters:
descriptor
- theDescriptor
to check.- Returns:
true
if and only if the suppliedDescriptor
is applicable in thisCredentialsProvider
.- Since:
- 2.0
-
_isApplicable
CredentialsProvider
subtypes can override this method to veto someDescriptor
s from being available from their store. This is often useful when you are building a custom store that holds a specific type of credentials or where you want to limit the number of choices given to the users.- Parameters:
descriptor
- theDescriptor
to check.- Returns:
true
if the suppliedDescriptor
is applicable in thisCredentialsProvider
- Since:
- 2.0
-
getCredentialsDescriptors
Returns the list ofCredentialsDescriptor
instances that are applicable within thisCredentialsProvider
.- Returns:
- the list of
CredentialsDescriptor
instances that are applicable within thisCredentialsProvider
. - Since:
- 2.0
-
hasCredentialsDescriptors
public final boolean hasCredentialsDescriptors()Checks if there is at least oneCredentialsDescriptor
applicable within thisCredentialsProvider
.- Returns:
true
if and ony if there is at least oneCredentialsDescriptor
applicable within thisCredentialsProvider
.- Since:
- 2.0
-
getFingerprintOf
Retrieves theFingerprint
for a specific credential.- Parameters:
c
- the credential.- Returns:
- the
Fingerprint
ornull
if the credential has no fingerprint associated with it. - Throws:
IOException
- if the credential's fingerprint hash could not be computed.- Since:
- 2.1.1
-
getOrCreateFingerprintOf
@NonNull public static Fingerprint getOrCreateFingerprintOf(@NonNull Credentials c) throws IOException Creates a fingerprint that can be used to track the usage of a specific credential.- Parameters:
c
- the credential to fingerprint.- Returns:
- the Fingerprint.
- Throws:
IOException
- if the credential's fingerprint hash could not be computed.- Since:
- 2.1.1
-
track
@CheckForNull public static <C extends Credentials> C track(@NonNull Run build, @CheckForNull C credentials) Track the usage of credentials in a specific build.- Type Parameters:
C
- the credentials type.- Parameters:
build
- the run to tag the fingerprintcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
trackAll
@SafeVarargs @NonNull public static <C extends Credentials> List<C> trackAll(@NonNull Run build, C... credentials) Track the usage of credentials in a specific build.- Type Parameters:
C
- the credentials type.- Parameters:
build
- the run to tag the fingerprintcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
trackAll
@NonNull public static <C extends Credentials> List<C> trackAll(@NonNull Run build, @NonNull List<C> credentials) Track the usage of credentials in a specific build.- Type Parameters:
C
- the credentials type.- Parameters:
build
- the run to tag the fingerprintcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
track
@CheckForNull public static <C extends Credentials> C track(@NonNull Node node, @CheckForNull C credentials) Track the usage of credentials in a specific node. Would be used for example when launching an agent.- Type Parameters:
C
- the credentials type.- Parameters:
node
- the node to tag the fingerprintcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
trackAll
@SafeVarargs @NonNull public static <C extends Credentials> List<C> trackAll(@NonNull Node node, C... credentials) Track the usage of credentials in a specific node. Would be used for example when launching an agent.- Type Parameters:
C
- the credentials type.- Parameters:
node
- the node to tag the fingerprintcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
trackAll
@NonNull public static <C extends Credentials> List<C> trackAll(@NonNull Node node, @NonNull List<C> credentials) Track the usage of credentials in a specific node. Would be used for example when launching an agent.- Type Parameters:
C
- the credentials type.- Parameters:
node
- the node to tag the fingerprintcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
track
@CheckForNull public static <C extends Credentials> C track(@NonNull Item item, @CheckForNull C credentials) Track the usage of credentials in a specific item but not associated with a specific build, for example SCM polling.- Type Parameters:
C
- the credentials type.- Parameters:
item
- the item to tag the fingerprint againstcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
trackAll
@SafeVarargs @NonNull public static <C extends Credentials> List<C> trackAll(@NonNull Item item, C... credentials) Track the usage of credentials in a specific item but not associated with a specific build, for example SCM polling.- Type Parameters:
C
- the credentials type.- Parameters:
item
- the item to tag the fingerprint againstcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
trackAll
@NonNull public static <C extends Credentials> List<C> trackAll(@NonNull Item item, @NonNull List<C> credentials) Track the usage of credentials in a specific item but not associated with a specific build, for example SCM polling.- Type Parameters:
C
- the credentials type.- Parameters:
item
- the item to tag the fingerprint againstcredentials
- the credentials to fingerprint.- Returns:
- the supplied credentials for method chaining.
- Since:
- 2.1.1
-
saveAll
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void saveAll()A helper method for Groovy Scripting to address use cases such as JENKINS-39317 where all credential stores need to be resaved. As this is a potentially very expensive operation the method has been markedDoNotUse
in order to ensure that no plugin attempts to call this method. If invoking this method from aninit.d
Groovy script, ensure that the call is guarded by a marker file such that
-
findCredentialById(String, Class, Run, List)
instead.