@Immutable public final class JWSHeader extends Header
Supports all registered header
parameters of the JWS specification:
The header may also include custom
parameters; these will be serialised and parsed along the registered ones.
Example header of a JSON Web Signature (JWS) object using the
HMAC SHA-256 algorithm:
{
"alg" : "HS256"
}
| Modifier and Type | Class and Description |
|---|---|
static class |
JWSHeader.Builder
Builder for constructing JSON Web Signature (JWS) headers.
|
| Constructor and Description |
|---|
JWSHeader(JWSAlgorithm alg)
Creates a new minimal JSON Web Signature (JWS) header.
|
JWSHeader(JWSAlgorithm alg,
JOSEObjectType typ,
String cty,
Set<String> crit,
URI jku,
JWK jwk,
URI x5u,
Base64URL x5t,
Base64URL x5t256,
List<Base64> x5c,
String kid,
Map<String,Object> customParams,
Base64URL parsedBase64URL)
Creates a new JSON Web Signature (JWS) header.
|
JWSHeader(JWSHeader jwsHeader)
Deep copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
JWSAlgorithm |
getAlgorithm()
Gets the algorithm (
alg) parameter. |
Set<String> |
getIncludedParams()
Gets the names of all included parameters (registered and custom) in
the header instance.
|
JWK |
getJWK()
Gets the JSON Web Key (JWK) (
jwk) parameter. |
URI |
getJWKURL()
Gets the JSON Web Key (JWK) Set URL (
jku) parameter. |
String |
getKeyID()
Gets the key ID (
kid) parameter. |
static Set<String> |
getRegisteredParameterNames()
Gets the registered parameter names for JWS headers.
|
List<Base64> |
getX509CertChain()
Gets the X.509 certificate chain (
x5c) parameter
corresponding to the key used to sign or encrypt the JWS / JWE
object. |
Base64URL |
getX509CertSHA256Thumbprint()
Gets the X.509 certificate SHA-256 thumbprint (
x5t#S256)
parameter. |
Base64URL |
getX509CertThumbprint()
Gets the X.509 certificate SHA-1 thumbprint (
x5t) parameter. |
URI |
getX509CertURL()
Gets the X.509 certificate URL (
x5u) parameter. |
static JWSHeader |
parse(Base64URL base64URL)
Parses a JWS header from the specified Base64URL.
|
static JWSHeader |
parse(net.minidev.json.JSONObject jsonObject)
Parses a JWS header from the specified JSON object.
|
static JWSHeader |
parse(net.minidev.json.JSONObject jsonObject,
Base64URL parsedBase64URL)
Parses a JWS header from the specified JSON object.
|
static JWSHeader |
parse(String jsonString)
Parses a JWS header from the specified JSON object string.
|
static JWSHeader |
parse(String jsonString,
Base64URL parsedBase64URL)
Parses a JWS header from the specified JSON object string.
|
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of the header.
|
getContentType, getCriticalParams, getCustomParam, getCustomParams, getParsedBase64URL, getType, parseAlgorithm, toBase64URL, toStringpublic JWSHeader(JWSAlgorithm alg)
Note: Use PlainHeader to create a header with algorithm
none.
alg - The JWS algorithm (alg) parameter. Must not be
"none" or null.public JWSHeader(JWSAlgorithm alg, JOSEObjectType typ, String cty, Set<String> crit, URI jku, JWK jwk, URI x5u, Base64URL x5t, Base64URL x5t256, List<Base64> x5c, String kid, Map<String,Object> customParams, Base64URL parsedBase64URL)
Note: Use PlainHeader to create a header with algorithm
none.
alg - The JWS algorithm (alg) parameter.
Must not be "none" or null.typ - The type (typ) parameter,
null if not specified.cty - The content type (cty) parameter,
null if not specified.crit - The names of the critical header
(crit) parameters, empty set or
null if none.jku - The JSON Web Key (JWK) Set URL (jku)
parameter, null if not specified.jwk - The X.509 certificate URL (jwk)
parameter, null if not specified.x5u - The X.509 certificate URL parameter
(x5u), null if not specified.x5t - The X.509 certificate SHA-1 thumbprint
(x5t) parameter, null if not
specified.x5t256 - The X.509 certificate SHA-256 thumbprint
(x5t#S256) parameter, null if
not specified.x5c - The X.509 certificate chain (x5c)
parameter, null if not specified.kid - The key ID (kid) parameter,
null if not specified.customParams - The custom parameters, empty map or
null if none.parsedBase64URL - The parsed Base64URL, null if the
header is created from scratch.public static Set<String> getRegisteredParameterNames()
public JWSAlgorithm getAlgorithm()
alg) parameter.getAlgorithm in class Headerpublic static JWSHeader parse(net.minidev.json.JSONObject jsonObject) throws ParseException
jsonObject - The JSON object to parse. Must not be
null.ParseException - If the specified JSON object doesn't
represent a valid JWS header.public static JWSHeader parse(net.minidev.json.JSONObject jsonObject, Base64URL parsedBase64URL) throws ParseException
jsonObject - The JSON object to parse. Must not be
null.parsedBase64URL - The original parsed Base64URL, null
if not applicable.ParseException - If the specified JSON object doesn't
represent a valid JWS header.public static JWSHeader parse(String jsonString) throws ParseException
jsonString - The JSON string to parse. Must not be
null.ParseException - If the specified JSON object string doesn't
represent a valid JWS header.public static JWSHeader parse(String jsonString, Base64URL parsedBase64URL) throws ParseException
jsonString - The JSON string to parse. Must not be
null.parsedBase64URL - The original parsed Base64URL, null
if not applicable.ParseException - If the specified JSON object string doesn't
represent a valid JWS header.public static JWSHeader parse(Base64URL base64URL) throws ParseException
base64URL - The Base64URL to parse. Must not be null.ParseException - If the specified Base64URL doesn't represent
a valid JWS header.public URI getJWKURL()
jku) parameter.null if
not specified.public JWK getJWK()
jwk) parameter.null if not
specified.public URI getX509CertURL()
x5u) parameter.null if not
specified.public Base64URL getX509CertThumbprint()
x5t) parameter.null if not specified.public Base64URL getX509CertSHA256Thumbprint()
x5t#S256)
parameter.null if not specified.public List<Base64> getX509CertChain()
x5c) parameter
corresponding to the key used to sign or encrypt the JWS / JWE
object.null if not specified.public String getKeyID()
kid) parameter.null if not specified.public Set<String> getIncludedParams()
HeadergetIncludedParams in class Headerpublic net.minidev.json.JSONObject toJSONObject()
HeadertoJSONObject in class HeaderCopyright © 2016 Connect2id Ltd.. All rights reserved.