Package org.digidoc4j

Interface Container

All Superinterfaces:
Serializable
All Known Subinterfaces:
CompositeContainer
All Known Implementing Classes:
AsicContainer, AsicEContainer, AsicSCompositeContainer, AsicSContainer, BDocContainer, DDocContainer, PadesContainer

public interface Container extends Serializable
Offers functionality for handling data files and signatures in a container.

A container can contain several files and all those files can be signed using signing certificates. A container can only be signed if it contains data files.

Data files can be added and removed from a container only if the container is not signed. To modify the data list of a signed container by adding or removing datafiles you must first remove all the signatures.

  • Method Details

    • addDataFile

      DataFile addDataFile(String path, String mimeType)
      Adds a data file from the file system to the container.

      Note: Data files can be added to a container only after all signatures have been removed.

      Parameters:
      path - data file to be added to the container
      mimeType - MIME type of the data file, for example 'text/plain' or 'application/msword'
      Returns:
      data file
    • addDataFile

      DataFile addDataFile(InputStream is, String fileName, String mimeType)
      Adds a data file from the input stream (i.e. the date file content can be read from the internal memory buffer).

      Note: Data files can be added to a container only after all signatures have been removed.

      Parameters:
      is - input stream from where data is read
      fileName - data file name in the container
      mimeType - MIME type of the data file, for example 'text/plain' or 'application/msword'
      Returns:
      data file
    • addDataFile

      DataFile addDataFile(File file, String mimeType)
      Adds a data file from the file system to the container.

      Note: Data files can be added to a container only after all signatures have been removed.

      Parameters:
      file - data file to be added to the container
      mimeType - MIME type of the data file, for example 'text/plain' or 'application/msword'
      Returns:
      data file
    • addDataFile

      void addDataFile(DataFile dataFile)
      Adds the specified data file to the container.

      Note: Data files can be added to a container only after all signatures have been removed.

      Parameters:
      dataFile - data file to be added to the container
    • addSignature

      void addSignature(Signature signature)
      Adds a new signature to the container.
      Parameters:
      signature - signature to be added.
    • addTimestamp

      void addTimestamp(Timestamp timestamp)
      Adds a new timestamp token covering the contents of this container.
      Parameters:
      timestamp - timestamp to add to this container
    • getDataFiles

      List<DataFile> getDataFiles()
      Returns the list of data files in the container.
      Returns:
      list of data files in the container
    • getType

      String getType()
      Returns the type of the container. The known container types are the following: Custom implementations of this interface may return other custom types.
      Returns:
      type of the container
    • getSignatures

      List<Signature> getSignatures()
      Returns the list of signatures in the container.
      Returns:
      list of signatures in the container
    • getTimestamps

      default List<Timestamp> getTimestamps()
      Returns the list of timestamp tokens that cover the contents of this container.
      Returns:
      list of timestamp tokens in this container
    • removeDataFile

      void removeDataFile(DataFile file)
      Removes the data file from the container.

      Note: Data files can be removed from a container only after all signatures have been removed.

      Parameters:
      file - data file to be removed from the container.
    • removeSignature

      void removeSignature(Signature signature)
      Removes the signature from the container
      Parameters:
      signature - signature to be removed.
    • removeTimestamp

      void removeTimestamp(Timestamp timestamp)
      Removes the specified timestamp token from this container.

      Note: A timestamp token can be removed from a container only if the container does not contain any other timestamp tokens that cover the timestamp token to be removed.

      Parameters:
      timestamp - timestamp token to remove from this container
    • extendSignatureProfile

      void extendSignatureProfile(SignatureProfile profile)
      Extends profile of all signatures to SignatureProfile
      Parameters:
      profile - signature profile
      See Also:
    • extendSignatureProfile

      void extendSignatureProfile(SignatureProfile profile, List<Signature> signaturesToExtend)
      Extends profile of selected signatures to SignatureProfile
      Parameters:
      profile - signature profile
      signaturesToExtend - signatures selected for extension
      See Also:
    • saveAsFile

      File saveAsFile(String filePath)
      Saves the container to the specified location.
      Parameters:
      filePath - file name and path.
    • saveAsStream

      InputStream saveAsStream()
      Saves the container as a stream.
      Returns:
      stream of the container.
    • save

      void save(OutputStream out)
      Saves the container to the java.io.OutputStream.
      Parameters:
      out - output stream.
      See Also:
    • validate

      Validate container
      Returns:
      validation result
    • setTimeStampToken

      @Deprecated void setTimeStampToken(DataFile timeStampToken)
      Deprecated.
      Deprecated for removal. Use addTimestamp(Timestamp) instead.
      Adds timestamp token
      Parameters:
      timeStampToken - timestamp token
    • getTimeStampToken

      @Deprecated DataFile getTimeStampToken()
      Deprecated.
      Deprecated for removal. Use getTimestamps() instead.
      Returns timestamp token
      Returns:
      TimestampToken
    • getConfiguration

      Configuration getConfiguration()
      Gets Configuration
      Returns:
      Configuration