Package org.jose4j.jwe
Class JsonWebEncryption
java.lang.Object
org.jose4j.jwx.JsonWebStructure
org.jose4j.jwe.JsonWebEncryption
-
Field Summary
FieldsFields inherited from class org.jose4j.jwx.JsonWebStructure
doKeyValidation, headers, rawCompactSerialization
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
byte[]
byte[]
byte[]
getIv()
byte[]
Create, initialize and return theCryptoPrimitive
that this JWE instance will use for agreement or decryption of the content encryption key.protected void
setCompactSerializationParts
(String[] parts) void
void
setContentEncryptionAlgorithmConstraints
(AlgorithmConstraints contentEncryptionAlgorithmConstraints) void
setContentEncryptionKey
(byte[] contentEncryptionKey) void
setEncodedContentEncryptionKey
(String encodedContentEncryptionKey) void
setEncodedIv
(String encodedIv) void
void
setIv
(byte[] iv) void
setPayload
(String payload) void
setPlaintext
(byte[] plaintext) void
setPlaintext
(String plaintext) void
setPlainTextCharEncoding
(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:
-
-
Constructor Details
-
JsonWebEncryption
public JsonWebEncryption()
-
-
Method Details
-
setPlainTextCharEncoding
-
setPlaintext
public void setPlaintext(byte[] plaintext) -
setPlaintext
-
getPlaintextString
- Throws:
JoseException
-
getPlaintextBytes
- Throws:
JoseException
-
getPayload
- Specified by:
getPayload
in classJsonWebStructure
- Throws:
JoseException
-
setPayload
- Specified by:
setPayload
in classJsonWebStructure
-
setEncryptionMethodHeaderParameter
-
getEncryptionMethodHeaderParameter
-
setCompressionAlgorithmHeaderParameter
-
getCompressionAlgorithmHeaderParameter
-
enableDefaultCompression
public void enableDefaultCompression() -
setContentEncryptionAlgorithmConstraints
public void setContentEncryptionAlgorithmConstraints(AlgorithmConstraints contentEncryptionAlgorithmConstraints) -
getContentEncryptionAlgorithm
- Throws:
InvalidAlgorithmException
-
getKeyManagementModeAlgorithm
- Throws:
InvalidAlgorithmException
-
getAlgorithmNoConstraintCheck
- Specified by:
getAlgorithmNoConstraintCheck
in classJsonWebStructure
- Throws:
InvalidAlgorithmException
-
getAlgorithm
- Specified by:
getAlgorithm
in classJsonWebStructure
- Throws:
InvalidAlgorithmException
-
setCompactSerializationParts
- Specified by:
setCompactSerializationParts
in classJsonWebStructure
- Throws:
JoseException
-
prepareDecryptingPrimitive
Create, initialize and return theCryptoPrimitive
that 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:
getCompactSerialization
in 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
-