ASiCEWithCAdESManifestBuilder extends AbstractManifestBuilder { public Document build() { final Document documentDom = DomUtils.buildDOM(); final Element asicManifestDom = DomUtils.createElementNS(documentDom, ASiCNamespace.NS, ASiCElement.ASIC_MANIFEST); documentDom.appendChild(asicManifestDom); if (SigningOperation.SIGN == operation) { addSigReference(documentDom, asicManifestDom, uri, MimeType.PKCS7); } else { addSigReference(documentDom, asicManifestDom, uri, MimeType.TST); } for (DSSDocument document : documents) { addDataObjectReference(documentDom, asicManifestDom, document, digestAlgorithm); } return documentDom; } ASiCEWithCAdESManifestBuilder(SigningOperation operation, List<DSSDocument> documents, DigestAlgorithm digestAlgorithm, String uri); Document build();  }
@Test public void testManifestAgainstXSD() throws SAXException, IOException { List<DSSDocument> documents = new ArrayList<>(); documents.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test.bin")); documents.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test", MimeType.BINARY)); ASiCEWithCAdESManifestBuilder builder = new ASiCEWithCAdESManifestBuilder(SigningOperation.SIGN, documents, DigestAlgorithm.SHA256, "signature.p7s"); Document build = builder.build(); validator.validate(new DOMSource(build)); }
@Test public void testArchiveManifestAgainstXSD() throws SAXException, IOException { List<DSSDocument> signatures = new ArrayList<>(); signatures.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test.p7s", MimeType.PKCS7)); List<DSSDocument> timestamps = new ArrayList<>(); signatures.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test.tst", MimeType.TST)); List<DSSDocument> documents = new ArrayList<>(); documents.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test.bin")); documents.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test", MimeType.BINARY)); List<DSSDocument> manifests = new ArrayList<>(); documents.add(new InMemoryDocument(new byte[] { 1, 2, 3 }, "test.xml", MimeType.XML)); ASiCEWithCAdESArchiveManifestBuilder builder = new ASiCEWithCAdESArchiveManifestBuilder(signatures, timestamps, documents, manifests, null, DigestAlgorithm.SHA256, "timestamp.tst"); Document build = builder.build(); validator.validate(new DOMSource(build)); }