public class JWSHeader extends Header implements ReadOnlyJWSHeader
Supports all registered header
parameters of the JWS specification:
The header may also carry 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"
}
| 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. |
java.util.Set<java.lang.String> |
getIncludedParameters()
Gets the names of all included parameters (registered 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. |
java.net.URL |
getJWKURL()
Gets the JSON Web Key (JWK) Set URL (
jku) parameter. |
java.net.URL |
getJWKURL()
Gets the JSON Web Key (JWK) Set URL (
jku) parameter. |
java.lang.String |
getKeyID()
Gets the key ID (
kid) parameter. |
java.lang.String |
getKeyID()
Gets the key ID (
kid) parameter. |
static java.util.Set<java.lang.String> |
getRegisteredParameterNames()
Gets the registered parameter names for JWS headers.
|
java.util.List<Base64> |
getX509CertChain()
Gets the X.509 certificate chain (
x5c) parameter
corresponding to the key used to sign or encrypt the JWS / JWE
object. |
java.util.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. |
java.net.URL |
getX509CertURL()
Gets the X.509 certificate URL (
x5u) parameter. |
java.net.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(java.lang.String s)
Parses a JWS header from the specified JSON object string.
|
void |
setCustomParameter(java.lang.String name,
java.lang.Object value)
Sets a custom (non-registered) parameter.
|
void |
setJWK(JWK jwk)
Sets the JSON Web Key (JWK) (
jwk) parameter. |
void |
setJWKURL(java.net.URL jku)
Sets the JSON Web Key (JWK) Set URL (
jku) parameter. |
void |
setKeyID(java.lang.String kid)
Sets the key ID (
kid) parameter. |
void |
setX509CertChain(java.util.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(java.net.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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, toBase64URL, toJSONObject, toStringpublic JWSHeader(JWSAlgorithm alg)
Note: Use PlainHeader to create a header with algorithm
none.
alg - The JWS algorithm. Must not be "none" or null.public static java.util.Set<java.lang.String> getRegisteredParameterNames()
public JWSAlgorithm getAlgorithm()
ReadOnlyJWSHeaderalg) parameter.getAlgorithm in interface ReadOnlyHeadergetAlgorithm in interface ReadOnlyJWSHeaderpublic void setCustomParameter(java.lang.String name, java.lang.Object value)
HeadersetCustomParameter in class Headername - 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.java.lang.IllegalArgumentException - If the specified parameter name
matches a registered parameter
name.public java.util.Set<java.lang.String> getIncludedParameters()
ReadOnlyHeadergetIncludedParameters in interface ReadOnlyHeaderpublic static JWSHeader parse(net.minidev.json.JSONObject json) throws java.text.ParseException
json - The JSON object to parse. Must not be null.java.text.ParseException - If the specified JSON object doesn't
represent a valid JWS header.public static JWSHeader parse(java.lang.String s) throws java.text.ParseException
s - The JSON object string to parse. Must not be null.java.text.ParseException - If the specified JSON object string doesn't
represent a valid JWS header.public static JWSHeader parse(Base64URL base64URL) throws java.text.ParseException
base64URL - The Base64URL to parse. Must not be null.java.text.ParseException - If the specified Base64URL doesn't represent
a valid JWS header.public java.net.URL getJWKURL()
jku) parameter.null if not
specified.public JWK getJWK()
jwk) parameter.null if not
specified.public java.net.URL getX509CertURL()
x5u) parameter.null if not
specified.public Base64URL getX509CertThumbprint()
x5t) parameter.null if
not specified.public java.util.List<Base64> getX509CertChain()
x5c) parameter
corresponding to the key used to sign or encrypt the JWS / JWE
object.null if not specified.public java.lang.String getKeyID()
kid) parameter.null if not specified.public java.net.URL getJWKURL()
jku) parameter.null if not
specified.public void setJWKURL(java.net.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 java.net.URL getX509CertURL()
x5u) parameter.null if not
specified.public void setX509CertURL(java.net.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 java.util.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(java.util.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 java.lang.String getKeyID()
kid) parameter.null if not specified.public void setKeyID(java.lang.String kid)
kid) parameter.kid - The key ID parameter, null if not specified.public net.minidev.json.JSONObject toJSONObject()
ReadOnlyHeadertoJSONObject in interface ReadOnlyHeadertoJSONObject in class HeaderCopyright © 2014 Connect2id Ltd.. All Rights Reserved.