Class AuthorizationHeader
java.lang.Object
dev.getelements.elements.sdk.util.security.AuthorizationHeader
Created by patricktwohig on 6/26/17.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAuthorizationHeader
(String header) Parses the supplied header string, throwing an instance ofAuthorizationHeaderParseException
if the header does not correctly parse. -
Method Summary
Modifier and TypeMethodDescriptionasBasicHeader
(String encoding) Returns the credentials as a basic authorization header.Returns the credentials as a bearer token authorization header.getType()
static <T> Optional
<AuthorizationHeader> withOptionalValueSupplier
(HeaderOptionalSupplier<T> headerOptionalSupplier) Constructs an instance ofAuthorizationHeader
with the suppliedHeaderOptionalSupplier<T>
.static <T> Optional
<AuthorizationHeader> withValueSupplier
(Function<String, T> valueSupplier)
-
Field Details
-
AUTH_HEADER
Constant for the Authorization header.- See Also:
-
AUTH_TYPE_BASIC
Used in conjunction with the standard Authorization header. This is used to trigger an attempt to authorize the user via HTTP Basic auth- See Also:
-
AUTH_TYPE_BEARER
Used in conjunction with the standard Authorization header. This is used to trigger an attempt to authorize the user via HTTP Basic auth- See Also:
-
-
Constructor Details
-
AuthorizationHeader
Parses the supplied header string, throwing an instance ofAuthorizationHeaderParseException
if the header does not correctly parse.- Parameters:
header
- the header
-
-
Method Details
-
withValueSupplier
-
withOptionalValueSupplier
public static <T> Optional<AuthorizationHeader> withOptionalValueSupplier(HeaderOptionalSupplier<T> headerOptionalSupplier) Constructs an instance ofAuthorizationHeader
with the suppliedHeaderOptionalSupplier<T>
. If the suppliedHeaderOptionalSupplier<T>
does not supply a header the returnedOptional<AuthorizationHeader>
will be empty.- Type Parameters:
T
- the type of header result- Parameters:
headerOptionalSupplier
- theHeaderOptionalSupplier<T>
supplying the header values
-
getType
-
asBasicHeader
Returns the credentials as a basic authorization header.- Parameters:
encoding
- the encoding to use when parsing the header.- Returns:
- the
BasicAuthorizationHeader
- Throws:
AuthorizationHeaderParseException
- if it is not possible to construct the instance ofBasicAuthorizationHeader
AuthorizationHeaderParseException
- if it is not possible to construct the instance ofBasicAuthorizationHeader
-
asBearerHeader
Returns the credentials as a bearer token authorization header.- Returns:
- the
BearerAuthorizationHeader
- Throws:
AuthorizationHeaderParseException
- if it is not possible to construct the instance ofBearerAuthorizationHeader
-