Package org.forgerock.http.header
Class WwwAuthenticateHeader
- java.lang.Object
-
- org.forgerock.http.protocol.Header
-
- org.forgerock.http.header.WwwAuthenticateHeader
-
public class WwwAuthenticateHeader extends Header
AHeader
representation of the WWW-Authenticate HTTP header.- See Also:
- RFC7235, HTTP Authentication
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WwwAuthenticateHeader.Challenge
A single WWW-Authenticate challenge.
-
Constructor Summary
Constructors Constructor Description WwwAuthenticateHeader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WwwAuthenticateHeader
addChallenge(String scheme, String realm, Map<String,String> parameters)
Add a new challenge.WwwAuthenticateHeader
addChallenge(WwwAuthenticateHeader.Challenge challenge)
Add a new authentication option.static WwwAuthenticateHeader
basic(String realm)
Create a basic authentication challenge header.static WwwAuthenticateHeader
bearer(String realm, Map<String,String> parameters)
Create a bearer authentication challenge header.List<WwwAuthenticateHeader.Challenge>
getChallenges()
Return an unmodifiable view of the authentication challenges represented by this header object.String
getName()
Returns the name of the header, as it would canonically appear within an HTTP message.List<String>
getValues()
Returns the header as a list of strings.static WwwAuthenticateHeader
valueOf(List<String> values)
Obtain aWwwAuthenticateHeader
representation of the given header values.static WwwAuthenticateHeader
valueOf(Response response)
Obtain aWwwAuthenticateHeader
representation of the headers in the given response.-
Methods inherited from class org.forgerock.http.protocol.Header
equals, getFirstValue, hashCode, toString
-
-
-
-
Field Detail
-
NAME
public static final String NAME
A constant for the name of the WWW-Authenticate header.- See Also:
- Constant Field Values
-
-
Method Detail
-
getChallenges
public List<WwwAuthenticateHeader.Challenge> getChallenges()
Return an unmodifiable view of the authentication challenges represented by this header object.- Returns:
- The challenges.
-
getName
public String getName()
Description copied from class:Header
Returns the name of the header, as it would canonically appear within an HTTP message.
-
getValues
public List<String> 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.
-
addChallenge
public WwwAuthenticateHeader addChallenge(String scheme, String realm, Map<String,String> parameters)
Add a new challenge.- Parameters:
scheme
- The scheme of the authentication option.realm
- The realm of the authentication option.parameters
- Any additional options that the scheme requires.- Returns:
- This header, for fluent invocation of this method.
-
addChallenge
public WwwAuthenticateHeader addChallenge(WwwAuthenticateHeader.Challenge challenge)
Add a new authentication option.- Parameters:
challenge
- The authentication option.- Returns:
- This header, for fluent invocation of this method.
-
valueOf
public static WwwAuthenticateHeader valueOf(Response response) throws MalformedHeaderException
Obtain aWwwAuthenticateHeader
representation of the headers in the given response.- Parameters:
response
- The response object.- Returns:
- A header object containing 0-to-many header values for the WWW-Authenticate header, or
null
if theresponse
parameter is null. - Throws:
MalformedHeaderException
- If any of the WWW-Authenticate values cannot be parsed as such.
-
valueOf
public static WwwAuthenticateHeader valueOf(List<String> values) throws MalformedHeaderException
Obtain aWwwAuthenticateHeader
representation of the given header values.- Parameters:
values
- The header values.- Returns:
- A header object containing 0-to-many header values, or
null
if thevalues
parameter is null. - Throws:
MalformedHeaderException
- If any of the values cannot be parsed as a WWW-Authenticate value.
-
basic
public static WwwAuthenticateHeader basic(String realm)
Create a basic authentication challenge header.- Parameters:
realm
- The realm for the challenge.- Returns:
- The header value.
-
bearer
public static WwwAuthenticateHeader bearer(String realm, Map<String,String> parameters)
Create a bearer authentication challenge header.- Parameters:
realm
- The realm for the challenge.parameters
- Additional parameters for the challenge.- Returns:
- The header value.
-
-