Package iu.crypt

Class Jwe

java.lang.Object
iu.crypt.Jwe
All Implemented Interfaces:
WebEncryption

public class Jwe extends Object implements WebEncryption
JSON Web Encryption (JWE) implementation class.
  • Field Details

  • 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 algorithm
      deflate - true to compress content before encryption; false to encrypt uncompressed
      compact - true to verify as compact serializable
      protectedParameters - parameter names to enforce as shared and include in the protected header, ignored when compact = true
      recipients - message recipients
      contentEncryptionKey - content encryption key
      additionalData - AEAD additional authentication data
      in - provides the plain text data to be encrypted
    • Jwe

      public Jwe(String jwe)
      Verifies and prepares decryption of an inbound encrypted message.
      Parameters:
      jwe - inbound encrypted message
  • Method Details

    • getEncryption

      public WebEncryption.Encryption getEncryption()
      Description copied from interface: WebEncryption
      Gets the encryption algorithm.
      Specified by:
      getEncryption in interface WebEncryption
      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 interface WebEncryption
      Returns:
      true to compress content before encrypting; false to encrypt as-is
    • getRecipients

      public Iterable<JweRecipient> getRecipients()
      Description copied from interface: WebEncryption
      Gets the recipients.
      Specified by:
      getRecipients in interface WebEncryption
      Returns:
      recipients
    • getInitializationVector

      public byte[] getInitializationVector()
      Description copied from interface: WebEncryption
      Gets the iv JWE attribute
      Specified by:
      getInitializationVector in interface WebEncryption
      Returns:
      iv JWE attribute
    • getCipherText

      public byte[] getCipherText()
      Description copied from interface: WebEncryption
      Gets the ciphertext JWE attribute
      Specified by:
      getCipherText in interface WebEncryption
      Returns:
      ciphertext JWE attribute
    • getAuthenticationTag

      public byte[] getAuthenticationTag()
      Description copied from interface: WebEncryption
      Gets the tag JWE attribute
      Specified by:
      getAuthenticationTag in interface WebEncryption
      Returns:
      tag JWE attribute
    • getAdditionalData

      public byte[] getAdditionalData()
      Description copied from interface: WebEncryption
      Gets the aad JWE attribute
      Specified by:
      getAdditionalData in interface WebEncryption
      Returns:
      aad JWE attribute
    • decrypt

      public void decrypt(WebKey key, OutputStream out)
      Description copied from interface: WebEncryption
      Decrypts the encrypted content.
      Specified by:
      decrypt in interface WebEncryption
      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

      public String compact()
      Description copied from interface: WebEncryption
      Gets the message encrypted for only this recipient in compact JWE format.
      Specified by:
      compact in interface WebEncryption
      Returns:
      compact JWE
    • toString

      public String toString()
      Description copied from interface: WebEncryption
      Gets the encrypted message in serialized JWE format.
      Specified by:
      toString in interface WebEncryption
      Overrides:
      toString in class Object
      Returns:
      serialized JWE