Class JsonWebEncryption
java.lang.Object
org.jose4j.jwx.JsonWebStructure
org.jose4j.jwe.JsonWebEncryption
-
Field Summary
FieldsFields inherited from class JsonWebStructure
doKeyValidation, headers, rawCompactSerialization -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbyte[]byte[]byte[]getIv()byte[]Create, initialize and return theCryptoPrimitivethat this JWE instance will use for agreement or decryption of the content encryption key.protected voidsetCompactSerializationParts(String[] parts) voidvoidsetContentEncryptionAlgorithmConstraints(AlgorithmConstraints contentEncryptionAlgorithmConstraints) voidsetContentEncryptionKey(byte[] contentEncryptionKey) voidsetEncodedContentEncryptionKey(String encodedContentEncryptionKey) voidsetEncodedIv(String encodedIv) voidvoidsetIv(byte[] iv) voidsetPayload(String payload) voidsetPlaintext(byte[] plaintext) voidsetPlaintext(String plaintext) voidsetPlainTextCharEncoding(String plaintextCharEncoding) Methods inherited from class JsonWebStructure
checkCrit, checkNotEmptyPart, fromCompactSerialization, getAlgorithmConstraints, getAlgorithmHeaderValue, getCertificateChainHeaderValue, getContentTypeHeaderValue, getEncodedHeader, getHeader, getHeader, getHeaders, getIntegrity, getJwkHeader, getKey, getKeyIdHeaderValue, getLeafCertificateHeaderValue, getObjectHeader, getProviderCtx, getX509CertSha1ThumbprintHeaderValue, getX509CertSha256ThumbprintHeaderValue, isDoKeyValidation, isSupportedCriticalHeader, onNewKey, setAlgorithmConstraints, setAlgorithmHeaderValue, setCertificateChainHeaderValue, setCompactSerialization, setContentTypeHeaderValue, setCriticalHeaderNames, setDoKeyValidation, setEncodedHeader, setHeader, setHeader, setIntegrity, setJwkHeader, setKey, setKeyIdHeaderValue, setKnownCriticalHeaders, setProviderContext, setX509CertSha1ThumbprintHeaderValue, setX509CertSha1ThumbprintHeaderValue, setX509CertSha256ThumbprintHeaderValue, setX509CertSha256ThumbprintHeaderValue, toStringModifier and TypeMethodDescriptionprotected voidprotected voidcheckNotEmptyPart(String encodedPart, String partName) static JsonWebStructureprotected AlgorithmConstraintsprotected StringDeprecated.protected byte[]Gets the "jwk" (JSON Web Key) Header Parameter per https://tools.ietf.org/html/rfc7515#section-4.1.3 and/or https://tools.ietf.org/html/rfc7516#section-4.1.5getKey()getObjectHeader(String name) protected ProviderContextbooleanprotected booleanisSupportedCriticalHeader(String headerName) protected voidonNewKey()voidsetAlgorithmConstraints(AlgorithmConstraints algorithmConstraints) voidvoidvoidsetCompactSerialization(String compactSerialization) voidvoidsetCriticalHeaderNames(String... headerNames) Sets the value(s) of the critical ("crit") header, defined in section 4.1.11 of RFC 7515, which indicates that those headers MUST be understood and processed by the recipient.voidsetDoKeyValidation(boolean doKeyValidation) protected voidsetEncodedHeader(String encodedHeader) voidvoidprotected voidsetIntegrity(byte[] integrity) voidSets the "jwk" (JSON Web Key) Header Parameter per https://tools.ietf.org/html/rfc7515#section-4.1.3 and/or https://tools.ietf.org/html/rfc7516#section-4.1.5voidvoidvoidsetKnownCriticalHeaders(String... knownCriticalHeaders) Sets the values of the critical ("crit") header that are acceptable for the library to process.voidsetProviderContext(ProviderContext providerCtx) Sets theProviderContextfor this JWS or JWE, which allows for a particular Java Cryptography Architecture provider to be indicated by name to be used for various cryptographic operations.voidvoidsetX509CertSha1ThumbprintHeaderValue(X509Certificate certificate) voidvoidsetX509CertSha256ThumbprintHeaderValue(X509Certificate certificate) toString()
-
Field Details
-
COMPACT_SERIALIZATION_PARTS
public static final short COMPACT_SERIALIZATION_PARTS- See Also:
-
-
Constructor Details
-
JsonWebEncryption
public JsonWebEncryption()
-
-
Method Details
-
setPlainTextCharEncoding
-
setPlaintext
public void setPlaintext(byte[] plaintext) -
setPlaintext
-
getPlaintextString
- Throws:
JoseException
-
getPlaintextBytes
- Throws:
JoseException
-
getPayload
- Specified by:
getPayloadin classJsonWebStructure- Throws:
JoseException
-
setPayload
- Specified by:
setPayloadin classJsonWebStructure
-
setEncryptionMethodHeaderParameter
-
getEncryptionMethodHeaderParameter
-
setCompressionAlgorithmHeaderParameter
-
getCompressionAlgorithmHeaderParameter
-
enableDefaultCompression
public void enableDefaultCompression() -
setContentEncryptionAlgorithmConstraints
public void setContentEncryptionAlgorithmConstraints(AlgorithmConstraints contentEncryptionAlgorithmConstraints) -
getContentEncryptionAlgorithm
- Throws:
InvalidAlgorithmException
-
getKeyManagementModeAlgorithm
- Throws:
InvalidAlgorithmException
-
getAlgorithmNoConstraintCheck
- Specified by:
getAlgorithmNoConstraintCheckin classJsonWebStructure- Throws:
InvalidAlgorithmException
-
getAlgorithm
- Specified by:
getAlgorithmin classJsonWebStructure- Throws:
InvalidAlgorithmException
-
setCompactSerializationParts
- Specified by:
setCompactSerializationPartsin classJsonWebStructure- Throws:
JoseException
-
prepareDecryptingPrimitive
Create, initialize and return theCryptoPrimitivethat this JWE instance will use for agreement or decryption of the content encryption key. This can optionally be called after setting the key (and maybe ProviderContext) but before getting the payload (which is when the decryption magic happens). This method provides access to the underlying primitive instance (e.g. aCipher), which allows execution of the operation to be gated by some approval or authorization. For example, signing on Android with a key that was set to require user authentication when created needs a biometric prompt to allow the signature to execute with the key.- Returns:
- a CryptoPrimitive containing either a
Cipher,KeyAgreement, etc., or null - Throws:
JoseException- if an error condition is encountered during the initialization process
-
getEncryptedKey
public byte[] getEncryptedKey() -
getCompactSerialization
- Specified by:
getCompactSerializationin classJsonWebStructure- Throws:
JoseException
-
getContentEncryptionKey
public byte[] getContentEncryptionKey() -
setContentEncryptionKey
public void setContentEncryptionKey(byte[] contentEncryptionKey) -
setEncodedContentEncryptionKey
-
getIv
public byte[] getIv() -
setIv
public void setIv(byte[] iv) -
setEncodedIv
-
JsonWebStructure.getHeaders()andHeaders.getFullHeaderAsJsonString()