public class AuthorizationHeader extends Header
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)
.
Modifier and Type | Class and Description |
---|---|
static class |
AuthorizationHeader.Factory
A factory for creating
AuthorizationHeader instances. |
Modifier and Type | Field and Description |
---|---|
static String |
NAME
A constant for the name of the Authorization header.
|
Constructor and Description |
---|
AuthorizationHeader() |
Modifier and Type | Method and Description |
---|---|
String |
getCredentials()
Get the credentials component of the header value.
|
String |
getName()
Returns the name of the header, as it would canonically appear within an
HTTP message.
|
String |
getRawValue()
Get the raw value of the header.
|
String |
getType()
Get the type of the authorization being presented, e.g.
|
List<String> |
getValues()
Returns the header as a list of strings.
|
<C> Optional<C> |
parseCredentials(CredentialsParser<C> parser)
Parse the credentials to a rich type.
|
AuthorizationHeader |
setRawValue(String rawValue)
Set the raw value of the header.
|
static AuthorizationHeader |
valueOf(Message<?> message)
Constructs a new header, initialized from the specified message.
|
static AuthorizationHeader |
valueOf(String value)
Parse a string as an
Authorization header value. |
equals, getFirstValue, hashCode, toString
public static final String NAME
public String getName()
Header
public List<String> getValues()
Header
String
should represent the value component of the key-value
pair that makes up the HTTP header - as such, for some Header
implementations each String in this List
may contain multiple
token-separated values.
The List
returned from this method should not be expected to be
mutable. However, some subclasses of Header
may choose to
implement it as such.
public AuthorizationHeader setRawValue(String rawValue) throws MalformedHeaderException
rawValue
- The raw value.MalformedHeaderException
- If the value is malformed.public String getRawValue()
public String getType()
Basic
public String getCredentials()
public <C> Optional<C> parseCredentials(CredentialsParser<C> parser) throws MalformedHeaderException
C
- The rich type for the credentials.parser
- The parser that can parse to the rich type.parser
.MalformedHeaderException
- If the credentials are not valid for the type.public static AuthorizationHeader valueOf(String value) throws MalformedHeaderException
Authorization
header value.value
- The value.MalformedHeaderException
- If the header cannot be parsed as an Authorization
header.public static AuthorizationHeader valueOf(Message<?> message) throws MalformedHeaderException
message
- The message to initialize the header from.MalformedHeaderException
- If the Authorization
header is present but malformed.Copyright © 2010-2018, ForgeRock All Rights Reserved.