Interface CMSEncryptionService


public interface CMSEncryptionService
Interface for performing content-stream encryption and decryption.
  • Method Details

    • buildEncryptionOutputStream

      OutputStream buildEncryptionOutputStream(OutputStream dataContentStream, Set<PublicKeyIDWithPublicKey> publicKeys)
      Builds asymmetrically encrypted stream using public-key cryptography.
      Parameters:
      dataContentStream - Stream to encrypt
      publicKeys - Contains user public key and public-key ID which gets embedded into a stream, used for finding the private key to decrypt
      Returns:
      Encrypted stream that wraps dataContentStream
    • buildEncryptionOutputStream

      OutputStream buildEncryptionOutputStream(OutputStream dataContentStream, SecretKey secretKey, KeyID secretKeyID)
      Builds symmetrically encrypted stream.
      Parameters:
      dataContentStream - Stream to encrypt
      secretKey - User secret key
      secretKeyID - User key ID gets embedded into a stream, used for finding the key to decrypt
      Returns:
      Encrypted stream that wraps dataContentStream
    • buildDecryptionInputStream

      InputStream buildDecryptionInputStream(InputStream inputStream, Function<Set<String>,Map<String,Key>> keysByIds)
      Builds decrypted stream out of encrypted one.
      Parameters:
      inputStream - Stream to decrypt
      keysByIds - Key to its ID mapping function - you request for the set of key aliases and function returns only those that were found as a map (key id - key), will retrieve key for decryption using this. Implemented as a request once for many instead of iterating one-by-one to avoid possible concurrency issues.
      Returns:
      Decrypted stream that wraps inputStream