Class MultiEncrypter

All Implemented Interfaces:
JCAAware<JWEJCAContext>, JOSEProvider, JWEEncrypter, JWEProvider

@ThreadSafe public class MultiEncrypter extends MultiCryptoProvider implements JWEEncrypter
Multi-recipient encrypter of JWE objects.

This class is thread-safe.

Supports the following key management algorithms:

Supports the following elliptic curves:

Supports the following content encryption algorithms:

Version:
2024-04-20
Author:
Egor Puzanov, Vladimir Dzhuvinov
  • Constructor Details

    • MultiEncrypter

      Creates a new multi-recipient encrypter.
      Parameters:
      keys - The keys to encrypt to. Must not be null.
      Throws:
      KeyLengthException - If the symmetric key length is not compatible.
    • MultiEncrypter

      public MultiEncrypter(JWKSet keys, SecretKey contentEncryptionKey) throws KeyLengthException
      Creates a new multi-recipient encrypter.
      Parameters:
      keys - The keys to encrypt to. Must not be null.
      contentEncryptionKey - The content encryption key (CEK) to use. If specified its algorithm must be "AES" or "ChaCha20" and its length must match the expected for the JWE encryption method ("enc"). If null a CEK will be generated for each JWE.
      Throws:
      KeyLengthException - If the symmetric key length is not compatible.
  • Method Details

    • encrypt

      @Deprecated public JWECryptoParts encrypt(JWEHeader header, byte[] clearText) throws JOSEException
      Deprecated.
      Encrypts the specified clear text of a JWE object.
      Parameters:
      header - The JSON Web Encryption (JWE) header. Must specify a supported JWE algorithm and method. Must not be null.
      clearText - The clear text to encrypt. Must not be null.
      Returns:
      The resulting JWE crypto parts.
      Throws:
      JOSEException - If the JWE algorithm or method is not supported or if encryption failed for some other internal reason.
    • encrypt

      public JWECryptoParts encrypt(JWEHeader header, byte[] clearText, byte[] aad) throws JOSEException
      Description copied from interface: JWEEncrypter
      Encrypts the specified clear text of a JWE object.
      Specified by:
      encrypt in interface JWEEncrypter
      Parameters:
      header - The JSON Web Encryption (JWE) header. Must specify a supported JWE algorithm and method. Must not be null.
      clearText - The clear text to encrypt. Must not be null.
      aad - The additional authenticated data. Must not be null.
      Returns:
      The resulting JWE crypto parts.
      Throws:
      JOSEException - If the JWE algorithm or method is not supported or if encryption failed for some other internal reason.