public abstract class JwtHeader extends JWObject
Provides methods to set header parameters for all types of JWT Headers.
Constructor and Description |
---|
JwtHeader()
Constructs a new JwtHeader, with the "typ" parameter set to "JWT".
|
JwtHeader(Map<String,Object> headers)
Constructs a new JwtHeader, with its parameters set to the contents of the given Map.
|
Modifier and Type | Method and Description |
---|---|
String |
build()
Builds the JWT's header into a
String representation of a JSON object. |
abstract Algorithm |
getAlgorithm()
Gets the Algorithm set in the JWT header.
|
protected String |
getAlgorithmString()
Gets the string representation of the Algorithm set in the JWT header.
|
Object |
getParameter(String key)
Gets a header parameter for the specified key.
|
<T> T |
getParameter(String key,
Class<T> clazz)
Gets a header parameter for the specified key and then casts it to the specified type.
|
Map<String,Object> |
getParameters()
Returns this JwtHeader's parameters.
|
JwtType |
getType()
Gets the type of JWT this header represents.
|
void |
setAlgorithm(Algorithm algorithm)
Sets the algorithm used to perform cryptographic signing and/or encryption on the JWT.
|
void |
setParameter(String key,
Object value)
Sets a header parameter with the specified key and value.
|
void |
setParameters(Map<String,Object> headers)
Sets header parameters using the values contained in the specified map.
|
void |
setType(JwtType jwtType)
Sets the type of JWT this header represents.
|
checkListValuesAreOfType, checkValueIsOfType, get, isDefined, isValueOfType, keys, put, toJsonValue, toString
public JwtHeader()
public void setType(JwtType jwtType)
For non-nested JWTs then the "JWT" type is RECOMMENDED to be used but it is OPTIONAL to set the "typ" property. For nested signed or encrypted JWTs the JWT type MUST be "JWS" and "JWE" respectively and the "typ" property MUST be set.
jwtType
- The JwtType.JwtType
public JwtType getType()
public void setAlgorithm(Algorithm algorithm)
algorithm
- The Algorithm.public abstract Algorithm getAlgorithm()
protected String getAlgorithmString()
public void setParameter(String key, Object value)
If the key matches one of the reserved header parameter names, then the relevant set method is called to set that header parameter with the specified value.
key
- The key of the header parameter.value
- The value of the header parameter.public void setParameters(Map<String,Object> headers)
headers
- The Map to use to set header parameters.JwtHeader.setParameter(String, Object)
public Object getParameter(String key)
If the key matches one of the reserved header parameter names, then the relevant get method is called to get that header parameter.
key
- The header parameter key.public <T> T getParameter(String key, Class<T> clazz)
T
- The required type for the header parameter value.key
- The header parameter key.clazz
- The class of the required type.JwtHeader.getParameter(String)
public Map<String,Object> getParameters()
Map
of this JwtHeader's parameters.public String build()
String
representation of a JSON object.Copyright © 2010-2018, ForgeRock All Rights Reserved.