public abstract class Header extends Object implements ReadOnlyHeader
The header may also carry custom parameters;
these will be serialised and parsed along the registered 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 |
|---|---|
String |
getContentType()
Gets the content type (
cty) parameter. |
Set<String> |
getCriticalHeaders()
Gets the critical headers (
crit) parameter. |
Object |
getCustomParameter(String name)
Gets a custom (non-registered) parameter.
|
Map<String,Object> |
getCustomParameters()
Gets the custom (non-registered) parameters.
|
JOSEObjectType |
getType()
Gets the type (
typ) parameter. |
static Header |
parse(Base64URL base64URL)
|
static Header |
parse(net.minidev.json.JSONObject json)
|
static Header |
parse(String s)
|
static Algorithm |
parseAlgorithm(net.minidev.json.JSONObject json)
Parses an algorithm (
alg) parameter from the specified
header JSON object. |
void |
setContentType(String cty)
Sets the content type (
cty) parameter. |
void |
setCriticalHeaders(Set<String> crit)
Sets the critical headers (
crit) parameter. |
protected void |
setCustomParameter(String name,
Object value)
Sets a custom (non-registered) parameter.
|
void |
setCustomParameters(Map<String,Object> customParameters)
Sets the custom (non-registered) parameters.
|
protected void |
setParsedBase64URL(Base64URL parsedBase64URL)
Sets the original parsed Base64URL used to create this header.
|
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.
|
String |
toString()
Returns a JSON string representation of the 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 String getContentType()
ReadOnlyHeadercty) parameter.getContentType in interface ReadOnlyHeadernull if not specified.public void setContentType(String cty)
cty) parameter.cty - The content type parameter, null if not
specified.public Set<String> getCriticalHeaders()
ReadOnlyHeadercrit) parameter.getCriticalHeaders in interface ReadOnlyHeadernull if none.public void setCriticalHeaders(Set<String> crit)
crit) parameter.crit - The names of the critical header parameters, empty set
null if none.public Object getCustomParameter(String name)
ReadOnlyHeadergetCustomParameter in interface ReadOnlyHeadername - The name of the custom parameter. Must not be
null.null if not specified.protected void setCustomParameter(String name, Object value)
name - The name of the custom parameter. Must not match a
registered 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 Map<String,Object> getCustomParameters()
ReadOnlyHeadergetCustomParameters in interface ReadOnlyHeaderpublic void setCustomParameters(Map<String,Object> customParameters)
customParameters - The custom parameters, empty map or
null if none.protected void setParsedBase64URL(Base64URL parsedBase64URL)
parsedBase64URL - The parsed Base64URL, null if the
header was created from scratch.public net.minidev.json.JSONObject toJSONObject()
ReadOnlyHeadertoJSONObject in interface ReadOnlyHeaderpublic String toString()
ReadOnlyHeadertoString in interface ReadOnlyHeadertoString in class Objectpublic Base64URL toBase64URL()
ReadOnlyHeadertoBase64URL in interface ReadOnlyHeaderpublic static Algorithm parseAlgorithm(net.minidev.json.JSONObject json) throws 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.ParseException - If the alg parameter couldn't be
parsed.public static Header parse(net.minidev.json.JSONObject json) throws ParseException
json - The JSON object to parse. Must not be null.ParseException - If the specified JSON object doesn't
represent a valid header.public static Header parse(String s) throws ParseException
s - The JSON object string to parse. Must not be null.ParseException - If the specified JSON object string doesn't
represent a valid header.public static Header parse(Base64URL base64URL) throws ParseException
base64URL - The Base64URL to parse. Must not be null.ParseException - If the specified Base64URL doesn't represent
a valid header.Copyright © 2014 Connect2id Ltd.. All Rights Reserved.