Package com.nimbusds.jose
Class JWEHeader.Builder
- java.lang.Object
-
- com.nimbusds.jose.JWEHeader.Builder
-
- Enclosing class:
- JWEHeader
public static class JWEHeader.Builder extends Object
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
Constructors Constructor Description Builder(EncryptionMethod enc)Creates a new JWE header builder.Builder(JWEAlgorithm alg, EncryptionMethod enc)Creates a new JWE header builder.Builder(JWEHeader jweHeader)Creates a new JWE header builder with the parameters from the specified header.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JWEHeader.BuilderagreementPartyUInfo(Base64URL apu)Sets the agreement PartyUInfo (apu) parameter.JWEHeader.BuilderagreementPartyVInfo(Base64URL apv)Sets the agreement PartyVInfo (apv) parameter.JWEHeader.Builderalg(JWEAlgorithm alg)Sets the algorithm (alg) parameter.JWEHeader.BuilderauthTag(Base64URL tag)Sets the authentication tag (tag) parameter.JWEHeaderbuild()Builds a new JWE header.JWEHeader.BuildercompressionAlgorithm(CompressionAlgorithm zip)Sets the compression algorithm (zip) parameter.JWEHeader.BuildercontentType(String cty)Sets the content type (cty) parameter.JWEHeader.BuildercriticalParams(Set<String> crit)Sets the critical header parameters (crit) parameter.JWEHeader.BuildercustomParam(String name, Object value)Sets a custom (non-registered) parameter.JWEHeader.BuildercustomParams(Map<String,Object> customParameters)Sets the custom (non-registered) parameters.JWEHeader.BuilderephemeralPublicKey(JWK epk)Sets the Ephemeral Public Key (epk) parameter.JWEHeader.Builderiv(Base64URL iv)Sets the initialisation vector (iv) parameter.JWEHeader.Builderjwk(JWK jwk)Sets the public JSON Web Key (JWK) (jwk) parameter.JWEHeader.BuilderjwkURL(URI jku)Sets the public JSON Web Key (JWK) Set URL (jku) parameter.JWEHeader.BuilderkeyID(String kid)Sets the key ID (kid) parameter.JWEHeader.BuilderparsedBase64URL(Base64URL base64URL)Sets the parsed Base64URL.JWEHeader.Builderpbes2Count(int p2c)Sets the PBES2 count (p2c) parameter.JWEHeader.Builderpbes2Salt(Base64URL p2s)Sets the PBES2 salt (p2s) parameter.JWEHeader.BuildersenderKeyID(String skid)Sets the sender key ID (skid) parameter.JWEHeader.Buildertype(JOSEObjectType typ)Sets the type (typ) parameter.JWEHeader.Builderx509CertChain(List<Base64> x5c)Sets the X.509 certificate chain parameter (x5c) corresponding to the key used to sign the JWS object.JWEHeader.Builderx509CertSHA256Thumbprint(Base64URL x5t256)Sets the X.509 certificate SHA-256 thumbprint (x5t#s256) parameter.JWEHeader.Builderx509CertThumbprint(Base64URL x5t)Deprecated.JWEHeader.Builderx509CertURL(URI x5u)Sets the X.509 certificate URL (x5u) parameter.
-
-
-
Constructor Detail
-
Builder
public Builder(JWEAlgorithm alg, EncryptionMethod enc)
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
public Builder(EncryptionMethod enc)
Creates a new JWE header builder. This builder is intended formulti-recipient JWE.- Parameters:
enc- The encryption method. Must not benull.
-
-
Method Detail
-
alg
public JWEHeader.Builder alg(JWEAlgorithm alg)
Sets the algorithm (alg) parameter.- Parameters:
alg- The alg parameter,nullif not specified.- Returns:
- This builder.
-
type
public JWEHeader.Builder type(JOSEObjectType typ)
Sets the type (typ) parameter.- Parameters:
typ- The type parameter,nullif not specified.- Returns:
- This builder.
-
contentType
public JWEHeader.Builder contentType(String cty)
Sets the content type (cty) parameter.- Parameters:
cty- The content type parameter,nullif not specified.- Returns:
- This builder.
-
criticalParams
public JWEHeader.Builder criticalParams(Set<String> crit)
Sets the critical header parameters (crit) parameter.- Parameters:
crit- The names of the critical header parameters, empty set ornullif none.- Returns:
- This builder.
-
jwkURL
public JWEHeader.Builder jwkURL(URI jku)
Sets the public JSON Web Key (JWK) Set URL (jku) parameter.- Parameters:
jku- The public JSON Web Key (JWK) Set URL parameter,nullif not specified.- Returns:
- This builder.
-
jwk
public JWEHeader.Builder jwk(JWK jwk)
Sets the public JSON Web Key (JWK) (jwk) parameter.- Parameters:
jwk- The public JSON Web Key (JWK) (jwk) parameter,nullif not specified.- Returns:
- This builder.
-
x509CertURL
public JWEHeader.Builder x509CertURL(URI x5u)
Sets the X.509 certificate URL (x5u) parameter.- Parameters:
x5u- The X.509 certificate URL parameter,nullif not specified.- Returns:
- This builder.
-
x509CertThumbprint
@Deprecated public JWEHeader.Builder x509CertThumbprint(Base64URL x5t)
Deprecated.Sets the X.509 certificate SHA-1 thumbprint (x5t) parameter.- Parameters:
x5t- The X.509 certificate SHA-1 thumbprint parameter,nullif not specified.- Returns:
- This builder.
-
x509CertSHA256Thumbprint
public JWEHeader.Builder x509CertSHA256Thumbprint(Base64URL x5t256)
Sets the X.509 certificate SHA-256 thumbprint (x5t#s256) parameter.- Parameters:
x5t256- The X.509 certificate SHA-256 thumbprint parameter,nullif not specified.- Returns:
- This builder.
-
x509CertChain
public JWEHeader.Builder x509CertChain(List<Base64> x5c)
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,nullif not specified.- Returns:
- This builder.
-
keyID
public JWEHeader.Builder keyID(String kid)
Sets the key ID (kid) parameter.- Parameters:
kid- The key ID parameter,nullif not specified.- Returns:
- This builder.
-
ephemeralPublicKey
public JWEHeader.Builder ephemeralPublicKey(JWK epk)
Sets the Ephemeral Public Key (epk) parameter.- Parameters:
epk- The Ephemeral Public Key parameter,nullif not specified.- Returns:
- This builder.
-
compressionAlgorithm
public JWEHeader.Builder compressionAlgorithm(CompressionAlgorithm zip)
Sets the compression algorithm (zip) parameter.- Parameters:
zip- The compression algorithm parameter,nullif not specified.- Returns:
- This builder.
-
agreementPartyUInfo
public JWEHeader.Builder agreementPartyUInfo(Base64URL apu)
Sets the agreement PartyUInfo (apu) parameter.- Parameters:
apu- The agreement PartyUInfo parameter,nullif not specified.- Returns:
- This builder.
-
agreementPartyVInfo
public JWEHeader.Builder agreementPartyVInfo(Base64URL apv)
Sets the agreement PartyVInfo (apv) parameter.- Parameters:
apv- The agreement PartyVInfo parameter,nullif not specified.- Returns:
- This builder.
-
pbes2Salt
public JWEHeader.Builder pbes2Salt(Base64URL p2s)
Sets the PBES2 salt (p2s) parameter.- Parameters:
p2s- The PBES2 salt parameter,nullif not specified.- Returns:
- This builder.
-
pbes2Count
public JWEHeader.Builder pbes2Count(int p2c)
Sets the PBES2 count (p2c) parameter.- Parameters:
p2c- The PBES2 count parameter, zero if not specified. Must not be negative.- Returns:
- This builder.
-
iv
public JWEHeader.Builder iv(Base64URL iv)
Sets the initialisation vector (iv) parameter.- Parameters:
iv- The initialisation vector,nullif not specified.- Returns:
- This builder.
-
authTag
public JWEHeader.Builder authTag(Base64URL tag)
Sets the authentication tag (tag) parameter.- Parameters:
tag- The authentication tag,nullif not specified.- Returns:
- This builder.
-
senderKeyID
public JWEHeader.Builder senderKeyID(String skid)
Sets the sender key ID (skid) parameter.- Parameters:
skid- The sender Key ID parameter,nullif not specified.- Returns:
- This builder.
-
customParam
public JWEHeader.Builder customParam(String name, Object value)
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,nullif not specified.- Returns:
- This builder.
- Throws:
IllegalArgumentException- If the specified parameter name matches a registered parameter name.
-
customParams
public JWEHeader.Builder customParams(Map<String,Object> customParameters)
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 ornullif none.- Returns:
- This builder.
-
parsedBase64URL
public JWEHeader.Builder parsedBase64URL(Base64URL base64URL)
Sets the parsed Base64URL.- Parameters:
base64URL- The parsed Base64URL,nullif the header is created from scratch.- Returns:
- This builder.
-
-