Class ASiCUtils


  • public final class ASiCUtils
    extends Object
    • Method Detail

      • isSignature

        public static boolean isSignature​(String entryName)
      • isASiCMimeType

        public static boolean isASiCMimeType​(MimeType asicMimeType)
      • isASiCE

        public static boolean isASiCE​(ASiCParameters asicParameters)
      • isASiCS

        public static boolean isASiCS​(ASiCParameters asicParameters)
      • isArchiveContainsCorrectSignatureFileWithExtension

        public static boolean isArchiveContainsCorrectSignatureFileWithExtension​(DSSDocument toSignDocument,
                                                                                 String extension)
      • isASiCContainer

        public static boolean isASiCContainer​(DSSDocument dssDocument)
      • isXAdES

        public static boolean isXAdES​(String entryName)
      • isCAdES

        public static boolean isCAdES​(String entryName)
      • isOpenDocument

        public static boolean isOpenDocument​(DSSDocument mimeTypeDocument)
      • getPadNumber

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

        public static boolean isArchiveManifest​(String fileName)
      • secureCopy

        public static void secureCopy​(InputStream is,
                                      OutputStream os,
                                      long containerSize)
                               throws IOException
        Reads and copies InputStream in a secure way, depending on the provided container size This method allows to detect "ZipBombing" (large files inside a zip container)
        Parameters:
        is - InputStream of file
        os - OutputStream where save file to
        containerSize - - zip container size
        Throws:
        IOException
      • getFileNames

        public static List<String> getFileNames​(DSSDocument archive)
        Returns the file names for the given archive
        Parameters:
        archive - the archive to be analyzed
        Returns:
        a list of filename
      • getNextValidEntry

        public static ZipEntry getNextValidEntry​(ZipInputStream zis)
        Returns the next entry from the given ZipInputStream by skipping corrupted or not accessible files NOTE: returns null only when the end of ZipInputStream is reached
        Parameters:
        zis - ZipInputStream to get next entry from
        Returns:
        list of file name Strings
        Throws:
        DSSException - if too much tries failed
      • getCurrentDocument

        public static DSSDocument getCurrentDocument​(String filepath,
                                                     ZipInputStream zis,
                                                     long containerSize)
                                              throws IOException
        Returns file from the given ZipInputStream
        Parameters:
        filepath - String filepath where the file is located
        zis - ZipInputStream of the file
        containerSize - - long byte size of the parent container
        Returns:
        DSSDocument created from the given zis
        Throws:
        IOException - in case of ZipInputStream read error