public abstract class CredentialsDescriptor extends Descriptor<Credentials> implements org.jenkins.ui.icon.IconSpec
Modifier and Type | Class and Description |
---|---|
static class |
CredentialsDescriptor.EnhancedCheckMethod
An enhanced
FormValidation.CheckMethod that can add assistance for resolving the context from the
request path. |
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
clazz
Modifier | Constructor and Description |
---|---|
protected |
CredentialsDescriptor()
Infers the type of the corresponding
Credentials from the outer class. |
protected |
CredentialsDescriptor(Class<? extends Credentials> clazz)
Constructor.
|
Modifier and Type | Method and 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> |
findContextInPath(Class<T> type)
Attempts to resolve the credentials context from the
Stapler.getCurrentRequest() (includes special
handling of the HTTP Referer to enable resolution from AJAX requests). |
static <T extends ModelObject> |
findContextInPath(org.kohsuke.stapler.StaplerRequest request,
Class<T> type)
Attempts to resolve the credentials context from the
StaplerRequest (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 this
CredentialsDescriptor is applicable to the specified CredentialsProvider . |
boolean |
isScopeRelevant()
Checks if asking for a credentials scope is relevant.
|
boolean |
isScopeRelevant(CredentialsSelectHelper.WrappedCredentialsStore wrapper)
Similar to
isScopeRelevant() but used by CredentialsSelectHelper . |
boolean |
isScopeRelevant(CredentialsStore store)
Similar to
isScopeRelevant() but operating on a specific CredentialsStore rather than trying to
infer from the stapler request. |
boolean |
isScopeRelevant(CredentialsStoreAction.CredentialsWrapper wrapper)
Similar to
isScopeRelevant() but used by CredentialsStoreAction . |
boolean |
isScopeRelevant(CredentialsStoreAction.DomainWrapper wrapper)
Similar to
isScopeRelevant() but used by CredentialsStoreAction . |
boolean |
isScopeRelevant(ModelObject object)
Similar to
isScopeRelevant() but operating on a specific ModelObject 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 nearest
AncestorInPath ModelObject is one of the Credentials plugins wrapper
classes. |
addHelpFileRedirect, 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
protected CredentialsDescriptor(Class<? extends Credentials> clazz)
clazz
- The concrete credentials class.protected CredentialsDescriptor()
Credentials
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.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.1.5") public ListBoxModel doFillScopeItems(@ContextInPath ModelObject context)
context
- list-box context@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.1.5") public boolean isScopeRelevant()
UserCredentialsProvider
, there is no need to specify the scope,
as it can only be CredentialsScope.USER
, but where the credential will be stored in
SystemCredentialsProvider
, there are multiple scopes relevant for that container, so the scope
field is relevant.true
if the nearest request object that acts as a container for credentials needs a scope
to be specified.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.1.5") public boolean isScopeRelevant(ModelObject object)
isScopeRelevant()
but operating on a specific ModelObject
rather than trying to
infer from the stapler request.object
- the object that is going to contain the credential.true
if there is more than one CredentialsScope
that can be used for the specified
object.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScopeRelevant(@CheckForNull CredentialsStore store)
isScopeRelevant()
but operating on a specific CredentialsStore
rather than trying to
infer from the stapler request.store
- the object that is going to contain the credential.true
if there is more than one CredentialsScope
that can be used for the specified
object.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.1.5") public boolean isScopeRelevant(CredentialsStoreAction.DomainWrapper wrapper)
isScopeRelevant()
but used by CredentialsStoreAction
.wrapper
- the wrapper for the domain that is going to contain the credential.true
if there is more than one CredentialsScope
that can be used for the specified
object.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @RestrictedSince(value="2.1.5") public boolean isScopeRelevant(CredentialsStoreAction.CredentialsWrapper wrapper)
isScopeRelevant()
but used by CredentialsStoreAction
.wrapper
- the wrapper for the domain that is going to contain the credential.true
if there is more than one CredentialsScope
that can be used for the specified
object.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScopeRelevant(CredentialsSelectHelper.WrappedCredentialsStore wrapper)
isScopeRelevant()
but used by CredentialsSelectHelper
.wrapper
- the wrapper for the domain that is going to contain the credential.true
if there is more than one CredentialsScope
that can be used for the specified
object.public String getCredentialsPage()
public String getIconClassName()
getIconClassName
in interface org.jenkins.ui.icon.IconSpec
public boolean isApplicable(CredentialsProvider provider)
CredentialsDescriptor
is applicable to the specified CredentialsProvider
.
This method will be called by CredentialsProvider.isApplicable(Descriptor)
provider
- the CredentialsProvider
to check.true
if this CredentialsDescriptor
is applicable in the specified CredentialsProvider
@NonNull public static ModelObject unwrapContext(@NonNull ModelObject context)
AncestorInPath
ModelObject
is one of the Credentials plugins wrapper
classes.
This helper method unwraps those to return the correct context.context
- the context (wrapped or unwrapped).@CheckForNull public static ModelObject lookupContext(String provider, String token)
provider
- the provider.token
- the token.@CheckForNull public static <T extends ModelObject> T findContextInPath(@NonNull Class<T> type)
Stapler.getCurrentRequest()
(includes special
handling of the HTTP Referer to enable resolution from AJAX requests).T
- the type of context.type
- the type of context.@CheckForNull public static <T extends ModelObject> T findContextInPath(@NonNull org.kohsuke.stapler.StaplerRequest request, @NonNull Class<T> type)
StaplerRequest
(includes special
handling of the HTTP Referer to enable resolution from AJAX requests).T
- the type of context.request
- the StaplerRequest
.type
- the type of context.public FormValidation.CheckMethod getCheckMethod(String fieldName)
getCheckMethod
in class Descriptor<Credentials>
public void calcFillSettings(String field, Map<String,Object> attributes)
calcFillSettings
in class Descriptor<Credentials>
public void calcAutoCompleteSettings(String field, Map<String,Object> attributes)
calcAutoCompleteSettings
in class Descriptor<Credentials>
Copyright © 2016–2020. All rights reserved.