@Immutable public final class JWEHeader extends Header
Supports all registered header
parameters
of the JWE specification:
The header may also include custom
parameters
; these will be serialised and parsed along the registered ones.
Example header:
{ "alg" : "RSA1_5", "enc" : "A128CBC-HS256" }
Modifier and Type | Class and Description |
---|---|
static class |
JWEHeader.Builder
Builder for constructing JSON Web Encryption (JWE) headers.
|
Constructor and Description |
---|
JWEHeader(Algorithm alg,
EncryptionMethod enc,
JOSEObjectType typ,
String cty,
Set<String> crit,
URI jku,
JWK jwk,
URI x5u,
Base64URL x5t,
Base64URL x5t256,
List<Base64> x5c,
String kid,
JWK epk,
CompressionAlgorithm zip,
Base64URL apu,
Base64URL apv,
Base64URL p2s,
int p2c,
Base64URL iv,
Base64URL tag,
Map<String,Object> customParams,
Base64URL parsedBase64URL)
Creates a new JSON Web Encryption (JWE) header.
|
JWEHeader(JWEAlgorithm alg,
EncryptionMethod enc)
Creates a new minimal JSON Web Encryption (JWE) header.
|
JWEHeader(JWEHeader jweHeader)
Deep copy constructor.
|
Modifier and Type | Method and Description |
---|---|
Base64URL |
getAgreementPartyUInfo()
Gets the agreement PartyUInfo (
apu ) parameter. |
Base64URL |
getAgreementPartyVInfo()
Gets the agreement PartyVInfo (
apv ) parameter. |
JWEAlgorithm |
getAlgorithm()
Gets the algorithm (
alg ) parameter. |
Base64URL |
getAuthTag()
Gets the authentication tag (
tag ) parameter. |
CompressionAlgorithm |
getCompressionAlgorithm()
Gets the compression algorithm (
zip ) parameter. |
EncryptionMethod |
getEncryptionMethod()
Gets the encryption method (
enc ) parameter. |
JWK |
getEphemeralPublicKey()
Gets the Ephemeral Public Key (
epk ) parameter. |
Set<String> |
getIncludedParams()
Gets the names of all included parameters (registered and custom) in
the header instance.
|
Base64URL |
getIV()
Gets the initialisation vector (
iv ) parameter. |
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. |
int |
getPBES2Count()
Gets the PBES2 count (
p2c ) parameter. |
Base64URL |
getPBES2Salt()
Gets the PBES2 salt (
p2s ) parameter. |
static Set<String> |
getRegisteredParameterNames()
Gets the registered parameter names for JWE 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()
Deprecated.
|
URI |
getX509CertURL()
Gets the X.509 certificate URL (
x5u ) parameter. |
static JWEHeader |
parse(Base64URL base64URL)
Parses a JWE header from the specified Base64URL.
|
static JWEHeader |
parse(net.minidev.json.JSONObject jsonObject)
Parses a JWE header from the specified JSON object.
|
static JWEHeader |
parse(net.minidev.json.JSONObject jsonObject,
Base64URL parsedBase64URL)
Parses a JWE header from the specified JSON object.
|
static JWEHeader |
parse(String jsonString)
Parses a JWE header from the specified JSON object string.
|
static JWEHeader |
parse(String jsonString,
Base64URL parsedBase64URL)
Parses a JWE 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, toString
public JWEHeader(JWEAlgorithm alg, EncryptionMethod enc)
Note: Use PlainHeader
to create a header with algorithm
none
.
alg
- The JWE algorithm parameter. Must not be "none" or
null
.enc
- The encryption method parameter. Must not be
null
.public JWEHeader(Algorithm alg, EncryptionMethod enc, JOSEObjectType typ, String cty, Set<String> crit, URI jku, JWK jwk, URI x5u, Base64URL x5t, Base64URL x5t256, List<Base64> x5c, String kid, JWK epk, CompressionAlgorithm zip, Base64URL apu, Base64URL apv, Base64URL p2s, int p2c, Base64URL iv, Base64URL tag, Map<String,Object> customParams, Base64URL parsedBase64URL)
Note: Use PlainHeader
to create a header with algorithm
none
.
alg
- The JWE algorithm (alg
) parameter.
Must not be "none" or null
.enc
- The encryption method parameter. Must not be
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.epk
- The Ephemeral Public Key (epk
)
parameter, null
if not specified.zip
- The compression algorithm (zip
)
parameter, null
if not specified.apu
- The agreement PartyUInfo (apu
)
parameter, null
if not specified.apv
- The agreement PartyVInfo (apv
)
parameter, null
if not specified.p2s
- The PBES2 salt (p2s
) parameter,
null
if not specified.p2c
- The PBES2 count (p2c
) parameter, zero
if not specified. Must not be negative.iv
- The initialisation vector (iv
)
parameter, null
if not specified.tag
- The authentication tag (tag
)
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 JWEAlgorithm getAlgorithm()
alg
) parameter.getAlgorithm
in class Header
public EncryptionMethod getEncryptionMethod()
enc
) parameter.public JWK getEphemeralPublicKey()
epk
) parameter.null
if not
specified.public CompressionAlgorithm getCompressionAlgorithm()
zip
) parameter.null
if not
specified.public Base64URL getAgreementPartyUInfo()
apu
) parameter.null
if not
specified.public Base64URL getAgreementPartyVInfo()
apv
) parameter.null
if not
specified.public Base64URL getPBES2Salt()
p2s
) parameter.null
if not specified.public int getPBES2Count()
p2c
) parameter.public Base64URL getIV()
iv
) parameter.null
if not specified.public Base64URL getAuthTag()
tag
) parameter.null
if not specified.public Set<String> getIncludedParams()
Header
public net.minidev.json.JSONObject toJSONObject()
Header
public static JWEHeader 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 JWE header.public static JWEHeader 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 JWE header.public static JWEHeader parse(String jsonString) throws ParseException
jsonString
- The JSON object string to parse. Must not be null
.ParseException
- If the specified JSON object string doesn't
represent a valid JWE header.public static JWEHeader 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 JWE header.public static JWEHeader parse(Base64URL base64URL) throws ParseException
base64URL
- The Base64URL to parse. Must not be null
.ParseException
- If the specified Base64URL doesn't represent
a valid JWE 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.@Deprecated 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.Copyright © 2019 Connect2id Ltd.. All rights reserved.