Class SignatureTrailerDataContentBuilder

java.lang.Object
zeroecho.sdk.builders.SignatureTrailerDataContentBuilder
All Implemented Interfaces:
DataContentBuilder<DataContent>

public final class SignatureTrailerDataContentBuilder extends Object implements DataContentBuilder<DataContent>
Signature-specific trailer builder for DataContent pipelines.

This class is intended as a convenient, signature-specialized replacement for:

new TagTrailerDataContentBuilder<Signature>(engine).bufferSize(8192)
new TagTrailerDataContentBuilder<Signature>(engine).bufferSize(8192).throwOnMismatch()

It keeps TagTrailerDataContentBuilder as the generic implementation while providing a compact API for Signature usage, including construction of SignatureContext for both single-algorithm and hybrid signatures.

Mode selection

Context construction is in-memory. Checked I/O failures arise only when a built stream is attached or processed.

Since:
1.0
  • Method Details

    • core

      Core mode: wraps a fixed engine instance.

      This is the direct signature-specialized equivalent of: new TagTrailerDataContentBuilder<Signature>(engine).

      Parameters:
      engine - signature engine (typically a SignatureContext); must not be null
      Returns:
      builder instance
      Throws:
      NullPointerException - if engine is null
      Since:
      1.0
    • core

      public static SignatureTrailerDataContentBuilder core(Supplier<? extends TagEngine<Signature>> engineFactory)
      Core mode: wraps an engine factory.

      This is the direct signature-specialized equivalent of: new TagTrailerDataContentBuilder<Signature>(engineFactory).

      Parameters:
      engineFactory - engine factory; must not be null
      Returns:
      builder instance
      Throws:
      NullPointerException - if engineFactory is null
      Since:
      1.0
    • single

      Enters single-algorithm (non-hybrid) construction helpers.
      Parameters:
      session - active session used to create signature contexts
      Returns:
      selector for creating signing/verifying builders
      Since:
      1.0
    • hybrid

      Enters hybrid signature construction helpers.
      Parameters:
      session - active session used to create signature contexts
      Returns:
      selector for creating signing/verifying builders
      Since:
      1.0
    • bufferSize

      public SignatureTrailerDataContentBuilder bufferSize(int bytes)
      Sets the internal I/O buffer size used when stripping the trailer.
      Parameters:
      bytes - buffer size in bytes; must be at least 1
      Returns:
      this builder for chaining
      Throws:
      IllegalArgumentException - if bytes < 1
      Since:
      1.0
    • throwOnMismatch

      public SignatureTrailerDataContentBuilder throwOnMismatch()
      Configures verification to throw on mismatch (default verification behavior).
      Returns:
      this builder for chaining
      Since:
      1.0
    • flagInContext

      public SignatureTrailerDataContentBuilder flagInContext(CtxInterface ctx, Key<Boolean> verifyKey)
      Instead of throwing on mismatch, records the verification outcome into a context flag.
      Parameters:
      ctx - context instance to receive the flag; must not be null
      verifyKey - key under which the Boolean result is recorded; must not be null
      Returns:
      this builder for chaining
      Throws:
      NullPointerException - if ctx or verifyKey is null
      Since:
      1.0
    • build

      public DataContent build(boolean encrypt)
      Description copied from interface: DataContentBuilder
      Constructs and returns a new DataContent instance based on the builder's current configuration.
      Specified by:
      build in interface DataContentBuilder<DataContent>
      Parameters:
      encrypt - whether the resulting DataContent should be configured for encryption (true) or decryption (false). In encryption mode, additional headers or metadata may be inserted into the stream which must be retained for successful decryption.
      Returns:
      the constructed DataContent instance