Package com.nimbusds.jose
Class JWEHeader.Builder
java.lang.Object
com.nimbusds.jose.JWEHeader.Builder
- Enclosing class:
- JWEHeader
Builder for constructing JSON Web Encryption (JWE) headers.
Example usage:
JWEHeader header = new JWEHeader.Builder(JWEAlgorithm.RSA1_5, EncryptionMethod.A128GCM) .contentType("text/plain") .customParam("exp", new Date().getTime()) .build();
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder
(EncryptionMethod enc) Creates a new JWE header builder.Builder
(JWEAlgorithm alg, EncryptionMethod enc) Creates a new JWE header builder.Creates a new JWE header builder with the parameters from the specified header. -
Method Summary
Modifier and TypeMethodDescriptionSets the agreement PartyUInfo (apu
) parameter.Sets the agreement PartyVInfo (apv
) parameter.alg
(JWEAlgorithm alg) Sets the algorithm (alg
) parameter.Sets the audience (aud
) parameter as a replicated claim.Sets the authentication tag (tag
) parameter.build()
Builds a new JWE header.Sets the compression algorithm (zip
) parameter.contentType
(String cty) Sets the content type (cty
) parameter.criticalParams
(Set<String> crit) Sets the critical header parameters (crit
) parameter.customParam
(String name, Object value) Sets a custom (non-registered) parameter.customParams
(Map<String, Object> customParameters) Sets the custom (non-registered) parameters.ephemeralPublicKey
(JWK epk) Sets the Ephemeral Public Key (epk
) parameter.Sets the issuer (iss
) parameter as a replicated claim.Sets the initialisation vector (iv
) parameter.Sets the public JSON Web Key (JWK) (jwk
) parameter.Sets the public JSON Web Key (JWK) Set URL (jku
) parameter.Sets the key ID (kid
) parameter.parsedBase64URL
(Base64URL base64URL) Sets the parsed Base64URL.pbes2Count
(int p2c) Sets the PBES2 count (p2c
) parameter.Sets the PBES2 salt (p2s
) parameter.senderKeyID
(String skid) Sets the sender key ID (skid
) parameter.Sets the subject (sub
) parameter as a replicated claim.type
(JOSEObjectType typ) Sets the type (typ
) parameter.x509CertChain
(List<Base64> x5c) Sets the X.509 certificate chain parameter (x5c
) corresponding to the key used to sign the JWS object.x509CertSHA256Thumbprint
(Base64URL x5t256) Sets the X.509 certificate SHA-256 thumbprint (x5t#s256
) parameter.Deprecated.x509CertURL
(URI x5u) Sets the X.509 certificate URL (x5u
) parameter.
-
Constructor Details
-
Builder
Creates a new JWE header builder.- Parameters:
alg
- The JWE algorithm (alg
) parameter. Must not be "none" ornull
.enc
- The encryption method. Must not benull
.
-
Builder
Creates a new JWE header builder. This builder is intended formulti-recipient JWE
.- Parameters:
enc
- The encryption method. Must not benull
.
-
Builder
Creates a new JWE header builder with the parameters from the specified header.- Parameters:
jweHeader
- The JWE header to use. Must not benull
.
-
-
Method Details
-
alg
Sets the algorithm (alg
) parameter.- Parameters:
alg
- The alg parameter,null
if not specified.- Returns:
- This builder.
-
type
Sets the type (typ
) parameter.- Parameters:
typ
- The type parameter,null
if not specified.- Returns:
- This builder.
-
contentType
Sets the content type (cty
) parameter.- Parameters:
cty
- The content type parameter,null
if not specified.- Returns:
- This builder.
-
criticalParams
Sets the critical header parameters (crit
) parameter.- Parameters:
crit
- The names of the critical header parameters, empty set ornull
if none.- Returns:
- This builder.
-
jwkURL
Sets the public JSON Web Key (JWK) Set URL (jku
) parameter.- Parameters:
jku
- The public JSON Web Key (JWK) Set URL parameter,null
if not specified.- Returns:
- This builder.
-
jwk
Sets the public JSON Web Key (JWK) (jwk
) parameter.- Parameters:
jwk
- The public JSON Web Key (JWK) (jwk
) parameter,null
if not specified.- Returns:
- This builder.
-
x509CertURL
Sets the X.509 certificate URL (x5u
) parameter.- Parameters:
x5u
- The X.509 certificate URL parameter,null
if not specified.- Returns:
- This builder.
-
x509CertThumbprint
Deprecated.Sets the X.509 certificate SHA-1 thumbprint (x5t
) parameter.- Parameters:
x5t
- The X.509 certificate SHA-1 thumbprint parameter,null
if not specified.- Returns:
- This builder.
-
x509CertSHA256Thumbprint
Sets the X.509 certificate SHA-256 thumbprint (x5t#s256
) parameter.- Parameters:
x5t256
- The X.509 certificate SHA-256 thumbprint parameter,null
if not specified.- Returns:
- This builder.
-
x509CertChain
Sets the X.509 certificate chain parameter (x5c
) corresponding to the key used to sign the JWS object.- Parameters:
x5c
- The X.509 certificate chain parameter,null
if not specified.- Returns:
- This builder.
-
keyID
Sets the key ID (kid
) parameter.- Parameters:
kid
- The key ID parameter,null
if not specified.- Returns:
- This builder.
-
ephemeralPublicKey
Sets the Ephemeral Public Key (epk
) parameter.- Parameters:
epk
- The Ephemeral Public Key parameter,null
if not specified.- Returns:
- This builder.
-
compressionAlgorithm
Sets the compression algorithm (zip
) parameter.- Parameters:
zip
- The compression algorithm parameter,null
if not specified.- Returns:
- This builder.
-
agreementPartyUInfo
Sets the agreement PartyUInfo (apu
) parameter.- Parameters:
apu
- The agreement PartyUInfo parameter,null
if not specified.- Returns:
- This builder.
-
agreementPartyVInfo
Sets the agreement PartyVInfo (apv
) parameter.- Parameters:
apv
- The agreement PartyVInfo parameter,null
if not specified.- Returns:
- This builder.
-
pbes2Salt
Sets the PBES2 salt (p2s
) parameter.- Parameters:
p2s
- The PBES2 salt parameter,null
if not specified.- Returns:
- This builder.
-
pbes2Count
Sets the PBES2 count (p2c
) parameter.- Parameters:
p2c
- The PBES2 count parameter, zero if not specified. Must not be negative.- Returns:
- This builder.
-
iv
Sets the initialisation vector (iv
) parameter.- Parameters:
iv
- The initialisation vector,null
if not specified.- Returns:
- This builder.
-
senderKeyID
Sets the sender key ID (skid
) parameter.- Parameters:
skid
- The sender Key ID parameter,null
if not specified.- Returns:
- This builder.
-
issuer
Sets the issuer (iss
) parameter as a replicated claim.- Parameters:
iss
- The issuer,null
if not specified.- Returns:
- This builder.
-
subject
Sets the subject (sub
) parameter as a replicated claim.- Parameters:
sub
- The subject,null
if not specified.- Returns:
- This builder.
-
audience
Sets the audience (aud
) parameter as a replicated claim.- Parameters:
aud
- The audience,null
if not specified.- Returns:
- This builder.
-
authTag
Sets the authentication tag (tag
) parameter.- Parameters:
tag
- The authentication tag,null
if not specified.- Returns:
- This builder.
-
customParam
Sets a custom (non-registered) parameter.- Parameters:
name
- The name of the custom parameter. Must not match a registered parameter name and must not benull
.value
- The value of the custom parameter, should map to a valid JSON entity,null
if not specified.- Returns:
- This builder.
- Throws:
IllegalArgumentException
- If the specified parameter name matches a registered parameter name.
-
customParams
Sets the custom (non-registered) parameters. The values must be serialisable to a JSON entity, otherwise will be ignored.- Parameters:
customParameters
- The custom parameters, empty map ornull
if none.- Returns:
- This builder.
-
parsedBase64URL
Sets the parsed Base64URL.- Parameters:
base64URL
- The parsed Base64URL,null
if the header is created from scratch.- Returns:
- This builder.
-
build
Builds a new JWE header.- Returns:
- The JWE header.
-