Class AuthChallenge

java.lang.Object
com.salesforce.multicloudj.registry.driver.AuthChallenge

public final class AuthChallenge extends Object
Parses HTTP WWW-Authenticate header to determine authentication requirements. Supports both Basic and Bearer authentication schemes. Also supports anonymous access when no authentication is required.
  • Method Details

    • anonymous

      public static AuthChallenge anonymous()
      Creates an AuthChallenge representing anonymous access (no auth required).
      Returns:
      an anonymous AuthChallenge
    • discover

      public static AuthChallenge discover(org.apache.http.impl.client.CloseableHttpClient httpClient, String registryEndpoint)
      Discovers authentication requirements by pinging the registry. Sends GET /v2/ and parses the WWW-Authenticate header from 401 response.
      Parameters:
      httpClient - the HTTP client to use for the request
      registryEndpoint - the registry base URL
      Returns:
      AuthChallenge describing the authentication requirements (including anonymous)
      Throws:
      UnAuthorizedException - if registry returns 401 without WWW-Authenticate header
      UnknownException - if the request fails or registry returns an unexpected status
    • parse

      public static AuthChallenge parse(String header)
      Parses a WWW-Authenticate header value.
      Parameters:
      header - the WWW-Authenticate header value
      Returns:
      parsed AuthChallenge
      Throws:
      UnknownException - if the header is empty
      InvalidArgumentException - if the header uses an unsupported authentication scheme
    • isBearer

      public boolean isBearer()
      Returns true if this is a Bearer authentication challenge.
    • getScheme

      public AuthScheme getScheme()
      The authentication scheme (ANONYMOUS, BASIC, or BEARER).
    • getRealm

      public String getRealm()
      The realm URL for token exchange (Bearer auth).
    • getService

      public String getService()
      The service identifier.
    • getScope

      public String getScope()
      The requested scope.