Class CredentialsDescriptor
- java.lang.Object
-
- hudson.model.Descriptor<Credentials>
-
- com.cloudbees.plugins.credentials.CredentialsDescriptor
-
- Direct Known Subclasses:
BaseStandardCredentials.BaseStandardCredentialsDescriptor
public abstract class CredentialsDescriptor extends Descriptor<Credentials> implements IconSpec
Descriptor for credentials.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CredentialsDescriptor.EnhancedCheckMethod
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
Constructors Modifier Constructor Description protected
CredentialsDescriptor()
Infers the type of the correspondingCredentials
from the outer class.protected
CredentialsDescriptor(Class<? extends Credentials> clazz)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calcAutoCompleteSettings(String field, Map<String,Object> attributes)
void
calcFillSettings(String field, Map<String,Object> attributes)
ListBoxModel
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).FormValidation.CheckMethod
getCheckMethod(String fieldName)
String
getCredentialsPage()
Returns the config page for the credentials.String
getIconClassName()
boolean
isApplicable(CredentialsProvider provider)
Determines if thisCredentialsDescriptor
is applicable to the specifiedCredentialsProvider
.boolean
isScopeRelevant()
Checks if asking for a credentials scope is relevant.boolean
isScopeRelevant(CredentialsSelectHelper.WrappedCredentialsStore wrapper)
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
isScopeRelevant(CredentialsStoreAction.CredentialsWrapper wrapper)
Similar toisScopeRelevant()
but used byCredentialsStoreAction
.boolean
isScopeRelevant(CredentialsStoreAction.DomainWrapper wrapper)
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 Detail
-
CredentialsDescriptor
protected CredentialsDescriptor(Class<? extends Credentials> clazz)
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 Detail
-
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
public String getCredentialsPage()
Returns the config page for the credentials.- Returns:
- the config page for the credentials.
-
getIconClassName
public String getIconClassName()
- Specified by:
getIconClassName
in interfaceIconSpec
- Since:
- 1.25
-
isApplicable
public boolean isApplicable(CredentialsProvider provider)
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
@NonNull public static ModelObject unwrapContext(@NonNull ModelObject context)
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
@CheckForNull public static ModelObject lookupContext(String provider, String token)
Looks up the context given the provider and token.- Parameters:
provider
- the provider.token
- the token.- Returns:
- the context.
- Since:
- 2.1.5
-
findContextInPath
@CheckForNull public static <T extends ModelObject> T findContextInPath(@NonNull 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).- 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
public FormValidation.CheckMethod getCheckMethod(String fieldName)
- Overrides:
getCheckMethod
in classDescriptor<Credentials>
-
calcFillSettings
public void calcFillSettings(String field, Map<String,Object> attributes)
- Overrides:
calcFillSettings
in classDescriptor<Credentials>
-
calcAutoCompleteSettings
public void calcAutoCompleteSettings(String field, Map<String,Object> attributes)
- Overrides:
calcAutoCompleteSettings
in classDescriptor<Credentials>
-
-