Class CredentialsDescriptor

    • 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 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 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 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
      • getCredentialsPage

        public String getCredentialsPage()
        Returns the config page for the credentials.
        Returns:
        the config page for the credentials.
      • 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