Class BearerTokenProvider

java.lang.Object
land.oras.auth.BearerTokenProvider
All Implemented Interfaces:
AuthProvider

@NullMarked public final class BearerTokenProvider extends Object implements AuthProvider
A provider for bearer token authentication
  • Constructor Details

    • BearerTokenProvider

      public BearerTokenProvider()
      Create a new bearer token provider
    • BearerTokenProvider

      public BearerTokenProvider(String token)
      Create a new bearer token provider
      Parameters:
      token - The token
  • Method Details

    • getToken

      public @Nullable HttpClient.TokenResponse getToken()
      Get the token
      Returns:
      The token
    • setToken

      public void setToken(HttpClient.TokenResponse token)
      Set the token
      Parameters:
      token - The token
    • getAuthHeader

      public @Nullable String getAuthHeader(ContainerRef registry)
      Description copied from interface: AuthProvider
      Get the authentication header for this provider
      Specified by:
      getAuthHeader in interface AuthProvider
      Parameters:
      registry - The registry
      Returns:
      The authentication header or null if not applicable
    • getAuthScheme

      public AuthScheme getAuthScheme()
      Description copied from interface: AuthProvider
      Get the authentication scheme for this provider
      Specified by:
      getAuthScheme in interface AuthProvider
      Returns:
      The authentication scheme
    • getIdentity

      public String getIdentity(ContainerRef registry)
      Description copied from interface: AuthProvider
      Get an opaque identity marker for the credentials this provider resolves for the given registry. This marker is used to key TokenCache entries alongside the requested Scopes
      Specified by:
      getIdentity in interface AuthProvider
      Parameters:
      registry - The registry
      Returns:
      A non-null identity marker