Class CredentialsDescriptor

java.lang.Object
hudson.model.Descriptor<Credentials>
com.cloudbees.plugins.credentials.CredentialsDescriptor
All Implemented Interfaces:
Saveable, OnMaster, IconSpec
Direct Known Subclasses:
BaseStandardCredentials.BaseStandardCredentialsDescriptor

public abstract class CredentialsDescriptor extends Descriptor<Credentials> implements IconSpec
Descriptor for credentials.
  • Constructor Details

    • 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 corresponding 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.
      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 in 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.
      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 to isScopeRelevant() but operating on a specific ModelObject 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 one CredentialsScope that can be used for the specified object.
    • isScopeRelevant

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScopeRelevant(@CheckForNull CredentialsStore store)
      Similar to isScopeRelevant() but operating on a specific CredentialsStore 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 one CredentialsScope 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)
      Parameters:
      wrapper - the wrapper for the domain that is going to contain the credential.
      Returns:
      true if there is more than one CredentialsScope 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)
      Parameters:
      wrapper - the wrapper for the domain that is going to contain the credential.
      Returns:
      true if there is more than one CredentialsScope that can be used for the specified object.
    • isScopeRelevant

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isScopeRelevant(CredentialsSelectHelper.WrappedCredentialsStore wrapper)
      Parameters:
      wrapper - the wrapper for the domain that is going to contain the credential.
      Returns:
      true if there is more than one CredentialsScope 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 interface IconSpec
      Since:
      1.25
    • isApplicable

      public boolean isApplicable(CredentialsProvider provider)
      Determines if this CredentialsDescriptor is applicable to the specified CredentialsProvider.

      This method will be called by CredentialsProvider.isApplicable(Descriptor)

      Parameters:
      provider - the CredentialsProvider to check.
      Returns:
      true if this CredentialsDescriptor is applicable in the specified CredentialsProvider
      Since:
      2.0
    • unwrapContext

      @NonNull public static ModelObject unwrapContext(@NonNull ModelObject context)
      In some cases the nearest AncestorInPath 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 the Stapler.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 the StaplerRequest (includes special handling of the HTTP Referer to enable resolution from AJAX requests).
      Type Parameters:
      T - the type of context.
      Parameters:
      request - the StaplerRequest.
      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 class Descriptor<Credentials>
    • calcFillSettings

      public void calcFillSettings(String field, Map<String,Object> attributes)
      Overrides:
      calcFillSettings in class Descriptor<Credentials>
    • calcAutoCompleteSettings

      public void calcAutoCompleteSettings(String field, Map<String,Object> attributes)
      Overrides:
      calcAutoCompleteSettings in class Descriptor<Credentials>