Class McpAuthorizationCodeAcquirer.Builder
- Enclosing class:
- McpAuthorizationCodeAcquirer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthorizationEndpoint(URI value) Sets the authorization endpoint URL.browserLauncher(Consumer<URI> value) Sets the callback invoked with the authorization URL so the caller can open it in a browser (or print it).build()Builds the acquirer.Sets the OAuth client ID.clientSecret(String value) Sets the client secret (omit for a public/native PKCE-only client).expectedIssuer(URI value) Sets the expected issuer the callbackissparameter is validated against (SEP-2468).httpRequestConfigurator(Consumer<com.nimbusds.oauth2.sdk.http.HTTPRequest> value) Sets a callback that customizes the NimbusHTTPRequestfor the token exchange.httpTimeout(Duration value) Sets the connect/read timeout applied to the token-exchange request.offlineAccess(boolean value) Requests theoffline_accessscope so the IdP issues a refresh token (SEP-2207).redirectPath(String value) Sets the loopback redirect path.redirectPort(int value) Sets a fixed loopback redirect port so the receiver binds exactly that port (the "bind-first" strategy for strict exact-match authorization servers).requireIssuerResponseParameter(boolean value) Requires the authorization response to carry anissparameter, rejecting a response that omits it.Sets the RFC 8707resourceindicator (the canonical MCP server URI).Adds requested scopes.skipIssuerValidation(boolean value) Explicitly opts out of the SEP-2468issvalidation.store(EphemeralStore value) Sets the ephemeral state/verifier store.tokenEndpoint(URI value) Sets the token endpoint URL.
-
Constructor Details
-
Builder
protected Builder()Constructor.
-
-
Method Details
-
authorizationEndpoint
Sets the authorization endpoint URL. Required.- Parameters:
value- The endpoint URL.- Returns:
- This object.
-
tokenEndpoint
Sets the token endpoint URL. Required.- Parameters:
value- The endpoint URL.- Returns:
- This object.
-
clientId
Sets the OAuth client ID. Required.- Parameters:
value- The client ID.- Returns:
- This object.
-
clientSecret
Sets the client secret (omit for a public/native PKCE-only client).- Parameters:
value- The client secret.- Returns:
- This object.
-
scope
Adds requested scopes.- Parameters:
values- The scopes.- Returns:
- This object.
-
offlineAccess
Requests theoffline_accessscope so the IdP issues a refresh token (SEP-2207).- Parameters:
value-true to addoffline_access.- Returns:
- This object.
-
resource
Sets the RFC 8707resourceindicator (the canonical MCP server URI).- Parameters:
value- The canonical resource URI. Must not benull .- Returns:
- This object.
-
expectedIssuer
Sets the expected issuer the callbackissparameter is validated against (SEP-2468).Typically the
issuerreturned byOidcDiscoveryClientfor the discovered authorization server.- Parameters:
value- The expected issuer. Must not benull .- Returns:
- This object.
-
skipIssuerValidation
Explicitly opts out of the SEP-2468issvalidation.issvalidation is on by default;build()requiresexpectedIssuer(URI)unless this is set totrue . Only disable this against an authorization server known not to emitiss.- Parameters:
value-true to skip theisscheck.- Returns:
- This object.
-
requireIssuerResponseParameter
Requires the authorization response to carry anissparameter, rejecting a response that omits it.Set this when the discovered authorization-server metadata advertises
authorization_response_iss_parameter_supported(RFC 9207); seeOidcMetadata.authorizationResponseIssParameterSupported().- Parameters:
value-true to reject a response with noissparameter.- Returns:
- This object.
-
redirectPath
Sets the loopback redirect path. Default/callback.- Parameters:
value- The path (must start with/). Must not benull or blank.- Returns:
- This object.
-
redirectPort
Sets a fixed loopback redirect port so the receiver binds exactly that port (the "bind-first" strategy for strict exact-match authorization servers).Defaults to
0, meaning an ephemeral port (the RFC 8252 §7.3 port-agnostic strategy) — the simplest interoperable choice. Set a non-zero port only when the authorization server registration used a bind-firstforPortredirect;McpClientRegistrations.configure(org.apache.juneau.rest.client.mcp.auth.McpAuthorizationCodeAcquirer.Builder, org.apache.juneau.rest.client.mcp.auth.McpClientRegistration)wires this automatically from such a registration.- Parameters:
value- The fixed loopback port in1..65535, or0for an ephemeral port.- Returns:
- This object.
-
browserLauncher
Sets the callback invoked with the authorization URL so the caller can open it in a browser (or print it).- Parameters:
value- The launcher. Must not benull .- Returns:
- This object.
-
store
Sets the ephemeral state/verifier store. Defaults to a freshEphemeralStore.- Parameters:
value- The store. Must not benull .- Returns:
- This object.
-
httpTimeout
Sets the connect/read timeout applied to the token-exchange request. Default 10 seconds.- Parameters:
value- The timeout. Must not benull and must be positive.- Returns:
- This object.
-
httpRequestConfigurator
public McpAuthorizationCodeAcquirer.Builder httpRequestConfigurator(Consumer<com.nimbusds.oauth2.sdk.http.HTTPRequest> value) Sets a callback that customizes the NimbusHTTPRequestfor the token exchange.- Parameters:
value- The callback. Must not benull .- Returns:
- This object.
-
build
Builds the acquirer.- Returns:
- A new
McpAuthorizationCodeAcquirer.
-