Class AuthorizationResponse

java.lang.Object
com.revetsec.oauth.AuthorizationResponse

@Immutable public final class AuthorizationResponse extends Object
A parsed browser authorization response. It preserves repeated parameters so a duplicate cannot be silently selected. Its delivery mode comes from the application route and method, never from callback data. Parsing does not authenticate the response; OAuthClient checks its pending state before trusting any error or code.
Since:
1.0.0
Author:
Mark Allen
  • Method Details

    • fromQueryStringResult

      Parses a raw URL query, without the question mark, keeping malformed input as a rejected result. A successful parse grants no identity and does not validate the pending authorization transaction.
      Parameters:
      rawQuery - the raw query
      Returns:
      the unverified callback or a fixed rejection reason
      Throws:
      NullPointerException - if rawQuery is null
      Since:
      1.0.0
    • fromFormBodyResult

      @CheckReturnValue public static @NonNull AuthorizationResponseParseResult fromFormBodyResult(byte @NonNull [] body, @NonNull Charset charset, @Nullable String rawQueryOrNull)
      Parses a UTF-8 form-post body. Protocol members in the query reject split-channel responses; safe nonprotocol query parameters remain untrusted extras. Invalid charset, encoding, size or parameters produce rejection.
      Parameters:
      body - the form bytes
      charset - the application's parsed Content-Type charset, which must be UTF-8
      rawQueryOrNull - the URL's raw query, if any
      Returns:
      the unverified callback or a fixed rejection reason
      Throws:
      NullPointerException - if body or charset is null
      Since:
      1.0.0
    • fromFormBodyResult

      @CheckReturnValue public static @NonNull AuthorizationResponseParseResult fromFormBodyResult(byte @NonNull [] body, @NonNull List<@NonNull String> contentTypeHeaderValues, @Nullable String rawQueryOrNull)
      Parses a form-post callback after validating every raw Content-Type occurrence. Requires exactly one form field with an absent or UTF-8 charset and no duplicate MIME parameters. The field is capped at 8,192 characters before MIME parsing. Preserve materialized duplicates; a trusted edge rejects physical fields discarded by a transport. Invalid MIME, body, duplicate parameters and split channels produce rejection.
      Parameters:
      body - the raw form bytes
      contentTypeHeaderValues - all materialized Content-Type values
      rawQueryOrNull - the raw URL query, if any
      Returns:
      the unverified callback or a fixed rejection reason
      Throws:
      NullPointerException - if body, header list or its sole field is null
      Since:
      1.0.0
    • fromParametersResult

      Accepts parameters from an application parser, retaining multiplicity and the explicit route mode. Malformed, duplicate, oversized or split-channel parameters produce rejection. Success remains unverified.
      Parameters:
      values - decoded parameters, with all values for each name
      rawQueryOrNull - the URL query when the mode is form-post, if any
      responseMode - mode established by trusted application routing
      Returns:
      the unverified callback or a fixed rejection reason
      Throws:
      NullPointerException - if values, a parameter name/list/value or responseMode is null
      Since:
      1.0.0
    • getCode

      Returns the code, if present and nonempty. It is untrusted until completion succeeds.
      Returns:
      the code
      Since:
      1.0.0
    • getState

      Returns the state, if present and nonempty.
      Returns:
      the state
      Since:
      1.0.0
    • getIssuer

      Returns the RFC 9207 issuer, if present and nonempty.
      Returns:
      the issuer
      Since:
      1.0.0
    • getError

      Returns an authorization error, if present and nonempty.
      Returns:
      the error
      Since:
      1.0.0
    • getErrorDescription

      Returns untrusted error prose, if present, with non-NQSCHAR characters replaced and at most 1,024 characters. Do not log it without application redaction. The raw value remains available in getParameters().
      Returns:
      the prose
      Since:
      1.0.0
    • getErrorUri

      Returns the absolute error URI, if present and nonempty. Parsing rejects a malformed supplied URI. This is untrusted provider data with no navigation, scheme or destination authorization. Never automatically redirect, fetch or render it as active content. Applications choosing to expose a link must apply their own exact HTTPS destination allowlist and safe HTML rendering.
      Returns:
      the URI
      Since:
      1.0.0
    • getParameters

      Returns every decoded parameter, including unsigned provider extras.
      Returns:
      immutable parameter lists
      Since:
      1.0.0
    • getResponseMode

      Returns the callback mode established by trusted application routing.
      Returns:
      the mode
      Since:
      1.0.0
    • getPerFlowCookieName

      Returns the optional per-flow cookie name derived from state. The suffix is a selector, not an authenticator.
      Returns:
      the cookie name when nonempty state is present
      Since:
      1.0.0
    • toString

      Redacts all callback parameters.
      Overrides:
      toString in class Object
      Returns:
      a redacted description
      Since:
      1.0.0