Class CredentialsDescriptor
- Direct Known Subclasses:
BaseStandardCredentials.BaseStandardCredentialsDescriptor
Descriptor for credentials.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An enhancedFormValidation.CheckMethod
that can add assistance for resolving the context from the request path.Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
Field Summary
Fields inherited from class hudson.model.Descriptor
clazz
-
Constructor Summary
ModifierConstructorDescriptionprotected
Infers the type of the correspondingCredentials
from the outer class.protected
CredentialsDescriptor
(Class<? extends Credentials> clazz) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
calcAutoCompleteSettings
(String field, Map<String, Object> attributes) void
calcFillSettings
(String field, Map<String, Object> attributes) doFillScopeItems
(ModelObject context) Fills in the scopes for a scope list-box.static <T extends ModelObject>
TfindContextInPath
(Class<T> type) Attempts to resolve the credentials context from theStapler.getCurrentRequest()
(includes special handling of the HTTP Referer to enable resolution from AJAX requests).static <T extends ModelObject>
TfindContextInPath
(org.kohsuke.stapler.StaplerRequest request, Class<T> type) Attempts to resolve the credentials context from theStaplerRequest
(includes special handling of the HTTP Referer to enable resolution from AJAX requests).getCheckMethod
(String fieldName) Returns the config page for the credentials.boolean
isApplicable
(CredentialsProvider provider) Determines if thisCredentialsDescriptor
is applicable to the specifiedCredentialsProvider
.boolean
Checks if asking for a credentials scope is relevant.boolean
Similar toisScopeRelevant()
but used byCredentialsSelectHelper
.boolean
isScopeRelevant
(CredentialsStore store) Similar toisScopeRelevant()
but operating on a specificCredentialsStore
rather than trying to infer from the stapler request.boolean
Similar toisScopeRelevant()
but used byCredentialsStoreAction
.boolean
Similar toisScopeRelevant()
but used byCredentialsStoreAction
.boolean
isScopeRelevant
(ModelObject object) Similar toisScopeRelevant()
but operating on a specificModelObject
rather than trying to infer from the stapler request.static ModelObject
lookupContext
(String provider, String token) Looks up the context given the provider and token.static ModelObject
unwrapContext
(ModelObject context) In some cases the nearestAncestorInPath
ModelObject
is one of the Credentials plugins wrapper classes.Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getDisplayName, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Constructor Details
-
CredentialsDescriptor
Constructor.- Parameters:
clazz
- The concrete credentials class.- Since:
- 1.2
-
CredentialsDescriptor
protected CredentialsDescriptor()Infers the type of the correspondingCredentials
from the outer class. This version works when you follow the common convention, where a descriptor is written as the static nested class of the describable class.- Since:
- 1.3
-
-
Method Details
-
doFillScopeItems
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.1.5") public ListBoxModel doFillScopeItems(@ContextInPath ModelObject context) Fills in the scopes for a scope list-box.- Parameters:
context
- list-box context- Returns:
- the scopes for the nearest request object that acts as a container for credentials.
-
isScopeRelevant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.1.5") public boolean isScopeRelevant()Checks if asking for a credentials scope is relevant. For example, when a scope will be stored inUserCredentialsProvider
, there is no need to specify the scope, as it can only beCredentialsScope.USER
, but where the credential will be stored inSystemCredentialsProvider
, there are multiple scopes relevant for that container, so the scope field is relevant.- Returns:
true
if the nearest request object that acts as a container for credentials needs a scope to be specified.
-
isScopeRelevant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.1.5") public boolean isScopeRelevant(ModelObject object) Similar toisScopeRelevant()
but operating on a specificModelObject
rather than trying to infer from the stapler request.- Parameters:
object
- the object that is going to contain the credential.- Returns:
true
if there is more than oneCredentialsScope
that can be used for the specified object.
-
isScopeRelevant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScopeRelevant(@CheckForNull CredentialsStore store) Similar toisScopeRelevant()
but operating on a specificCredentialsStore
rather than trying to infer from the stapler request.- Parameters:
store
- the object that is going to contain the credential.- Returns:
true
if there is more than oneCredentialsScope
that can be used for the specified object.- Since:
- 2.1.5
-
isScopeRelevant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.1.5") public boolean isScopeRelevant(CredentialsStoreAction.DomainWrapper wrapper) Similar toisScopeRelevant()
but used byCredentialsStoreAction
.- Parameters:
wrapper
- the wrapper for the domain that is going to contain the credential.- Returns:
true
if there is more than oneCredentialsScope
that can be used for the specified object.
-
isScopeRelevant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince("2.1.5") public boolean isScopeRelevant(CredentialsStoreAction.CredentialsWrapper wrapper) Similar toisScopeRelevant()
but used byCredentialsStoreAction
.- Parameters:
wrapper
- the wrapper for the domain that is going to contain the credential.- Returns:
true
if there is more than oneCredentialsScope
that can be used for the specified object.
-
isScopeRelevant
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScopeRelevant(CredentialsSelectHelper.WrappedCredentialsStore wrapper) Similar toisScopeRelevant()
but used byCredentialsSelectHelper
.- Parameters:
wrapper
- the wrapper for the domain that is going to contain the credential.- Returns:
true
if there is more than oneCredentialsScope
that can be used for the specified object.- Since:
- 2.1.5
-
getCredentialsPage
Returns the config page for the credentials.- Returns:
- the config page for the credentials.
-
getIconClassName
- Specified by:
getIconClassName
in interfaceIconSpec
- Since:
- 1.25
-
isApplicable
Determines if thisCredentialsDescriptor
is applicable to the specifiedCredentialsProvider
.This method will be called by
CredentialsProvider.isApplicable(Descriptor)
- Parameters:
provider
- theCredentialsProvider
to check.- Returns:
true
if thisCredentialsDescriptor
is applicable in the specifiedCredentialsProvider
- Since:
- 2.0
-
unwrapContext
In some cases the nearestAncestorInPath
ModelObject
is one of the Credentials plugins wrapper classes. This helper method unwraps those to return the correct context.- Parameters:
context
- the context (wrapped or unwrapped).- Returns:
- the unwrapped context.
- Since:
- 2.1.5
-
lookupContext
Looks up the context given the provider and token.- Parameters:
provider
- the provider.token
- the token.- Returns:
- the context.
- Since:
- 2.1.5
-
findContextInPath
Attempts to resolve the credentials context from theStapler.getCurrentRequest()
(includes special handling of the HTTP Referer to enable resolution from AJAX requests).- Type Parameters:
T
- the type of context.- Parameters:
type
- the type of context.- Returns:
- the context from the request
- Since:
- 2.1.5
-
findContextInPath
@CheckForNull public static <T extends ModelObject> T findContextInPath(@NonNull org.kohsuke.stapler.StaplerRequest request, @NonNull Class<T> type) Attempts to resolve the credentials context from theStaplerRequest
(includes special handling of the HTTP Referer to enable resolution from AJAX requests).- Type Parameters:
T
- the type of context.- Parameters:
request
- theStaplerRequest
.type
- the type of context.- Returns:
- the context from the request
- Since:
- 2.1.5
-
getCheckMethod
- Overrides:
getCheckMethod
in classDescriptor<Credentials>
-
calcFillSettings
- Overrides:
calcFillSettings
in classDescriptor<Credentials>
-
calcAutoCompleteSettings
- Overrides:
calcAutoCompleteSettings
in classDescriptor<Credentials>
-