java.lang.Object
iu.crypt.Jwe
- All Implemented Interfaces:
WebEncryption
JSON Web Encryption (JWE) implementation class.
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.iu.crypt.WebEncryption
WebEncryption.Builder, WebEncryption.Encryption
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJwe
(WebEncryption.Encryption encryption, boolean deflate, boolean compact, Set<String> protectedParameters, Iterable<JweRecipient> recipients, byte[] contentEncryptionKey, byte[] additionalData, InputStream in) Encrypts an outbound message.Verifies and prepares decryption of an inbound encrypted message. -
Method Summary
Modifier and TypeMethodDescriptioncompact()
Gets the message encrypted for only this recipient in compact JWE format.void
decrypt
(WebKey key, OutputStream out) Decrypts the encrypted content.byte[]
Gets the aad JWE attributebyte[]
Gets the tag JWE attributebyte[]
Gets the ciphertext JWE attributeGets the encryption algorithm.byte[]
Gets the iv JWE attributeGets the recipients.boolean
Determines whether or not to compress content before encryption.toString()
Gets the encrypted message in serialized JWE format.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.iu.crypt.WebEncryption
decrypt, decryptText
-
Field Details
-
JSON
-
-
Constructor Details
-
Jwe
Jwe(WebEncryption.Encryption encryption, boolean deflate, boolean compact, Set<String> protectedParameters, Iterable<JweRecipient> recipients, byte[] contentEncryptionKey, byte[] additionalData, InputStream in) Encrypts an outbound message.- Parameters:
encryption
- content encryption algorithmdeflate
- true to compress content before encryption; false to encrypt uncompressedcompact
- true to verify as compact serializableprotectedParameters
- parameter names to enforce as shared and include in the protected header, ignored when compact = truerecipients
- message recipientscontentEncryptionKey
- content encryption keyadditionalData
- AEAD additional authentication datain
- provides the plain text data to be encrypted
-
Jwe
Verifies and prepares decryption of an inbound encrypted message.- Parameters:
jwe
- inbound encrypted message
-
-
Method Details
-
getEncryption
Description copied from interface:WebEncryption
Gets the encryption algorithm.- Specified by:
getEncryption
in interfaceWebEncryption
- Returns:
- encryption algorithm
-
isDeflate
public boolean isDeflate()Description copied from interface:WebEncryption
Determines whether or not to compress content before encryption.- Specified by:
isDeflate
in interfaceWebEncryption
- Returns:
- true to compress content before encrypting; false to encrypt as-is
-
getRecipients
Description copied from interface:WebEncryption
Gets the recipients.- Specified by:
getRecipients
in interfaceWebEncryption
- Returns:
- recipients
-
getInitializationVector
public byte[] getInitializationVector()Description copied from interface:WebEncryption
Gets the iv JWE attribute- Specified by:
getInitializationVector
in interfaceWebEncryption
- Returns:
- iv JWE attribute
-
getCipherText
public byte[] getCipherText()Description copied from interface:WebEncryption
Gets the ciphertext JWE attribute- Specified by:
getCipherText
in interfaceWebEncryption
- Returns:
- ciphertext JWE attribute
-
getAuthenticationTag
public byte[] getAuthenticationTag()Description copied from interface:WebEncryption
Gets the tag JWE attribute- Specified by:
getAuthenticationTag
in interfaceWebEncryption
- Returns:
- tag JWE attribute
-
getAdditionalData
public byte[] getAdditionalData()Description copied from interface:WebEncryption
Gets the aad JWE attribute- Specified by:
getAdditionalData
in interfaceWebEncryption
- Returns:
- aad JWE attribute
-
decrypt
Description copied from interface:WebEncryption
Decrypts the encrypted content.- Specified by:
decrypt
in interfaceWebEncryption
- Parameters:
key
- private or secret key; should be verified by the application as correct for the recipient before calling.out
-OutputStream
to write the decrypted content to
-
compact
Description copied from interface:WebEncryption
Gets the message encrypted for only this recipient in compact JWE format.- Specified by:
compact
in interfaceWebEncryption
- Returns:
- compact JWE
-
toString
Description copied from interface:WebEncryption
Gets the encrypted message in serialized JWE format.- Specified by:
toString
in interfaceWebEncryption
- Overrides:
toString
in classObject
- Returns:
- serialized JWE
-