public abstract class Header extends java.lang.Object implements ReadOnlyHeader
The header may also carry custom parameters;
these will be serialised and parsed along the reserved ones.
| Modifier and Type | Field and Description |
|---|---|
protected Algorithm |
alg
The algorithm (
alg) parameter. |
| Modifier | Constructor and Description |
|---|---|
protected |
Header(Algorithm alg)
Creates a new header with the specified algorithm (
alg)
parameter. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getContentType()
Gets the content type (
cty) parameter. |
java.lang.Object |
getCustomParameter(java.lang.String name)
Gets a custom (non-reserved) parameter.
|
java.util.Map<java.lang.String,java.lang.Object> |
getCustomParameters()
Gets the custom (non-reserved) parameters.
|
JOSEObjectType |
getType()
Gets the type (
typ) parameter. |
static Header |
parse(net.minidev.json.JSONObject json)
|
static Algorithm |
parseAlgorithm(net.minidev.json.JSONObject json)
Parses an algorithm (
alg) parameter from the specified
header JSON object. |
void |
setContentType(java.lang.String cty)
Sets the content type (
cty) parameter. |
protected void |
setCustomParameter(java.lang.String name,
java.lang.Object value)
Sets a custom (non-reserved) parameter.
|
void |
setCustomParameters(java.util.Map<java.lang.String,java.lang.Object> customParameters)
Sets the custom (non-reserved) parameters.
|
void |
setType(JOSEObjectType typ)
Sets the type (
typ) parameter. |
Base64URL |
toBase64URL()
Returns a Base64URL representation of the header.
|
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of the header.
|
java.lang.String |
toString()
Returns a JSON string representation of this header.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAlgorithm, getIncludedParameterspublic JOSEObjectType getType()
ReadOnlyHeadertyp) parameter.getType in interface ReadOnlyHeadernull if not specified.public void setType(JOSEObjectType typ)
typ) parameter.typ - The type parameter, null if not specified.public java.lang.String getContentType()
ReadOnlyHeadercty) parameter.getContentType in interface ReadOnlyHeadernull if not specified.public void setContentType(java.lang.String cty)
cty) parameter.cty - The content type parameter, null if not specified.public java.lang.Object getCustomParameter(java.lang.String name)
ReadOnlyHeadergetCustomParameter in interface ReadOnlyHeadername - The name of the custom parameter. Must not be
null.null if not specified.protected void setCustomParameter(java.lang.String name, java.lang.Object value)
name - The name of the custom parameter. Must not match a
reserved parameter name and must not be null.value - The value of the custom parameter, should map to a valid
JSON entity, null if not specified.public java.util.Map<java.lang.String,java.lang.Object> getCustomParameters()
ReadOnlyHeadergetCustomParameters in interface ReadOnlyHeaderpublic void setCustomParameters(java.util.Map<java.lang.String,java.lang.Object> customParameters)
customParameters - The custom parameters, empty map or
null if none.public net.minidev.json.JSONObject toJSONObject()
ReadOnlyHeadertoJSONObject in interface ReadOnlyHeaderpublic java.lang.String toString()
toString in class java.lang.Objectpublic Base64URL toBase64URL()
ReadOnlyHeadertoBase64URL in interface ReadOnlyHeaderpublic static Algorithm parseAlgorithm(net.minidev.json.JSONObject json) throws java.text.ParseException
alg) parameter from the specified
header JSON object. Intended for initial parsing of plain, JWS and
JWE headers.
The algorithm type (none, JWS or JWE) is determined by inspecting the algorithm name for "none" and the presence of an "enc" parameter.
json - The JSON object to parse. Must not be null.Algorithm.NONE,
JWSAlgorithm or JWEAlgorithm.java.text.ParseException - If the alg parameter couldn't be
parsed.Copyright © 2013 NimbusDS. All Rights Reserved.