![JAR search and dependency download from the Maven repository](/logo.png)
eu.europa.esig.dss.asic.signature.asice.ASiCEWithCAdESManifestBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dss-asic-cades Show documentation
Show all versions of dss-asic-cades Show documentation
DSS ASiC with CAdES contains the code for the creation and validation of ASiC containers with CAdES signature(s).
package eu.europa.esig.dss.asic.signature.asice;
import java.util.List;
import javax.xml.crypto.dsig.XMLSignature;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import eu.europa.esig.dss.DSSDocument;
import eu.europa.esig.dss.DigestAlgorithm;
import eu.europa.esig.dss.DomUtils;
import eu.europa.esig.dss.MimeType;
import eu.europa.esig.dss.asic.ASiCNamespace;
/**
* This class is used to generate the ASiCManifest.xml content (ASiC-E)
*
* Sample:
*
*
*
*
*
*
*
* OuL0HMJE899y+uJtyNnTt5B/gFrrw8adNczI+9w9GDQ=
*
*
*
*
*
*/
public class ASiCEWithCAdESManifestBuilder {
private final List documents;
private final DigestAlgorithm digestAlgorithm;
private final String signatureUri;
public ASiCEWithCAdESManifestBuilder(List documents, DigestAlgorithm digestAlgorithm, String signatureUri) {
this.documents = documents;
this.digestAlgorithm = digestAlgorithm;
this.signatureUri = signatureUri;
}
public Document build() {
final Document documentDom = DomUtils.buildDOM();
final Element asicManifestDom = documentDom.createElementNS(ASiCNamespace.NS, ASiCNamespace.ASIC_MANIFEST);
documentDom.appendChild(asicManifestDom);
final Element sigReferenceDom = DomUtils.addElement(documentDom, asicManifestDom, ASiCNamespace.NS, ASiCNamespace.SIG_REFERENCE);
sigReferenceDom.setAttribute("URI", signatureUri);
sigReferenceDom.setAttribute("MimeType", MimeType.PKCS7.getMimeTypeString());
for (DSSDocument document : documents) {
final String detachedDocumentName = document.getName();
final Element dataObjectReferenceDom = DomUtils.addElement(documentDom, asicManifestDom, ASiCNamespace.NS, ASiCNamespace.DATA_OBJECT_REFERENCE);
dataObjectReferenceDom.setAttribute("URI", detachedDocumentName);
final Element digestMethodDom = DomUtils.addElement(documentDom, dataObjectReferenceDom, XMLSignature.XMLNS, "DigestMethod");
digestMethodDom.setAttribute("Algorithm", digestAlgorithm.getXmlId());
final Element digestValueDom = DomUtils.addElement(documentDom, dataObjectReferenceDom, XMLSignature.XMLNS, "DigestValue");
final Text textNode = documentDom.createTextNode(document.getDigest(digestAlgorithm));
digestValueDom.appendChild(textNode);
}
return documentDom;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy