com.nimbusds.jose
Class JWEHeader

java.lang.Object
  extended by com.nimbusds.jose.Header
      extended by com.nimbusds.jose.CommonSEHeader
          extended by com.nimbusds.jose.JWEHeader
All Implemented Interfaces:
ReadOnlyCommonSEHeader, ReadOnlyHeader, ReadOnlyJWEHeader

public class JWEHeader
extends CommonSEHeader
implements ReadOnlyJWEHeader

JSON Web Encryption (JWE) header.

Supports all reserved header parameters of the JWE specification:

The header may also carry custom parameters; these will be serialised and parsed along the reserved ones.

Example header:

 { 
   "alg" : "RSA1_5",
   "enc" : "A128CBC+HS256"
 }
 

Version:
$version$ (2013-01-08)
Author:
Vladimir Dzhuvinov

Field Summary
 
Fields inherited from class com.nimbusds.jose.Header
alg
 
Constructor Summary
JWEHeader(JWEAlgorithm alg, EncryptionMethod enc)
          Creates a new JSON Web Encryption (JWE) header.
 
Method Summary
 Base64URL getAgreementPartyUInfo()
          Gets the agreement PartyUInfo (apu) parameter.
 Base64URL getAgreementPartyVInfo()
          Gets the agreement PartyVInfo (apv) parameter.
 JWEAlgorithm getAlgorithm()
          Gets the algorithm (alg) parameter.
 CompressionAlgorithm getCompressionAlgorithm()
          Gets the compression algorithm (zip) parameter.
 EncryptionMethod getEncryptionMethod()
          Gets the encryption method (enc) parameter.
 Base64URL getEncryptionPartyUInfo()
          Gets the encryption PartyUInfo (epu) parameter.
 Base64URL getEncryptionPartyVInfo()
          Gets the encryption PartyVInfo (epv) parameter.
 ECKey getEphemeralPublicKey()
          Gets the Ephemeral Public Key (epk) parameter.
 java.util.Set<java.lang.String> getIncludedParameters()
          Gets the names of all included parameters (reserved and custom) in the header instance.
static java.util.Set<java.lang.String> getReservedParameterNames()
          Gets the reserved parameter names for JWE headers.
static JWEHeader parse(Base64URL base64URL)
          Parses a JWE header from the specified Base64URL.
static JWEHeader parse(net.minidev.json.JSONObject json)
          Parses a JWE header from the specified JSON object.
static JWEHeader parse(java.lang.String s)
          Parses a JWE header from the specified JSON string.
 void setAgreementPartyUInfo(Base64URL apu)
          Sets the agreement PartyUInfo (apu) parameter.
 void setAgreementPartyVInfo(Base64URL apv)
          Sets the agreement PartyVInfo (apv) parameter.
 void setCompressionAlgorithm(CompressionAlgorithm zip)
          Sets the compression algorithm (zip) parameter.
 void setCustomParameter(java.lang.String name, java.lang.Object value)
          Sets a custom (non-reserved) parameter.
 void setEncryptionPartyUInfo(Base64URL epu)
          Sets the encryption PartyUInfo (epu) parameter.
 void setEncryptionPartyVInfo(Base64URL epv)
          Sets the encryption PartyVInfo (epv) parameter.
 void setEphemeralPublicKey(ECKey epk)
          Sets the Ephemeral Public Key (epk) parameter.
 net.minidev.json.JSONObject toJSONObject()
          Returns a JSON object representation of the header.
 
Methods inherited from class com.nimbusds.jose.CommonSEHeader
getJWK, getJWKURL, getKeyID, getX509CertChain, getX509CertThumbprint, getX509CertURL, parseX509CertChain, setJWK, setJWKURL, setKeyID, setX509CertChain, setX509CertThumbprint, setX509CertURL
 
Methods inherited from class com.nimbusds.jose.Header
getContentType, getCustomParameter, getCustomParameters, getType, parseAlgorithm, setContentType, setCustomParameters, 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.ReadOnlyCommonSEHeader
getJWK, getJWKURL, getKeyID, getX509CertChain, getX509CertThumbprint, getX509CertURL
 
Methods inherited from interface com.nimbusds.jose.ReadOnlyHeader
getContentType, getCustomParameter, getCustomParameters, getType, toBase64URL
 

Constructor Detail

JWEHeader

public JWEHeader(JWEAlgorithm alg,
                 EncryptionMethod enc)
Creates a new JSON Web Encryption (JWE) header.

Parameters:
alg - The JWE algorithm parameter. Must not be null.
enc - The encryption method parameter. Must not be null.
Method Detail

getReservedParameterNames

public static java.util.Set<java.lang.String> getReservedParameterNames()
Gets the reserved parameter names for JWE headers.

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

getAlgorithm

public JWEAlgorithm getAlgorithm()
Description copied from interface: ReadOnlyJWEHeader
Gets the algorithm (alg) parameter.

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

getEncryptionMethod

public EncryptionMethod getEncryptionMethod()
Description copied from interface: ReadOnlyJWEHeader
Gets the encryption method (enc) parameter.

Specified by:
getEncryptionMethod in interface ReadOnlyJWEHeader
Returns:
The encryption method parameter.

getEphemeralPublicKey

public ECKey getEphemeralPublicKey()
Description copied from interface: ReadOnlyJWEHeader
Gets the Ephemeral Public Key (epk) parameter.

Specified by:
getEphemeralPublicKey in interface ReadOnlyJWEHeader
Returns:
The Ephemeral Public Key parameter, null if not specified.

setEphemeralPublicKey

public void setEphemeralPublicKey(ECKey epk)
Sets the Ephemeral Public Key (epk) parameter.

Parameters:
epk - The Ephemeral Public Key parameter, null if not specified.

getCompressionAlgorithm

public CompressionAlgorithm getCompressionAlgorithm()
Description copied from interface: ReadOnlyJWEHeader
Gets the compression algorithm (zip) parameter.

Specified by:
getCompressionAlgorithm in interface ReadOnlyJWEHeader
Returns:
The compression algorithm parameter, null if not specified.

setCompressionAlgorithm

public void setCompressionAlgorithm(CompressionAlgorithm zip)
Sets the compression algorithm (zip) parameter.

Parameters:
zip - The compression algorithm parameter, null if not specified.

getAgreementPartyUInfo

public Base64URL getAgreementPartyUInfo()
Description copied from interface: ReadOnlyJWEHeader
Gets the agreement PartyUInfo (apu) parameter.

Specified by:
getAgreementPartyUInfo in interface ReadOnlyJWEHeader
Returns:
The agreement PartyUInfo parameter, null if not specified.

setAgreementPartyUInfo

public void setAgreementPartyUInfo(Base64URL apu)
Sets the agreement PartyUInfo (apu) parameter.

Parameters:
apu - The agreement PartyUInfo parameter, null if not specified.

getAgreementPartyVInfo

public Base64URL getAgreementPartyVInfo()
Description copied from interface: ReadOnlyJWEHeader
Gets the agreement PartyVInfo (apv) parameter.

Specified by:
getAgreementPartyVInfo in interface ReadOnlyJWEHeader
Returns:
The agreement PartyVInfo parameter, null if not specified.

setAgreementPartyVInfo

public void setAgreementPartyVInfo(Base64URL apv)
Sets the agreement PartyVInfo (apv) parameter.

Parameters:
apv - The agreement PartyVInfo parameter, null if not specified.

getEncryptionPartyUInfo

public Base64URL getEncryptionPartyUInfo()
Description copied from interface: ReadOnlyJWEHeader
Gets the encryption PartyUInfo (epu) parameter.

Specified by:
getEncryptionPartyUInfo in interface ReadOnlyJWEHeader
Returns:
The encryption PartyUInfo parameter, null if not specified.

setEncryptionPartyUInfo

public void setEncryptionPartyUInfo(Base64URL epu)
Sets the encryption PartyUInfo (epu) parameter.

Parameters:
epu - The encryption PartyUInfo parameter, null if not specified.

getEncryptionPartyVInfo

public Base64URL getEncryptionPartyVInfo()
Description copied from interface: ReadOnlyJWEHeader
Gets the encryption PartyVInfo (epv) parameter.

Specified by:
getEncryptionPartyVInfo in interface ReadOnlyJWEHeader
Returns:
The encryption PartyVInfo parameter, null if not specified.

setEncryptionPartyVInfo

public void setEncryptionPartyVInfo(Base64URL epv)
Sets the encryption PartyVInfo (epv) parameter.

Parameters:
epv - The encryption PartyVInfo parameter, null if not specified.

setCustomParameter

public void setCustomParameter(java.lang.String name,
                               java.lang.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:
java.lang.IllegalArgumentException - If the specified parameter name matches a reserved parameter name.

getIncludedParameters

public java.util.Set<java.lang.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.

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 CommonSEHeader
Returns:
The JSON object representation of the header.

parse

public static JWEHeader parse(net.minidev.json.JSONObject json)
                       throws java.text.ParseException
Parses a JWE header from the specified JSON object.

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

parse

public static JWEHeader parse(java.lang.String s)
                       throws java.text.ParseException
Parses a JWE header from the specified JSON string.

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

parse

public static JWEHeader parse(Base64URL base64URL)
                       throws java.text.ParseException
Parses a JWE header from the specified Base64URL.

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


Copyright © 2013 NimbusDS. All Rights Reserved.