ASiCUtils { public static ASiCContainerType getASiCContainerType(final MimeType asicMimeType) { if (MimeType.ASICS.equals(asicMimeType)) { return ASiCContainerType.ASiC_S; } else if (MimeType.ASICE.equals(asicMimeType) || isOpenDocumentMimeType(asicMimeType)) { return ASiCContainerType.ASiC_E; } else { throw new IllegalArgumentException("Not allowed mimetype '" + asicMimeType.getMimeTypeString() + "'"); } } private  ASiCUtils(); static boolean isSignature(final String entryName); static boolean isTimestamp(final String entryName); static String getMimeTypeString(final ASiCParameters asicParameters); static boolean isASiCMimeType(final MimeType asicMimeType); static boolean isOpenDocumentMimeType(final MimeType mimeType); static ASiCContainerType getASiCContainerType(final MimeType asicMimeType); static boolean isASiCE(final ASiCParameters asicParameters); static boolean isASiCS(final ASiCParameters asicParameters); static MimeType getMimeType(ASiCParameters asicParameters); static boolean isArchiveContainsCorrectSignatureFileWithExtension(DSSDocument container, String extension); static boolean isArchiveContainsCorrectTimestamp(DSSDocument container); static boolean isArchive(List<DSSDocument> docs); static boolean isZip(DSSDocument dssDocument); static boolean isASiCWithCAdES(DSSDocument archive); static boolean isXAdES(final String entryName); static boolean isCAdES(final String entryName); static boolean isOpenDocument(final DSSDocument mimeTypeDoc); static MimeType getMimeType(final DSSDocument mimeTypeDocument); static ASiCContainerType getContainerType(DSSDocument archive, DSSDocument mimetype, String zipComment, List<DSSDocument> signedDocuments); static String getPadNumber(int num); static boolean isAsic(List<DSSDocument> documents); static boolean isArchiveManifest(String fileName); static void secureCopy(InputStream is, OutputStream os, long containerSize); static List<String> getFileNames(DSSDocument archive); static ZipEntry getNextValidEntry(ZipInputStream zis); static DSSDocument getCurrentDocument(String filepath, ZipInputStream zis, long containerSize); static void closeEntry(ZipInputStream zis); static String getNextASiCEManifestName(final String expectedManifestName, final List<DSSDocument> existingManifests); static List<String> getDSSDocumentNames(List<DSSDocument> documents); static boolean isASiCSArchive(DSSDocument document); static List<DSSDocument> getPackageZipContent(DSSDocument packageZip); static final String MANIFEST_FILENAME; static final String MIME_TYPE; static final String MIME_TYPE_COMMENT; static final String META_INF_FOLDER; static final String PACKAGE_ZIP; static final String SIGNATURE_FILENAME; static final String TIMESTAMP_FILENAME; static final String TST_EXTENSION; static final String XML_EXTENSION; static final String ZIP_ENTRY_DETACHED_FILE; }
@Test public void getASiCContainerType() { MimeType mt = new MimeType(); mt.setMimeTypeString("application/vnd.etsi.asic-e+zip"); assertEquals(ASiCContainerType.ASiC_E, ASiCUtils.getASiCContainerType(mt)); assertEquals(ASiCContainerType.ASiC_E, ASiCUtils.getASiCContainerType(MimeType.ASICE)); }
@Test public void getWrongASiCContainerType() { MimeType mt = new MimeType(); mt.setMimeTypeString("application/wrong"); Exception exception = assertThrows(IllegalArgumentException.class, () -> ASiCUtils.getASiCContainerType(mt)); assertEquals("Not allowed mimetype 'application/wrong'", exception.getMessage()); }