public class JWSHeader extends Header implements ReadOnlyJWSHeader
Supports all reserved header parameters
of the JWS specification:
The header may also carry custom parameters
;
these will be serialised and parsed along the reserved ones.
Example header of a JSON Web Signature (JWS) object using the
HMAC SHA-256 algorithm
:
{ "alg" : "HS256" }
Constructor and Description |
---|
JWSHeader(JWSAlgorithm alg)
Creates a new JSON Web Signature (JWS) header.
|
Modifier and Type | Method and Description |
---|---|
JWSAlgorithm |
getAlgorithm()
Gets the algorithm (
alg ) parameter. |
Set<String> |
getIncludedParameters()
Gets the names of all included parameters (reserved and custom) in
the header instance.
|
JWK |
getJWK()
Gets the JSON Web Key (JWK) (
jwk ) parameter. |
JWK |
getJWK()
Gets the JSON Web Key (JWK) (
jwk ) parameter. |
URL |
getJWKURL()
Gets the JSON Web Key (JWK) Set URL (
jku ) parameter. |
URL |
getJWKURL()
Gets the JSON Web Key (JWK) Set URL (
jku ) parameter. |
String |
getKeyID()
Gets the key ID (
kid ) parameter. |
String |
getKeyID()
Gets the key ID (
kid ) parameter. |
static Set<String> |
getReservedParameterNames()
Gets the reserved 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. |
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 |
getX509CertThumbprint()
Gets the X.509 certificate thumbprint (
x5t ) parameter. |
Base64URL |
getX509CertThumbprint()
Gets the X.509 certificate thumbprint (
x5t ) parameter. |
URL |
getX509CertURL()
Gets the X.509 certificate URL (
x5u ) parameter. |
URL |
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 json)
Parses a JWS header from the specified JSON object.
|
static JWSHeader |
parse(String s)
Parses a JWS header from the specified JSON object string.
|
void |
setCustomParameter(String name,
Object value)
Sets a custom (non-reserved) parameter.
|
void |
setJWK(JWK jwk)
Sets the JSON Web Key (JWK) (
jwk ) parameter. |
void |
setJWKURL(URL jku)
Sets the JSON Web Key (JWK) Set URL (
jku ) parameter. |
void |
setKeyID(String kid)
Sets the key ID (
kid ) parameter. |
void |
setX509CertChain(List<Base64> x5c)
Sets the X.509 certificate chain parameter (
x5c )
corresponding to the key used to sign or encrypt the JWS / JWE
object. |
void |
setX509CertThumbprint(Base64URL x5t)
Sets the X.509 certificate thumbprint (
x5t ) parameter. |
void |
setX509CertURL(URL x5u)
Sets the X.509 certificate URL (
x5u ) parameter. |
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of the header.
|
getContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, parseAlgorithm, setContentType, setCriticalHeaders, setCustomParameters, setParsedBase64URL, setType, toBase64URL, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, toBase64URL, toJSONObject, toString
public JWSHeader(JWSAlgorithm alg)
alg
- The JWS algorithm. Must not be null
.public static Set<String> getReservedParameterNames()
public JWSAlgorithm getAlgorithm()
ReadOnlyJWSHeader
alg
) parameter.getAlgorithm
in interface ReadOnlyHeader
getAlgorithm
in interface ReadOnlyJWSHeader
public void setCustomParameter(String name, Object value)
Header
setCustomParameter
in class Header
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.IllegalArgumentException
- If the specified parameter name
matches a reserved parameter name.public Set<String> getIncludedParameters()
ReadOnlyHeader
getIncludedParameters
in interface ReadOnlyHeader
public static JWSHeader 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 JWS header.public static JWSHeader 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 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 URL getJWKURL()
jku
) parameter.null
if not
specified.public JWK getJWK()
jwk
) parameter.null
if not
specified.public URL getX509CertURL()
x5u
) parameter.null
if not
specified.public Base64URL getX509CertThumbprint()
x5t
) 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 URL getJWKURL()
jku
) parameter.null
if not
specified.public void setJWKURL(URL jku)
jku
) parameter.jku
- The JSON Web Key (JWK) Set URL parameter, null
if
not specified.public JWK getJWK()
jwk
) parameter.null
if not
specified.public void setJWK(JWK jwk)
jwk
) parameter.jwk
- The JSON Web Key (JWK) (jwk
) parameter,
null
if not specified.public URL getX509CertURL()
x5u
) parameter.null
if not
specified.public void setX509CertURL(URL x5u)
x5u
) parameter.x5u
- The X.509 certificate URL parameter, null
if not
specified.public Base64URL getX509CertThumbprint()
x5t
) parameter.null
if
not specified.public void setX509CertThumbprint(Base64URL x5t)
x5t
) parameter.x5t
- The X.509 certificate thumbprint 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 void setX509CertChain(List<Base64> x5c)
x5c
)
corresponding to the key used to sign or encrypt the JWS / JWE
object.x5c
- The X.509 certificate chain parameter, null
if
not specified.public String getKeyID()
kid
) parameter.null
if not specified.public void setKeyID(String kid)
kid
) parameter.kid
- The key ID parameter, null
if not specified.public net.minidev.json.JSONObject toJSONObject()
ReadOnlyHeader
toJSONObject
in interface ReadOnlyHeader
toJSONObject
in class Header
Copyright © 2013 NimbusDS. All Rights Reserved.