Package edu.iu.crypt

Interface WebEncryption

All Known Implementing Classes:
Jwe

public interface WebEncryption
Unifies algorithm support and maps from JCE encryption to JSON Web Encryption (JWE).
See Also:
  • Method Details

    • to

      Starts a new encrypted message for a single recipient with compact semantics and compression enabled.
      Parameters:
      encryption - content encryption algorithm
      algorithm - key encryption algorithm
      Returns:
      WebEncryptionRecipient.Builder
    • builder

      static WebEncryption.Builder builder(WebEncryption.Encryption encryption)
      Starts a new encrypted message with compression enabled.
      Parameters:
      encryption - encryption algorithm
      Returns:
      WebEncryption.Builder
    • builder

      static WebEncryption.Builder builder(WebEncryption.Encryption encryption, boolean deflate)
      Starts a new encrypted message.
      Parameters:
      encryption - encryption algorithm
      deflate - true to compress content; false to encrypt without compression
      Returns:
      WebEncryption.Builder
    • parse

      static WebEncryption parse(String jwe)
      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

      default String decryptText(WebKey key)
      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

      default byte[] decrypt(WebKey key)
      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

      void decrypt(WebKey key, OutputStream out)
      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.
      Overrides:
      toString in class Object
      Returns:
      serialized JWE