Interface MultiRecipientContent

All Superinterfaces:
AutoCloseable, DataContent, Destroyable

public interface MultiRecipientContent extends DataContent, Destroyable, AutoCloseable
Represents one-shot multi-recipient content that owns temporary recipient resources until processing or explicit cleanup.

Callers must invoke close() when a built instance is abandoned before getStream() is called. Successful or failed stream construction also releases the owned recipient resources. Unlocking keys and password material supplied separately remain caller-owned and are never destroyed by this content.

Implementations are not thread-safe. Cleanup is idempotent, and content cannot be used after cleanup. Calling getStream() is terminal even when stream construction fails.

  • Field Summary

    Fields inherited from interface DataContent

    DEFAULT_MAX_READ_SIZE
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases all recipient resources still owned by this content.
    void
    Destroys all recipient resources still owned by this content.
    Creates the processed stream and releases all recipient resources.
    boolean
    Reports whether this content has released its recipient resources.
    void
    Connects the upstream content before the one processing attempt.

    Methods inherited from interface DataContent

    toBytes, toText
  • Method Details

    • setInput

      void setInput(DataContent input)
      Connects the upstream content before the one processing attempt.
      Specified by:
      setInput in interface DataContent
      Parameters:
      input - non-null upstream plaintext or encrypted content
      Throws:
      NullPointerException - if input is null
      IllegalStateException - if this content has already processed input or has been closed
    • getStream

      InputStream getStream() throws IOException
      Creates the processed stream and releases all recipient resources.

      This method may be called only once. Recipient resources are released before it returns or throws. On success, the caller owns the returned stream and must close it; closing this content does not replace closing an already returned stream.

      Specified by:
      getStream in interface DataContent
      Returns:
      the encrypted or decrypted stream
      Throws:
      IOException - if envelope processing, cryptographic stream creation, or resource cleanup fails
      NullPointerException - if no upstream content was supplied
      IllegalStateException - if this content has already processed input or has been closed
    • close

      void close() throws IOException
      Releases all recipient resources still owned by this content.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException - if an owned context cannot be closed
    • destroy

      void destroy() throws DestroyFailedException
      Destroys all recipient resources still owned by this content.
      Specified by:
      destroy in interface Destroyable
      Throws:
      DestroyFailedException - if cleanup fails
    • isDestroyed

      boolean isDestroyed()
      Reports whether this content has released its recipient resources.
      Specified by:
      isDestroyed in interface Destroyable
      Returns:
      true after processing, close(), or destroy()