Class McpBearerChallenge
WWW-Authenticate: Bearer ... challenge value (RFC 6750 §3, RFC
9728 §5.1) emitted by the 2026-07-28 MCP resource server on a 401.
Produces Bearer <k>="<v>", ... auth-params in the order added, so the emitted header parses cleanly on the
client side via org.apache.juneau.rest.client.mcp.auth.WwwAuthenticateChallenge (which lower-cases keys and
accepts quoted values). Auth-param values are sanitized for the RFC 7235 quoted-string grammar: control characters
(< 0x20 and 0x7F, including CR/LF that would otherwise enable header injection) are stripped, and
"/\ are backslash-escaped (\" / \\) rather than mangled.
Extensibility:
The baseline emits realm, error,
error_description, scope, and
resource_metadata. The generic param(String, String) seam lets a
later layer (SEP-2350 scoped step-up) add further auth-params without touching this class — this class
deliberately does not implement scope-accumulation/step-up.
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds theWWW-Authenticatechallenge value.static McpBearerChallengecreate()Static creator.Adds theerrorauth-param (e.g.errorDescription(String value) Adds theerror_descriptionauth-param.Adds an arbitrary auth-param — the extensibility seam for future challenge parameters.Adds therealmauth-param.resourceMetadata(URI value) Adds theresource_metadataauth-param (RFC 9728 §5.1) pointing at the PRM document.scope(Collection<String> scopes) Adds the space-delimitedscopeauth-param.toString()
-
Method Details
-
create
Static creator.- Returns:
- A new, empty challenge builder.
-
realm
Adds therealmauth-param.- Parameters:
value- The realm. Anull value is ignored.- Returns:
- This object (for method chaining).
-
error
Adds theerrorauth-param (e.g.invalid_token,insufficient_scope).- Parameters:
value- The error code. Anull value is ignored.- Returns:
- This object (for method chaining).
-
errorDescription
Adds theerror_descriptionauth-param.- Parameters:
value- The human-readable error description. Anull value is ignored.- Returns:
- This object (for method chaining).
-
scope
Adds the space-delimitedscopeauth-param.- Parameters:
scopes- The scopes. Anull or empty collection is ignored.- Returns:
- This object (for method chaining).
-
resourceMetadata
Adds theresource_metadataauth-param (RFC 9728 §5.1) pointing at the PRM document.- Parameters:
value- The PRM document URI. Anull value is ignored.- Returns:
- This object (for method chaining).
-
param
Adds an arbitrary auth-param — the extensibility seam for future challenge parameters.- Parameters:
name- The auth-param name. Must not benull or blank.value- The auth-param value. Anull value is ignored (the param is not added).- Returns:
- This object (for method chaining).
-
build
Builds theWWW-Authenticatechallenge value.- Returns:
- The header value (e.g.
Bearer realm="mcp", resource_metadata="https://host/.well-known/..."), or the bareBearerscheme when no auth-params were added.
-
toString
-