- All Known Implementing Classes:
Jwe
public interface WebEncryption
Unifies algorithm support and maps from JCE encryption to JSON Web Encryption
(JWE).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePrepares a new encrypted message.static enumEnumerates content encryption algorithms. -
Method Summary
Modifier and TypeMethodDescriptionstatic WebEncryption.Builderbuilder(WebEncryption.Encryption encryption) Starts a new encrypted message with compression enabled.static WebEncryption.Builderbuilder(WebEncryption.Encryption encryption, boolean deflate) Starts a new encrypted message.compact()Gets the message encrypted for only this recipient in compact JWE format.default byte[]Decrypts the encrypted content.voiddecrypt(WebKey key, OutputStream out) Decrypts the encrypted content.default StringdecryptText(WebKey key) Decrypts UTF-8 encoded 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 attributeIterable<? extends WebEncryptionRecipient> Gets the recipients.booleanDetermines whether or not to compress content before encryption.static WebEncryptionParses a compact or serialized JWE.static WebEncryptionRecipient.Builder<?> to(WebEncryption.Encryption encryption, WebKey.Algorithm algorithm) Starts a new encrypted message for a single recipient withcompact semanticsand compression enabled.toString()Gets the encrypted message in serialized JWE format.
-
Method Details
-
to
static WebEncryptionRecipient.Builder<?> to(WebEncryption.Encryption encryption, WebKey.Algorithm algorithm) Starts a new encrypted message for a single recipient withcompact semanticsand compression enabled.- Parameters:
encryption-content encryption algorithmalgorithm-key encryption algorithm- Returns:
WebEncryptionRecipient.Builder
-
builder
Starts a new encrypted message with compression enabled.- Parameters:
encryption-encryption algorithm- Returns:
WebEncryption.Builder
-
builder
Starts a new encrypted message.- Parameters:
encryption-encryption algorithmdeflate- true to compress content; false to encrypt without compression- Returns:
WebEncryption.Builder
-
parse
Parses a compact or serialized JWE.- Parameters:
jwe- compact or serialized JWE- Returns:
WebEncryption
-
getEncryption
WebEncryption.Encryption getEncryption()Gets the encryption algorithm.- Returns:
- encryption algorithm
-
isDeflate
boolean isDeflate()Determines whether or not to compress content before encryption.- Returns:
- true to compress content before encrypting; false to encrypt as-is
-
getRecipients
Iterable<? extends WebEncryptionRecipient> getRecipients()Gets the recipients.- Returns:
- recipients
-
getInitializationVector
byte[] getInitializationVector()Gets the iv JWE attribute- Returns:
- iv JWE attribute
-
getCipherText
byte[] getCipherText()Gets the ciphertext JWE attribute- Returns:
- ciphertext JWE attribute
-
getAuthenticationTag
byte[] getAuthenticationTag()Gets the tag JWE attribute- Returns:
- tag JWE attribute
-
getAdditionalData
byte[] getAdditionalData()Gets the aad JWE attribute- Returns:
- aad JWE attribute
-
decryptText
Decrypts UTF-8 encoded encrypted content.- Parameters:
key- private or secret key; should be verified by the application as correct for the recipient before calling.- Returns:
- decrypted content
-
decrypt
Decrypts the encrypted content.- Parameters:
key- private or secret key; should be verified by the application as correct for the recipient before calling.- Returns:
- decrypted content
-
decrypt
Decrypts the encrypted content.- Parameters:
key- private or secret key; should be verified by the application as correct for the recipient before calling.out-OutputStreamto write the decrypted content to
-
compact
String compact()Gets the message encrypted for only this recipient in compact JWE format.- Returns:
- compact JWE
-
toString
String toString()Gets the encrypted message in serialized JWE format.
-