You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Lei Chen <Le...@sfcommerce.com> on 2001/04/02 17:41:57 UTC
embed digital signature in XML
Hi folks,
I am trying to embed a digital signature into a XML document as processing
instructions like following:
<top>
<contract>
...
</contract>
<?DigSignA234B5678E897?>
</top>
The signature was generated by using 'byte[] Signature.sign(bye[])' from
java.security package. However, when I ran following code:
...
byte[] data = ...
byte[] sig = signature.sign(data);
...
Element root = doc.createElement("top");
doc.appendChild(root);
...
root.appendChild (
doc.createProcessingInstruction("DigSign" + new String(sig), null) );
I got
java.lang.InstantiationError: org/w3c/dom/DOMException
at
org.apache.xerces.dom.DocumentImpl.createProcessingInstruction(DocumentImpl.
java:566)
If I switch to sun's crimson parser, the error message is more informative:
org.apache.crimson.tree.DomEx: INVALID_CHARACTER_ERR: An invalid character
was specified, such as in a name.
at
org.apache.crimson.tree.XmlDocument.createProcessingInstruction(XmlDocument.
java:984)
I guess some kind of encoding has to be done to the signature byte array
before I construct the
String and pass it to this method. But I don't know how to do it. Can
somebody point it out?
thanx in advance
-Lei