You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Radek <ra...@finus.com.pl> on 2005/02/08 10:56:54 UTC
Sign DOM Document
Hi,
i want to sign DOM Document. Lets consider that xml looks that:
=====================
<root>
<child1></child1>
<child2></child2>
<signatures></signatures>
</root>
=====================
Now i want to sign this Document and info about Signature put in
<signatures>. I make it in this order:
=============================================
1. XMLSignature xmlsign = new XMLSignature(doc, "",
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1,
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments");
2. doc.getDocumentElement().appendChild(xmlsign.getElement());
3. X509Certificate cert=(X509Certificate)ks.getCertificate(alias);
4. xmlsign.addKeyInfo(cert);
5. xmlsign.addDocument("");
6. xmlsign.sign(prv);
==============================================
It is correct? Or schould i change order of operation? Result of this code
looks fine but i don't know if it is realy ok.
Regards Radek.