public class JWEHeader extends Header implements ReadOnlyJWEHeader
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" }
Constructor and Description |
---|
JWEHeader(JWEAlgorithm alg,
EncryptionMethod enc)
Creates a new JSON Web Encryption (JWE) header.
|
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. |
CompressionAlgorithm |
getCompressionAlgorithm()
Gets the compression algorithm (
zip ) parameter. |
EncryptionMethod |
getEncryptionMethod()
Gets the encryption method (
enc ) parameter. |
ECKey |
getEphemeralPublicKey()
Gets the Ephemeral Public Key (
epk ) 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. |
int |
getPBES2Count()
Gets the PBES2 count (
p2c ) parameter. |
Base64URL |
getPBES2Salt()
Gets the PBES2 salt (
p2s ) parameter. |
static Set<String> |
getReservedParameterNames()
Gets the reserved 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. |
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 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(String s)
Parses a JWE header from the specified JSON object 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(String name,
Object value)
Sets a custom (non-reserved) parameter.
|
void |
setEphemeralPublicKey(ECKey epk)
Sets the Ephemeral Public Key (
epk ) 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 |
setPBES2Count(int p2c)
Sets the PBES2 count (
p2c ) parameter. |
void |
setPBES2Salt(Base64URL p2s)
Sets the PBES2 salt (
p2s ) 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, toString
public JWEHeader(JWEAlgorithm alg, EncryptionMethod enc)
alg
- The JWE algorithm parameter. Must not be null
.enc
- The encryption method parameter. Must not be
null
.public static Set<String> getReservedParameterNames()
public JWEAlgorithm getAlgorithm()
ReadOnlyJWEHeader
alg
) parameter.getAlgorithm
in interface ReadOnlyHeader
getAlgorithm
in interface ReadOnlyJWEHeader
public EncryptionMethod getEncryptionMethod()
ReadOnlyJWEHeader
enc
) parameter.getEncryptionMethod
in interface ReadOnlyJWEHeader
public ECKey getEphemeralPublicKey()
ReadOnlyJWEHeader
epk
) parameter.getEphemeralPublicKey
in interface ReadOnlyJWEHeader
null
if not
specified.public void setEphemeralPublicKey(ECKey epk)
epk
) parameter.epk
- The Ephemeral Public Key parameter, null
if not
specified.public CompressionAlgorithm getCompressionAlgorithm()
ReadOnlyJWEHeader
zip
) parameter.getCompressionAlgorithm
in interface ReadOnlyJWEHeader
null
if not
specified.public void setCompressionAlgorithm(CompressionAlgorithm zip)
zip
) parameter.zip
- The compression algorithm parameter, null
if not
specified.public Base64URL getAgreementPartyUInfo()
ReadOnlyJWEHeader
apu
) parameter.getAgreementPartyUInfo
in interface ReadOnlyJWEHeader
null
if not
specified.public void setAgreementPartyUInfo(Base64URL apu)
apu
) parameter.apu
- The agreement PartyUInfo parameter, null
if not
specified.public Base64URL getAgreementPartyVInfo()
ReadOnlyJWEHeader
apv
) parameter.getAgreementPartyVInfo
in interface ReadOnlyJWEHeader
null
if not
specified.public void setAgreementPartyVInfo(Base64URL apv)
apv
) parameter.apv
- The agreement PartyVInfo parameter, null
if not
specified.public Base64URL getPBES2Salt()
ReadOnlyJWEHeader
p2s
) parameter.getPBES2Salt
in interface ReadOnlyJWEHeader
null
if not specified.public void setPBES2Salt(Base64URL p2s)
p2s
) parameter.p2s
- The PBES2 salt parameter, null
if not specified.public int getPBES2Count()
ReadOnlyJWEHeader
p2c
) parameter.getPBES2Count
in interface ReadOnlyJWEHeader
public void setPBES2Count(int p2c)
p2c
) parameter.p2c
- The PBES2 count parameter, zero if not specified. Must
not be negative.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 net.minidev.json.JSONObject toJSONObject()
ReadOnlyHeader
toJSONObject
in interface ReadOnlyHeader
public static JWEHeader 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 JWE header.public static JWEHeader 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 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 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.Copyright © 2013 NimbusDS. All Rights Reserved.