A note on the handling of Signature tags in Java XML signatures.
createXml.java
//Creating a signature context
//Prefix Signature tags (including all child elements) with setDefaultNamespacePrefix
DOMSignContext dsc = new DOMSignContext(privateKey, document.getDocumentElement());
dsc.setDefaultNamespacePrefix("dsig");
createXml.java
XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
(Omission)
//Sign.
//Set the ID in the 4th argument of newXMLSignature
XMLSignature signature = fac.newXMLSignature(si, ki, null, "a", null);
signature.sign(dsc);
How to add namespace while signing XML file using javax.xml.crypto.dsig.*? add attribute to signature xml in java
Recommended Posts