Class ProxyAuthenticate.Builder

java.lang.Object
org.apache.juneau.http.header.ProxyAuthenticate.Builder
Enclosing class:
ProxyAuthenticate

public static class ProxyAuthenticate.Builder extends Object
Fluent builder for assembling an HTTP Proxy-Authenticate challenge value.

Composes the scheme [ 1*SP #auth-param ] challenge form defined by RFC 7235 ยง4.3. Typed setters cover the common Basic / Bearer / Digest auth-params and apply the correct quoting (quoted-string vs token); param(String, String) is a generic escape hatch so new params never require an API change. The scheme presets (basic(String) / bearer() / digest()) overwrite the scheme; auth-param setters overwrite a previously-set param of the same name while preserving its original position.

Example:

String value = ProxyAuthenticate.create() .digest() .realm("http-auth@example.org") .qop("auth", "auth-int") .nonce("7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v") .algorithm("SHA-256") .build(); // => "Digest realm=\"http-auth@example.org\", qop=\"auth,auth-int\", nonce=\"...\", algorithm=SHA-256"

See Also:
Since:
10.0.0
  • Constructor Details

  • Method Details

    • scheme

      Sets the authentication scheme (e.g. "Basic", "Bearer", "Digest").
      Parameters:
      value - The scheme name. Must not be null or blank.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is null or blank.
    • basic

      Sets the scheme to Basic and the realm auth-param.
      Parameters:
      realm - The protection space realm. Must not be null.
      Returns:
      This object.
    • bearer

      Sets the scheme to Bearer.
      Returns:
      This object.
    • digest

      Sets the scheme to Digest.
      Returns:
      This object.
    • realm

      Sets the realm auth-param (rendered as a quoted-string).
      Parameters:
      value - The realm value. Must not be null.
      Returns:
      This object.
    • charset

      Sets the charset auth-param (rendered as a quoted-string).
      Parameters:
      value - The charset (e.g. "UTF-8"). Must not be null.
      Returns:
      This object.
    • qop

      public ProxyAuthenticate.Builder qop(String... values)
      Sets the qop auth-param to a comma-separated, quoted list of quality-of-protection tokens.
      Parameters:
      values - The qop tokens (e.g. "auth", "auth-int"). Must not be null.
      Returns:
      This object.
    • nonce

      Sets the nonce auth-param (rendered as a quoted-string).
      Parameters:
      value - The server nonce. Must not be null.
      Returns:
      This object.
    • opaque

      Sets the opaque auth-param (rendered as a quoted-string).
      Parameters:
      value - The opaque value to be echoed back by the client. Must not be null.
      Returns:
      This object.
    • algorithm

      Sets the algorithm auth-param (rendered as a bare token, unquoted).
      Parameters:
      value - The algorithm (e.g. "MD5", "SHA-256"). Must not be null.
      Returns:
      This object.
    • domain

      Sets the domain auth-param to a space-separated, quoted list of URIs.
      Parameters:
      values - The protection space URIs. Must not be null.
      Returns:
      This object.
    • stale

      public ProxyAuthenticate.Builder stale(boolean value)
      Sets the stale auth-param (rendered as a bare token, unquoted).
      Parameters:
      value - true if the previous request's nonce was stale.
      Returns:
      This object.
    • error

      Sets the error auth-param (rendered as a quoted-string; RFC 6750 Bearer).
      Parameters:
      value - The error code (e.g. "invalid_token"). Must not be null.
      Returns:
      This object.
    • errorDescription

      Sets the error_description auth-param (rendered as a quoted-string; RFC 6750 Bearer).
      Parameters:
      value - The human-readable error description. Must not be null.
      Returns:
      This object.
    • param

      Generic escape hatch for setting any auth-param by name, rendered as a quoted-string.

      Replaces any previously-registered value for the same param while preserving its original position.

      Parameters:
      name - The auth-param name. Must not be null or blank.
      value - The auth-param value (quoted automatically). Must not be null.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If name is null or blank.
    • build

      public String build()
      Builds the rendered Proxy-Authenticate challenge value.

      Returns an empty string when no scheme or params have been registered.

      Returns:
      The header value. Never null.
    • toHeader

      Builds a ProxyAuthenticate header bean directly from this builder.
      Returns:
      A ProxyAuthenticate carrying build(). Never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object