Class Authorization.Builder
- Enclosing class:
- Authorization
Composes the basic(String, String) and bearer(String) presets render the opaque digest() preset enables the typed Digest auth-params, which apply the correct quoting (quoted-string vs
token). param(String, String) is a generic escape hatch so new params never require an API change.
Setting a scheme preset or token(String) clears any previously-registered auth-params and vice versa, so
a built value carries either a token68 or an auth-param list, never both.
Example:
String
See Also:
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets thealgorithm auth-param (rendered as a bare token, unquoted).SetsBasic credentials by base64-encodinguser:password as the token68 form.SetsBearer credentials with the supplied token as the token68 form.build()Builds the renderedAuthorization credentials value.Sets thecnonce auth-param (rendered as a quoted-string).digest()Sets the scheme toDigest (typed Digest auth-params can then be chained).Sets thenc (nonce-count) auth-param (rendered as a bare token, unquoted).Sets thenonce auth-param (rendered as a quoted-string).Sets theopaque auth-param (rendered as a quoted-string).Generic escape hatch for setting any auth-param by name, rendered as a quoted-string.Sets theqop auth-param (rendered as a bare token, unquoted; a single value in credentials).Sets therealm auth-param (rendered as a quoted-string).Sets theresponse auth-param (rendered as a quoted-string).Sets the authentication scheme (e.g.toHeader()Builds anAuthorizationheader bean directly from this builder.Sets the opaquetoken68 credentials form, clearing any auth-params.toString()Sets theuri auth-param (rendered as a quoted-string).Sets theusername auth-param (rendered as a quoted-string).
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
scheme
Sets the authentication scheme (e.g."Basic" ,"Bearer" ,"Digest" ).- Parameters:
value- The scheme name. Must not benull or blank.- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifvalueisnull or blank.
-
basic
SetsBasic credentials by base64-encodinguser:password as the token68 form.- Parameters:
user- The username. Must not benull .password- The password. Must not benull .- Returns:
- This object.
-
bearer
SetsBearer credentials with the supplied token as the token68 form.- Parameters:
token- The bearer token. Must not benull .- Returns:
- This object.
-
digest
Sets the scheme toDigest (typed Digest auth-params can then be chained).- Returns:
- This object.
-
token
Sets the opaquetoken68 credentials form, clearing any auth-params.- Parameters:
value- The token68 value. Must not benull .- Returns:
- This object.
-
username
Sets theusername auth-param (rendered as a quoted-string).- Parameters:
value- The username. Must not benull .- Returns:
- This object.
-
realm
Sets therealm auth-param (rendered as a quoted-string).- Parameters:
value- The realm. Must not benull .- Returns:
- This object.
-
nonce
Sets thenonce auth-param (rendered as a quoted-string).- Parameters:
value- The server nonce echoed back from the challenge. Must not benull .- Returns:
- This object.
-
uri
Sets theuri auth-param (rendered as a quoted-string).- Parameters:
value- The effective request URI. Must not benull .- Returns:
- This object.
-
response
Sets theresponse auth-param (rendered as a quoted-string).- Parameters:
value- The computed digest response. Must not benull .- Returns:
- This object.
-
cnonce
Sets thecnonce auth-param (rendered as a quoted-string).- Parameters:
value- The client nonce. Must not benull .- Returns:
- This object.
-
opaque
Sets theopaque auth-param (rendered as a quoted-string).- Parameters:
value- The opaque value echoed back from the challenge. Must not benull .- Returns:
- This object.
-
algorithm
Sets thealgorithm auth-param (rendered as a bare token, unquoted).- Parameters:
value- The algorithm (e.g."MD5" ,"SHA-256" ). Must not benull .- Returns:
- This object.
-
qop
Sets theqop auth-param (rendered as a bare token, unquoted; a single value in credentials).- Parameters:
value- The quality-of-protection token (e.g."auth" ). Must not benull .- Returns:
- This object.
-
nc
Sets thenc (nonce-count) auth-param (rendered as a bare token, unquoted).- Parameters:
value- The 8-digit hex nonce-count (e.g."00000001" ). Must not benull .- 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, and clears any previously-set
token68.- Parameters:
name- The auth-param name. Must not benull or blank.value- The auth-param value (quoted automatically). Must not benull .- Returns:
- This object.
- Throws:
IllegalArgumentException- Ifnameisnull or blank.
-
build
Builds the renderedAuthorization credentials value.Returns an empty string when no scheme has been registered.
- Returns:
- The header value. Never
null .
-
toHeader
Builds anAuthorizationheader bean directly from this builder.- Returns:
- An
Authorizationcarryingbuild(). Nevernull .
-
toString
-