Class AuthenticationTokens

java.lang.Object
jenkins.authentication.tokens.api.AuthenticationTokens

public final class AuthenticationTokens extends Object
Utility class for manipulating authentication tokens.
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, C extends com.cloudbees.plugins.credentials.Credentials>
    T
    convert(Class<T> type, C credentials)
    Converts the supplied credentials into the specified token.
    static <T, C extends com.cloudbees.plugins.credentials.Credentials>
    T
    convert(AuthenticationTokenContext<T> context, C credentials)
    Converts the supplied credentials into the specified token.
    static <T, C extends com.cloudbees.plugins.credentials.Credentials>
    T
    convert(AuthenticationTokenContext<T> context, C... credentials)
    Converts the best match of the supplied credentials into the specified token.
    static <T, C extends com.cloudbees.plugins.credentials.Credentials>
    T
    convert(AuthenticationTokenContext<T> context, List<C> credentials)
    Converts the best match of the supplied credentials into the specified token.
    static <T> com.cloudbees.plugins.credentials.CredentialsMatcher
    matcher(Class<T> tokenClass)
    Builds a matcher for credentials that can be converted into the supplied token type.
    static <T> com.cloudbees.plugins.credentials.CredentialsMatcher
    Builds a matcher for credentials that can be converted into the supplied token type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • matcher

      public static <T> com.cloudbees.plugins.credentials.CredentialsMatcher matcher(Class<T> tokenClass)
      Builds a matcher for credentials that can be converted into the supplied token type.
      Type Parameters:
      T - the type of token
      Parameters:
      tokenClass - the type of token
      Returns:
      a matcher for the type of token
    • matcher

      public static <T> com.cloudbees.plugins.credentials.CredentialsMatcher matcher(AuthenticationTokenContext<T> context)
      Builds a matcher for credentials that can be converted into the supplied token type.
      Type Parameters:
      T - the type of token.
      Parameters:
      context - the context that an authentication token is required in.
      Returns:
      a matcher for the type of token.
      Since:
      1.2
    • convert

      @CheckForNull public static <T, C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull Class<T> type, @CheckForNull C credentials)
      Converts the supplied credentials into the specified token.
      Type Parameters:
      T - the type of token to convert to.
      C - the type of credentials to convert,
      Parameters:
      type - the type of token to convert to.
      credentials - the credentials instance to convert.
      Returns:
      the token or null if the credentials could not be converted.
    • convert

      @CheckForNull public static <T, C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull AuthenticationTokenContext<T> context, @CheckForNull C credentials)
      Converts the supplied credentials into the specified token.
      Type Parameters:
      T - the type of token to convert to.
      C - the type of credentials to convert,
      Parameters:
      context - the context that an authentication token is required in.
      credentials - the credentials instance to convert.
      Returns:
      the token or null if the credentials could not be converted.
      Since:
      1.2
    • convert

      @CheckForNull public static <T, C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull AuthenticationTokenContext<T> context, @NonNull C... credentials)
      Converts the best match of the supplied credentials into the specified token.
      Type Parameters:
      T - the type of token to convert to.
      C - the type of credentials to convert,
      Parameters:
      context - the context that an authentication token is required in.
      credentials - the credentials instances to try and convert.
      Returns:
      the token or null if the credentials could not be converted.
      Since:
      1.2
    • convert

      @CheckForNull public static <T, C extends com.cloudbees.plugins.credentials.Credentials> T convert(@NonNull AuthenticationTokenContext<T> context, @NonNull List<C> credentials)
      Converts the best match of the supplied credentials into the specified token.
      Type Parameters:
      T - the type of token to convert to.
      C - the type of credentials to convert,
      Parameters:
      context - the context that an authentication token is required in.
      credentials - the credentials instances to try and convert.
      Returns:
      the token or null if the credentials could not be converted.
      Since:
      1.2