Class AuthenticationTokenContext<T>

java.lang.Object
jenkins.authentication.tokens.api.AuthenticationTokenContext<T>
Type Parameters:
T - the type of token

@ThreadSafe public final class AuthenticationTokenContext<T> extends Object
The context within which an authentication token will be used.
Since:
1.2
  • Constructor Details

    • AuthenticationTokenContext

      public AuthenticationTokenContext(@NonNull Class<T> tokenClass)
      Creates a basic context for any purpose.
      Parameters:
      tokenClass - the type of token.
  • Method Details

    • builder

      public static <T> AuthenticationTokenContext.Builder<T> builder(@NonNull Class<T> tokenClass)
      Creates a AuthenticationTokenContext.Builder for contexts of the specified token type.
      Type Parameters:
      T - the type of token.
      Parameters:
      tokenClass - the type of token.
      Returns:
      a AuthenticationTokenContext.Builder instance.
    • getTokenClass

      @NonNull public Class<T> getTokenClass()
      Returns the type of token.
      Returns:
      the type of token.
    • canHave

      public boolean canHave(@NonNull Object purpose, Object... validValues)
      Checks if the context specifies the supplied purpose and matches against the valid values.
      Parameters:
      purpose - the purpose.
      validValues - the valid values that the purpose must match if specified.
      Returns:
      true if either the purpose is not specified or the purpose is specified and is equal to one of the specified values.
    • mustHave

      public boolean mustHave(@NonNull Object purpose, Object... validValues)
      Ensures the context specifies the supplied purpose matching against the valid values.
      Parameters:
      purpose - the purpose.
      validValues - the valid values that the purpose must match.
      Returns:
      true if and only if the purpose is specified and is equal to one of the specified values.