- 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 interface
Prepares a new encrypted message.static enum
Enumerates content encryption algorithms. -
Method Summary
Modifier and TypeMethodDescriptionstatic WebEncryption.Builder
builder
(WebEncryption.Encryption encryption) Starts a new encrypted message with compression enabled.static WebEncryption.Builder
builder
(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.void
decrypt
(WebKey key, OutputStream out) Decrypts the encrypted content.default String
decryptText
(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.boolean
Determines whether or not to compress content before encryption.static WebEncryption
Parses 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 semantics
and 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 semantics
and compression enabled.- Parameters:
encryption
-content encryption algorithm
algorithm
-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 algorithm
deflate
- 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
-OutputStream
to 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.
-