Package org.forgerock.http.header
Class AuthorizationHeader
java.lang.Object
org.forgerock.http.protocol.Header
org.forgerock.http.header.AuthorizationHeader
A header class representing the
Authorization
HTTP header.
The Authorization
header is made up of <type><space><credentials>
, where credentials
can be any text that fulfils the requirements of the type. e.g. for a type of Basic
, the
credentials will be base64encode(username + ":" + password)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A factory for creatingAuthorizationHeader
instances. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the credentials component of the header value.getName()
Returns the name of the header, as it would canonically appear within an HTTP message.Get the raw value of the header.getType()
Get the type of the authorization being presented, e.g.Returns the header as a list of strings.<C> Optional<C>
parseCredentials
(CredentialsParser<C> parser) Parse the credentials to a rich type.setRawValue
(String rawValue) Set the raw value of the header.static AuthorizationHeader
Parse a string as anAuthorization
header value.static AuthorizationHeader
Constructs a new header, initialized from the specified message.Methods inherited from class org.forgerock.http.protocol.Header
equals, getFirstValue, hashCode, toString
-
Field Details
-
NAME
A constant for the name of the Authorization header.- See Also:
-
-
Constructor Details
-
AuthorizationHeader
public AuthorizationHeader()
-
-
Method Details
-
getName
Description copied from class:Header
Returns the name of the header, as it would canonically appear within an HTTP message. -
getValues
Description copied from class:Header
Returns the header as a list of strings. If the header has no values then it must return an empty list, never null. EachString
should represent the value component of the key-value pair that makes up the HTTP header - as such, for someHeader
implementations each String in thisList
may contain multiple token-separated values.The
List
returned from this method should not be expected to be mutable. However, some subclasses ofHeader
may choose to implement it as such. -
setRawValue
Set the raw value of the header.- Parameters:
rawValue
- The raw value.- Returns:
- The header.
- Throws:
MalformedHeaderException
- If the value is malformed.
-
getRawValue
Get the raw value of the header.- Returns:
- The raw value.
-
getType
Get the type of the authorization being presented, e.g.Basic
- Returns:
- The type.
-
getCredentials
Get the credentials component of the header value.- Returns:
- The credentials string.
-
parseCredentials
public <C> Optional<C> parseCredentials(CredentialsParser<C> parser) throws MalformedHeaderException Parse the credentials to a rich type.- Type Parameters:
C
- The rich type for the credentials.- Parameters:
parser
- The parser that can parse to the rich type.- Returns:
- An optional of the parsed credentials, or an empty optional if the type is not supported by the
provided
parser
. - Throws:
MalformedHeaderException
- If the credentials are not valid for the type.
-
valueOf
Parse a string as anAuthorization
header value.- Parameters:
value
- The value.- Returns:
- The header.
- Throws:
MalformedHeaderException
- If the header cannot be parsed as anAuthorization
header.
-
valueOf
Constructs a new header, initialized from the specified message.- Parameters:
message
- The message to initialize the header from.- Returns:
- The parsed header.
- Throws:
MalformedHeaderException
- If theAuthorization
header is present but malformed.
-