Class OAuthClient
java.lang.Object
com.revetsec.oauth.OAuthClient
OAuth 2.0 authorization-code, client-credentials, refresh and revocation client. Code authorization always uses
fresh PKCE S256. Discovery is lazy; constructing a client does no network I/O and starts no thread. Browser
callbacks must be supplied with a pending source and the exact callback URI selected by trusted application
routing, never reconstructed from request headers. Tokens are raw credentials, not verified identity results.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfigures an OAuth client. -
Method Summary
Modifier and TypeMethodDescriptionStarts a browser code flow with client-default scopes and resources.Starts a browser code flow with per-request options.completeAuthorizationResult(@NonNull AuthorizationResponse response, @NonNull PendingAuthorizationSource source, @NonNull URI actualCallbackUri) Completes the flow once, returning endpoint tokens, a checked authorization error, a local callback security rejection, an endpoint client rejection, or a fixed pending-store failure.refreshResult(@NonNull RefreshToken refreshToken, @NonNull TokenRequestOptions options) Sends one refresh POST and returns issued tokens or a fixed endpoint client rejection.Requests one client-credentials token and returns issued tokens or a fixed endpoint client rejection.revokeResult(@NonNull String token, @NonNull TokenTypeHint hint) Sends one RFC 7009 revocation POST and returns acceptance or a fixed endpoint client rejection.toString()Redacts client configuration and credentials.voidwarmUp()Loads metadata now, under the same cache and deadline policy as normal use.static @NonNull OAuthClient.BuilderStarts a client with manually supplied metadata; build validates every known endpoint.static @NonNull OAuthClient.BuilderwithIssuer(@NonNull String issuer) Starts a client with lazy RFC 8414 then OIDC discovery.
-
Method Details
-
withIssuer
Starts a client with lazy RFC 8414 then OIDC discovery.- Parameters:
issuer- exact configured issuer URI- Returns:
- the builder
- Since:
- 1.0.0
-
withAuthorizationServerMetadata
public static @NonNull OAuthClient.Builder withAuthorizationServerMetadata(@NonNull AuthorizationServerMetadata metadata) Starts a client with manually supplied metadata; build validates every known endpoint.- Parameters:
metadata- metadata- Returns:
- the builder
- Since:
- 1.0.0
-
warmUp
Loads metadata now, under the same cache and deadline policy as normal use. A static client does no I/O.- Since:
- 1.0.0
-
beginAuthorization
Starts a browser code flow with client-default scopes and resources.- Returns:
- the redirect and pending authorization
- Since:
- 1.0.0
-
beginAuthorization
public @NonNull AuthorizationRedirect beginAuthorization(@NonNull AuthorizationRequestOptions options) Starts a browser code flow with per-request options. It may perform lazy discovery.- Parameters:
options- the options- Returns:
- the redirect and pending authorization
- Since:
- 1.0.0
-
completeAuthorizationResult
@CheckReturnValue public @NonNull AuthorizationCompletionResult completeAuthorizationResult(@NonNull AuthorizationResponse response, @NonNull PendingAuthorizationSource source, @NonNull URI actualCallbackUri) Completes the flow once, returning endpoint tokens, a checked authorization error, a local callback security rejection, an endpoint client rejection, or a fixed pending-store failure. Metadata, transport, malformed responses and transient endpoint failures remain exceptions. Clear the pending cookie on every outcome. Atomic consumption and replay behavior are preserved: local checks precede I/O and an atomic store supplies client-side single use.- Parameters:
response- parsed callbacksource- browser-bound pending sourceactualCallbackUri- receiving route URI from trusted routing configuration- Returns:
- the completion outcome
- Since:
- 1.0.0
-
requestClientCredentialsResult
@CheckReturnValue public @NonNull OAuthTokenRequestResult requestClientCredentialsResult(@NonNull TokenRequestOptions options) Requests one client-credentials token and returns issued tokens or a fixed endpoint client rejection. A public client cannot use this grant. Transport, metadata, malformed responses and transient endpoint failures remain exceptions. No request is automatically retried.- Parameters:
options- scope, resource and safe additional form options- Returns:
- the token-request outcome
- Since:
- 1.0.0
-
refreshResult
@CheckReturnValue public @NonNull OAuthTokenRequestResult refreshResult(@NonNull RefreshToken refreshToken, @NonNull TokenRequestOptions options) Sends one refresh POST and returns issued tokens or a fixed endpoint client rejection. The caller restricts scopes to the original grant and retains the old refresh token when no replacement is returned. Transport, metadata, malformed responses and transient endpoint failures remain exceptions. No request is retried.- Parameters:
refreshToken- current refresh credentialoptions- per-request scope and resources- Returns:
- the token-request outcome
- Since:
- 1.0.0
-
revokeResult
@CheckReturnValue public @NonNull OAuthRevocationResult revokeResult(@NonNull String token, @NonNull TokenTypeHint hint) Sends one RFC 7009 revocation POST and returns acceptance or a fixed endpoint client rejection. A 200 response also accepts unknown tokens, and its body is ignored. Transport, metadata, malformed responses and transient endpoint failures remain exceptions. No request is automatically retried.- Parameters:
token- token to revokehint- token type hint- Returns:
- the revocation outcome
- Since:
- 1.0.0
-
toString
-