Class ASiCUtils

java.lang.Object
eu.europa.esig.dss.asic.common.ASiCUtils

public final class ASiCUtils
extends Object
Contains utils for working with ASiC containers
  • Field Details

  • Method Details

    • isSignature

      public static boolean isSignature​(String entryName)
      Verifies if the entryName represents a signature file name
      Parameters:
      entryName - String name to check
      Returns:
      TRUE if the entryName represents a signature file name, FALSE otherwise
    • isTimestamp

      public static boolean isTimestamp​(String entryName)
      Verifies if the entryName represents a timestamp file name
      Parameters:
      entryName - String name to check
      Returns:
      TRUE if the entryName represents a timestamp file name, FALSE otherwise
    • getMimeTypeString

      public static String getMimeTypeString​(ASiCParameters asicParameters)
      Returns the target MimeType string
      Parameters:
      asicParameters - ASiCParameters
      Returns:
      String MimeType
    • getZipComment

      public static String getZipComment​(ASiCParameters asicParameters)
      Returns a ZIP Comment String according to the given parameters
      Parameters:
      asicParameters - ASiCParameters
      Returns:
      String zip comment
    • getZipComment

      public static String getZipComment​(String mimeTypeString)
      Returns a ZIP Comment String from the provided mimeTypeString
      Parameters:
      mimeTypeString - String
      Returns:
      String zip comment
    • isASiCMimeType

      public static boolean isASiCMimeType​(MimeType mimeType)
      Checks if the given MimeType is ASiC MimeType
      Parameters:
      mimeType - MimeType to check
      Returns:
      TRUE if the given MimeType is ASiC MimeType, FALSE otherwise
    • isOpenDocumentMimeType

      public static boolean isOpenDocumentMimeType​(MimeType mimeType)
      Checks if the given MimeType is OpenDocument MimeType
      Parameters:
      mimeType - MimeType to check
      Returns:
      TRUE if the given MimeType is OpenDocument MimeType, FALSE otherwise
    • getASiCContainerType

      public static ASiCContainerType getASiCContainerType​(MimeType asicMimeType)
      Returns related ASiCContainerType for the given asicMimeType
      Parameters:
      asicMimeType - MimeType to get ASiCContainerType for
      Returns:
      ASiCContainerType
    • isASiCE

      public static boolean isASiCE​(ASiCParameters asicParameters)
      Checks if the parameters are configured for ASiCE creation
      Parameters:
      asicParameters - ASiCParameters
      Returns:
      TRUE if parameters are configured for ASiCE, FALSE otherwise
    • isASiCS

      public static boolean isASiCS​(ASiCParameters asicParameters)
      Checks if the parameters are configured for ASiCS creation
      Parameters:
      asicParameters - ASiCParameters
      Returns:
      TRUE if parameters are configured for ASiCS, FALSE otherwise
    • getMimeType

      public static MimeType getMimeType​(ASiCParameters asicParameters)
      Returns a relevant MimeType for the provided parameters
      Parameters:
      asicParameters - ASiCParameters
      Returns:
      MimeType
    • areFilesContainCorrectSignatureFileWithExtension

      public static boolean areFilesContainCorrectSignatureFileWithExtension​(List<String> filenames, String extension)
      Checks if the list of filenames contains a signature with the expected extension
      Parameters:
      filenames - a list of file names
      extension - String signature file extension to find
      Returns:
      TRUE if the list of filename contains the expected signature file, FALSE otherwise
    • areFilesContainSignatures

      public static boolean areFilesContainSignatures​(List<String> filenames)
      Checks if the list of filenames contains a signature(s)
      Parameters:
      filenames - a list of file names
      Returns:
      TRUE if the list of filename contains a signature file(s)
    • isAsicFileContent

      public static boolean isAsicFileContent​(List<String> filenames)
      Checks if the list of filenames represents an ASiC container content
      Parameters:
      filenames - a list of String file names
      Returns:
      TRUE if the list of filenames represents an ASiC container content, FALSE otherwise
    • areFilesContainTimestamp

      public static boolean areFilesContainTimestamp​(List<String> filenames)
      Checks if the list of filenames contains a timestamp
      Parameters:
      filenames - a list of filenames to check
      Returns:
      TRUE if the list of filenames contains the expected timestamp file, FALSE otherwise
    • isZip

      public static boolean isZip​(DSSDocument document)
      Checks if the document is a ZIP container
      Parameters:
      document - DSSDocument to check
      Returns:
      TRUE if the DSSDocument is a ZIP container, FALSE otherwise
    • isASiCWithCAdES

      public static boolean isASiCWithCAdES​(List<String> filenames)
      Checks if the extracted filenames represent an ASiC with CAdES content
      Parameters:
      filenames - a list of String file names to check
      Returns:
      TRUE if the filenames represent an ASiC with CAdES content, FALSE otherwise
    • isXAdES

      public static boolean isXAdES​(String entryName)
      Checks if the entryName is a relevant XAdES signature
      Parameters:
      entryName - String to check
      Returns:
      TRUE if the entryName is a relevant XAdES signature, FALSE otherwise
    • isCAdES

      public static boolean isCAdES​(String entryName)
      Checks if the entryName is a relevant CAdES signature
      Parameters:
      entryName - String to check
      Returns:
      TRUE if the entryName is a relevant CAdES signature, FALSE otherwise
    • isOpenDocument

      public static boolean isOpenDocument​(DSSDocument mimeTypeDoc)
      Checks if the mimeType document defines an OpenDocument
      Parameters:
      mimeTypeDoc - DSSDocument mimetype file extracted from an ASiC container
      Returns:
      TRUE if the mimeTypeDoc file defines an OpenDocument, FALSE otherwise
    • isMimetype

      public static boolean isMimetype​(String entryName)
      Checks if the given name is a "mimetype"
      Parameters:
      entryName - String document name
      Returns:
      TRUE if the name is a "mimetype", FALSE otherwise
    • getMimeType

      public static MimeType getMimeType​(DSSDocument mimeTypeDocument)
      Extracts and returns MimeType from the document
      Parameters:
      mimeTypeDocument - DSSDocument to get a MimeType of
      Returns:
      MimeType
    • getContainerType

      public static ASiCContainerType getContainerType​(DSSDocument archive, DSSDocument mimetype, String zipComment, List<DSSDocument> signedDocuments)
      Returns target container type
      Parameters:
      archive - DSSDocument archive
      mimetype - DSSDocument mimetype file
      zipComment - String zipComment
      signedDocuments - a list of DSSDocuments
      Returns:
      ASiCContainerType
    • getPadNumber

      public static String getPadNumber​(int num)
      Transforms num with the pattern: "2 -> 002", "10 -> 010", etc.
      Parameters:
      num - number to transform
      Returns:
      String
    • isArchiveManifest

      public static boolean isArchiveManifest​(String fileName)
      Checks if the fileName matches to an Archive Manifest name standard
      Parameters:
      fileName - String to check
      Returns:
      TRUE if the given name matches to and ASiC Archive Manifest filename, FALSE otherwise
    • getNextASiCEManifestName

      public static String getNextASiCEManifestName​(String expectedManifestName, List<DSSDocument> existingManifests)
      Generates an unique name for a new ASiC-E Manifest file, avoiding any name collision
      Parameters:
      expectedManifestName - String defines the expected name of the file without extension (e.g. "ASiCmanifest")
      existingManifests - list of existing DSSDocument manifests of the type present in the container
      Returns:
      String new manifest name
    • isASiCSArchive

      public static boolean isASiCSArchive​(DSSDocument document)
      Checks if the current document an ASiC-E ZIP specific archive
      Parameters:
      document - DSSDocument to check
      Returns:
      TRUE if the document if a "package.zip" archive, FALSE otherwise