com.nimbusds.jose
Class JWSHeader

java.lang.Object
  extended by com.nimbusds.jose.Header
      extended by com.nimbusds.jose.JWSHeader
All Implemented Interfaces:
ReadOnlyHeader, ReadOnlyJWSHeader

public class JWSHeader
extends Header
implements ReadOnlyJWSHeader

JSON Web Signature (JWS) header.

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"
 }
 

Version:
$version$ (2013-05-29)
Author:
Vladimir Dzhuvinov

Field Summary
 
Fields inherited from class com.nimbusds.jose.Header
alg
 
Constructor Summary
JWSHeader(JWSAlgorithm alg)
          Creates a new JSON Web Signature (JWS) header.
 
Method Summary
 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 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.
 
Methods inherited from class com.nimbusds.jose.Header
getContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, parseAlgorithm, setContentType, setCriticalHeaders, setCustomParameters, setParsedBase64URL, setType, toBase64URL, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.nimbusds.jose.ReadOnlyHeader
getContentType, getCriticalHeaders, getCustomParameter, getCustomParameters, getType, toBase64URL, toJSONObject, toString
 

Constructor Detail

JWSHeader

public JWSHeader(JWSAlgorithm alg)
Creates a new JSON Web Signature (JWS) header.

Parameters:
alg - The JWS algorithm. Must not be null.
Method Detail

getReservedParameterNames

public static Set<String> getReservedParameterNames()
Gets the reserved parameter names for JWS headers.

Returns:
The reserved parameter names, as an unmodifiable set.

getAlgorithm

public JWSAlgorithm getAlgorithm()
Description copied from interface: ReadOnlyJWSHeader
Gets the algorithm (alg) parameter.

Specified by:
getAlgorithm in interface ReadOnlyHeader
Specified by:
getAlgorithm in interface ReadOnlyJWSHeader
Returns:
The algorithm parameter.

setCustomParameter

public void setCustomParameter(String name,
                               Object value)
Description copied from class: Header
Sets a custom (non-reserved) parameter. Callers and extending classes should ensure the parameter name doesn't match a reserved parameter name.

Overrides:
setCustomParameter in class Header
Parameters:
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.
Throws:
IllegalArgumentException - If the specified parameter name matches a reserved parameter name.

getIncludedParameters

public Set<String> getIncludedParameters()
Description copied from interface: ReadOnlyHeader
Gets the names of all included parameters (reserved and custom) in the header instance.

Specified by:
getIncludedParameters in interface ReadOnlyHeader
Returns:
The included parameters.

parse

public static JWSHeader parse(net.minidev.json.JSONObject json)
                       throws ParseException
Parses a JWS header from the specified JSON object.

Parameters:
json - The JSON object to parse. Must not be null.
Returns:
The JWS header.
Throws:
ParseException - If the specified JSON object doesn't represent a valid JWS header.

parse

public static JWSHeader parse(String s)
                       throws ParseException
Parses a JWS header from the specified JSON string.

Parameters:
s - The JSON string to parse. Must not be null.
Returns:
The JWS header.
Throws:
ParseException - If the specified JSON object string doesn't represent a valid JWS header.

parse

public static JWSHeader parse(Base64URL base64URL)
                       throws ParseException
Parses a JWS header from the specified Base64URL.

Parameters:
base64URL - The Base64URL to parse. Must not be null.
Returns:
The JWS header.
Throws:
ParseException - If the specified Base64URL doesn't represent a valid JWS header.

getJWKURL

public URL getJWKURL()
Gets the JSON Web Key (JWK) Set URL (jku) parameter.

Returns:
The JSON Web Key (JWK) Set URL parameter, null if not specified.

getJWK

public JWK getJWK()
Gets the JSON Web Key (JWK) (jwk) parameter.

Returns:
The JSON Web Key (JWK) parameter, null if not specified.

getX509CertURL

public URL getX509CertURL()
Gets the X.509 certificate URL (x5u) parameter.

Returns:
The X.509 certificate URL parameter, null if not specified.

getX509CertThumbprint

public Base64URL getX509CertThumbprint()
Gets the X.509 certificate thumbprint (x5t) parameter.

Returns:
The X.509 certificate thumbprint parameter, null if not specified.

getX509CertChain

public List<Base64> getX509CertChain()
Gets the X.509 certificate chain (x5c) parameter corresponding to the key used to sign or encrypt the JWS / JWE object.

Returns:
The X.509 certificate chain parameter as a unmodifiable list, null if not specified.

getKeyID

public String getKeyID()
Gets the key ID (kid) parameter.

Returns:
The key ID parameter, null if not specified.

getJWKURL

public URL getJWKURL()
Gets the JSON Web Key (JWK) Set URL (jku) parameter.

Returns:
The JSON Web Key (JWK) Set URL parameter, null if not specified.

setJWKURL

public void setJWKURL(URL jku)
Sets the JSON Web Key (JWK) Set URL (jku) parameter.

Parameters:
jku - The JSON Web Key (JWK) Set URL parameter, null if not specified.

getJWK

public JWK getJWK()
Gets the JSON Web Key (JWK) (jwk) parameter.

Returns:
The JSON Web Key (JWK) parameter, null if not specified.

setJWK

public void setJWK(JWK jwk)
Sets the JSON Web Key (JWK) (jwk) parameter.

Parameters:
jwk - The JSON Web Key (JWK) (jwk) parameter, null if not specified.

getX509CertURL

public URL getX509CertURL()
Gets the X.509 certificate URL (x5u) parameter.

Returns:
The X.509 certificate URL parameter, null if not specified.

setX509CertURL

public void setX509CertURL(URL x5u)
Sets the X.509 certificate URL (x5u) parameter.

Parameters:
x5u - The X.509 certificate URL parameter, null if not specified.

getX509CertThumbprint

public Base64URL getX509CertThumbprint()
Gets the X.509 certificate thumbprint (x5t) parameter.

Returns:
The X.509 certificate thumbprint parameter, null if not specified.

setX509CertThumbprint

public void setX509CertThumbprint(Base64URL x5t)
Sets the X.509 certificate thumbprint (x5t) parameter.

Parameters:
x5t - The X.509 certificate thumbprint parameter, null if not specified.

getX509CertChain

public List<Base64> getX509CertChain()
Gets the X.509 certificate chain (x5c) parameter corresponding to the key used to sign or encrypt the JWS / JWE object.

Returns:
The X.509 certificate chain parameter as a unmodifiable list, null if not specified.

setX509CertChain

public 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.

Parameters:
x5c - The X.509 certificate chain parameter, null if not specified.

getKeyID

public String getKeyID()
Gets the key ID (kid) parameter.

Returns:
The key ID parameter, null if not specified.

setKeyID

public void setKeyID(String kid)
Sets the key ID (kid) parameter.

Parameters:
kid - The key ID parameter, null if not specified.

toJSONObject

public net.minidev.json.JSONObject toJSONObject()
Description copied from interface: ReadOnlyHeader
Returns a JSON object representation of the header. All custom parameters are included if they serialise to a JSON entity and their names don't conflict with the reserved ones.

Specified by:
toJSONObject in interface ReadOnlyHeader
Overrides:
toJSONObject in class Header
Returns:
The JSON object representation of the header.


Copyright © 2013 NimbusDS. All Rights Reserved.