Class OAuthClient

java.lang.Object
com.revetsec.oauth.OAuthClient

@ThreadSafe public final class OAuthClient extends Object
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
  • 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

      Starts a client with manually supplied metadata; build validates every known endpoint.
      Parameters:
      metadata - metadata
      Returns:
      the builder
      Since:
      1.0.0
    • warmUp

      public void 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

      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

      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 callback
      source - browser-bound pending source
      actualCallbackUri - receiving route URI from trusted routing configuration
      Returns:
      the completion outcome
      Since:
      1.0.0
    • requestClientCredentialsResult

      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

      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 credential
      options - per-request scope and resources
      Returns:
      the token-request outcome
      Since:
      1.0.0
    • revokeResult

      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 revoke
      hint - token type hint
      Returns:
      the revocation outcome
      Since:
      1.0.0
    • toString

      Redacts client configuration and credentials.
      Overrides:
      toString in class Object
      Returns:
      a redacted description
      Since:
      1.0.0