Class DefaultContainerMerger

java.lang.Object
eu.europa.esig.dss.asic.common.merge.DefaultContainerMerger
All Implemented Interfaces:
ASiCContainerMerger
Direct Known Subclasses:
AbstractASiCWithCAdESContainerMerger, AbstractASiCWithXAdESContainerMerger

public abstract class DefaultContainerMerger extends Object implements ASiCContainerMerger
This class is used to load a relevant eu.europa.esig.dss.asic.common.merge.ASiCContainerMerger in order merge content of given containers.
  • Field Details

    • DEFAULT_DIGEST_ALGORITHM

      protected static final DigestAlgorithm DEFAULT_DIGEST_ALGORITHM
      Digest algo used for internal documents comparison
    • asicContents

      protected ASiCContent[] asicContents
      An array of ASiC contents representing containers to be merged
  • Constructor Details

    • DefaultContainerMerger

      protected DefaultContainerMerger()
      Empty constructor
    • DefaultContainerMerger

      protected DefaultContainerMerger(DSSDocument... containers)
      This constructor is used to create an ASiCContainerMerger from provided container documents
      Parameters:
      containers - DSSDocuments representing containers to be merged
    • DefaultContainerMerger

      protected DefaultContainerMerger(ASiCContent... asicContents)
      This constructor is used to create an ASiCContainerMerger from to given ASiCContents
      Parameters:
      asicContents - ASiCContents to be merged
  • Method Details

    • getContainerExtractor

      protected abstract AbstractASiCContainerExtractor getContainerExtractor(DSSDocument container)
      This method returns a relevant ASiC container extractor
      Parameters:
      container - DSSDocument representing a container to be extracted
      Returns:
      AbstractASiCContainerExtractor
    • getCreationTime

      public Date getCreationTime()
      Gets the merged container result's creation time
      Returns:
      Date
    • setCreationTime

      public void setCreationTime(Date creationTime)
      Sets the creation time of the merged container result (optional)
      Parameters:
      creationTime - Date
    • fromDocuments

      public static ASiCContainerMerger fromDocuments(DSSDocument... containers)
      This method loads a relevant ASiCContainerMerger to be used to merge given container documents
      Parameters:
      containers - DSSDocument to be merged
      Returns:
      ASiCContainerMerger
    • fromASiCContents

      public static ASiCContainerMerger fromASiCContents(ASiCContent... asicContents)
      This method loads a relevant ASiCContainerMerger to be used to merge given ASiCContents
      Parameters:
      asicContents - ASiCContents to be merged
      Returns:
      ASiCContainerMerger
    • isSupported

      public boolean isSupported(DSSDocument... containers)
      Description copied from interface: ASiCContainerMerger
      Returns whether the format of given containers is supported by the current ASiCContainerMerger
      Specified by:
      isSupported in interface ASiCContainerMerger
      Parameters:
      containers - DSSDocuments to be merged
      Returns:
      TRUE if all documents are supported by the current container, FALSE otherwise
    • isSupported

      protected abstract boolean isSupported(DSSDocument container)
      This method verifies whether the provided container is supported by the current class
      Parameters:
      container - DSSDocument to verify
      Returns:
      TRUE if the container is supported, FALSE otherwise
    • isSupported

      public boolean isSupported(ASiCContent... asicContents)
      Description copied from interface: ASiCContainerMerger
      Returns whether the format of given containers is supported by the current ASiCContainerMerger
      Specified by:
      isSupported in interface ASiCContainerMerger
      Parameters:
      asicContents - ASiCContents to be merged
      Returns:
      TRUE if all containers are supported by the current container, FALSE otherwise
    • isSupported

      protected abstract boolean isSupported(ASiCContent asicContent)
      This method verifies whether the provided ASiCContent is supported by the current class
      Parameters:
      asicContent - ASiCContent to verify
      Returns:
      TRUE if the ASIC Content is supported, FALSE otherwise
    • merge

      public DSSDocument merge()
      Description copied from interface: ASiCContainerMerger
      Merges given containers to a new container document, when possible
      Specified by:
      merge in interface ASiCContainerMerger
      Returns:
      DSSDocument representing a merge result of the given ZIP-containers
    • mergeToASiCContent

      public ASiCContent mergeToASiCContent()
      Description copied from interface: ASiCContainerMerger
      Merges given containers to a single ASiCContent, when possible
      Specified by:
      mergeToASiCContent in interface ASiCContainerMerger
      Returns:
      ASiCContent representing a merge result
    • ensureContainerContentAllowMerge

      protected abstract void ensureContainerContentAllowMerge()
      Verifies whether containers can be merged
    • ensureSignaturesAllowMerge

      protected abstract void ensureSignaturesAllowMerge()
      This method is used to ensure that the entry names between the containers' entries are different
    • createMergedResult

      protected ASiCContent createMergedResult()
      This method creates a new ASiCContent by merging the given containers
      Returns:
      ASiCContent
    • createEmptyContainer

      protected ASiCContent createEmptyContainer()
      This method creates an empty container
      Returns:
      ASiCContent
    • getTargetASiCContainerType

      protected abstract ASiCContainerType getTargetASiCContainerType()
      This method returns a target ASiC Container Type of the current merger class
      Returns:
      ASiCContainerType
    • getFinalContainerName

      protected String getFinalContainerName(ASiCContainerType asicContainerType)
      This method returns a filename for the merged container
      Parameters:
      asicContainerType - ASiCContainerType ASiC type of the merged container
      Returns:
      String filename of the container