Class WwwAuthenticateChallenge
java.lang.Object
org.apache.juneau.rest.client.mcp.auth.WwwAuthenticateChallenge
- All Implemented Interfaces:
Serializable
A parsed
WWW-Authenticate: Bearer ... challenge as returned by an OAuth 2.1 / MCP resource server on a
401/403 response (RFC 6750 §3, RFC 9728 §5.1).
The MCP client uses this to recover the resource_metadata pointer to the RFC 9728 PRM document, the
per-operation scope on a step-up challenge, and the error code. Auth-param values are matched
case-insensitively on the key per RFC 7235.
Serializable (it is just a scheme string plus an immutable string map) so it can ride along a serialized
McpInsufficientScopeException without being dropped.
- Since:
- 10.0.0
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWwwAuthenticateChallenge(String scheme, Map<String, String> parameters) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionerror()Returns theerrorcode (e.g.booleanisBearer()Returns whether the scheme isBearer(case-insensitive).Returns the raw value of an auth-param.Returns the parsed auth-params (lower-cased keys).static Optional<WwwAuthenticateChallenge>Parses a singleWWW-Authenticateheader value.Returns theresource_metadatapointer (RFC 9728 §5.1) to the PRM document.scheme()Returns the auth scheme.scopes()Returns the space-delimitedscopeparam as an order-preserving set.
-
Constructor Details
-
WwwAuthenticateChallenge
Constructor.- Parameters:
scheme- The auth scheme (e.g."Bearer"). Must not benull or blank.parameters- The auth-params (lower-cased keys). Must not benull .
-
-
Method Details
-
parse
Parses a singleWWW-Authenticateheader value.Recognizes a single challenge of the form
<scheme> <key>=<value>, <key>="<value>", .... Both quoted and bare token values are accepted; commas inside quoted values are preserved.- Parameters:
headerValue- The raw header value. May benull or blank.- Returns:
- The parsed challenge, or
Optional.empty()if the value is null/blank or has no scheme token.
-
scheme
Returns the auth scheme.- Returns:
- The scheme (e.g.
"Bearer"). Nevernull.
-
isBearer
Returns whether the scheme isBearer(case-insensitive).- Returns:
true if this is a Bearer challenge.
-
parameters
Returns the parsed auth-params (lower-cased keys).- Returns:
- An unmodifiable map. Never
null.
-
parameter
Returns the raw value of an auth-param.- Parameters:
name- The param name (matched case-insensitively). Must not benull .- Returns:
- The value, or
Optional.empty()if absent.
-
resourceMetadata
Returns theresource_metadatapointer (RFC 9728 §5.1) to the PRM document.- Returns:
- The PRM document URI, or
Optional.empty()if absent or unparseable as a URI.
-
error
Returns theerrorcode (e.g."insufficient_scope"), if present.- Returns:
- The error code, or
Optional.empty().
-
scopes
Returns the space-delimitedscopeparam as an order-preserving set.- Returns:
- The challenged scopes (empty if the param is absent or blank). Never
null.
-