Package org.jose4j.jwe
Class JsonWebEncryption
java.lang.Object
org.jose4j.jwx.JsonWebStructure
org.jose4j.jwe.JsonWebEncryption
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Base64Url(package private) byte[]static final shortprivate AlgorithmConstraints(package private) byte[]private CryptoPrimitiveprivate static final AlgorithmConstraints(package private) byte[](package private) byte[]private byte[]private StringFields inherited from class org.jose4j.jwx.JsonWebStructure
doKeyValidation, headers, rawCompactSerialization -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckCek(ContentEncryptionAlgorithm contentEncryptionAlg, ContentEncryptionKeyDescriptor contentEncryptionKeyDesc, byte[] rawCek) (package private) byte[]private CryptoPrimitive(package private) byte[]decompress(Headers headers, byte[] data) private voiddecrypt()voidbyte[](package private) byte[]byte[]byte[]getIv()(package private) KeyManagementAlgorithmgetKeyManagementModeAlgorithm(boolean checkConstraints) 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 org.jose4j.jwx.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, toString
-
Field Details
-
COMPACT_SERIALIZATION_PARTS
public static final short COMPACT_SERIALIZATION_PARTS- See Also:
-
DEFAULT_BLOCKED
-
base64url
-
plaintextCharEncoding
-
plaintext
private byte[] plaintext -
encryptedKey
byte[] encryptedKey -
iv
byte[] iv -
ciphertext
byte[] ciphertext -
contentEncryptionKey
byte[] contentEncryptionKey -
contentEncryptionAlgorithmConstraints
-
decryptingPrimitive
-
-
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
-
getKeyManagementModeAlgorithm
KeyManagementAlgorithm getKeyManagementModeAlgorithm(boolean checkConstraints) throws InvalidAlgorithmException - 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
-
createDecryptingPrimitive
- Throws:
JoseException
-
decrypt
- Throws:
JoseException
-
checkCek
private void checkCek(ContentEncryptionAlgorithm contentEncryptionAlg, ContentEncryptionKeyDescriptor contentEncryptionKeyDesc, byte[] rawCek) throws InvalidKeyException - Throws:
InvalidKeyException
-
getEncryptedKey
public byte[] getEncryptedKey() -
getEncodedHeaderAsciiBytesForAdditionalAuthenticatedData
byte[] getEncodedHeaderAsciiBytesForAdditionalAuthenticatedData() -
decompress
- Throws:
JoseException
-
compress
- Throws:
InvalidAlgorithmException
-
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
-