Class AuthChallenge
java.lang.Object
com.salesforce.multicloudj.registry.driver.AuthChallenge
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 Summary
Modifier and TypeMethodDescriptionstatic AuthChallengeCreates an AuthChallenge representing anonymous access (no auth required).static AuthChallengeDiscovers authentication requirements by pinging the registry.getRealm()The realm URL for token exchange (Bearer auth).The authentication scheme (ANONYMOUS, BASIC, or BEARER).getScope()The requested scope.The service identifier.booleanisBearer()Returns true if this is a Bearer authentication challenge.static AuthChallengeParses a WWW-Authenticate header value.
-
Method Details
-
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 requestregistryEndpoint- the registry base URL- Returns:
- AuthChallenge describing the authentication requirements (including anonymous)
- Throws:
UnAuthorizedException- if registry returns 401 without WWW-Authenticate headerUnknownException- if the request fails or registry returns an unexpected status
-
parse
Parses a WWW-Authenticate header value.- Parameters:
header- the WWW-Authenticate header value- Returns:
- parsed AuthChallenge
- Throws:
UnknownException- if the header is emptyInvalidArgumentException- if the header uses an unsupported authentication scheme
-
isBearer
public boolean isBearer()Returns true if this is a Bearer authentication challenge. -
getScheme
The authentication scheme (ANONYMOUS, BASIC, or BEARER). -
getRealm
The realm URL for token exchange (Bearer auth). -
getService
The service identifier. -
getScope
The requested scope.
-