Class AuthenticationTokenSource<T,​C extends com.cloudbees.plugins.credentials.Credentials>

  • All Implemented Interfaces:
    ExtensionPoint

    public abstract class AuthenticationTokenSource<T,​C extends com.cloudbees.plugins.credentials.Credentials>
    extends Object
    implements ExtensionPoint
    Converts Credentials into authentication tokens
    Since:
    1.0
    • Constructor Detail

      • AuthenticationTokenSource

        protected AuthenticationTokenSource​(Class<T> tokenClass,
                                            Class<C> credentialsClass)
        Constructor.
        Parameters:
        tokenClass - the type of token produced.
        credentialsClass - the type of credentials consumed.
    • Method Detail

      • convert

        @NonNull
        public abstract T convert​(@NonNull
                                  C credential)
                           throws AuthenticationTokenException
        Converts the specified credentials into a token.
        Parameters:
        credential - the credentials to convert.
        Returns:
        the corresponding token.
        Throws:
        AuthenticationTokenException - if the specific credentials could not be converted.
      • matcher

        @NonNull
        @OverrideMustInvoke(ANYTIME)
        public com.cloudbees.plugins.credentials.CredentialsMatcher matcher()
        Produces a CredentialsMatcher for this specific AuthenticationTokenSource. Implementations only need to override this method when they can only process a sub-set of the credential class that they convert. For example if UsernamePasswordCredentials are converted into a specific authentication token, but only for those cases where there is a password and the username is between 3 and 8 lowercase letters then the specific source implementation would likely override this method and return a more specific CredentialsMatcher in order to avoid convert(Credentials) having to throw an AuthenticationTokenException.
        Returns:
        the CredentialsMatcher for this source.
      • produces

        public final <T> boolean produces​(@NonNull
                                          Class<T> tokenClass)
        Checks if this source produces the specified token type.
        Type Parameters:
        T - the token type.
        Parameters:
        tokenClass - the token type.
        Returns:
        true if and only if this source can produce tokens of the specified type.
      • consumes

        public final <C extends com.cloudbees.plugins.credentials.Credentials> boolean consumes​(@NonNull
                                                                                                Class<C> credentialsClass)
        Checks if this source consumes Credentials of the specified type.
        Type Parameters:
        C - the credential type.
        Parameters:
        credentialsClass - the credential type.
        Returns:
        true if and only if this source can consume credentials of the specified type.
      • consumes

        public final boolean consumes​(@NonNull
                                      com.cloudbees.plugins.credentials.Credentials credentials)
        Checks if this source consumes the specific Credentials instance.
        Parameters:
        credentials - the credentials.
        Returns:
        true if and only if this source can consume credentials of the specified type.
      • fits

        public final boolean fits​(AuthenticationTokenContext<?> context)
        Checks if this source fits the specified context.
        Parameters:
        context - the context that an authentication token is required in.
        Returns:
        true if and only if this source fits the specified context.
        Since:
        1.2
      • isFit

        protected boolean isFit​(AuthenticationTokenContext<? super T> context)
        Checks if this source fits the specified context, override this method
        Parameters:
        context - the context that an authentication token is required in.
        Returns:
        true if and only if this source fits the specified context.
        Since:
        1.2