I
tried both encode(byte[]) and encodeBuffer(byte[]) of sun.misc.BASE64Encode, but
I am still getting the same exception. Here is the code:
byte[] data =
"">
byte[] sig = signature.sign(data);
...
Element root = doc.createElement("top");
doc.appendChild(root);
...
Element root = doc.createElement("top");
doc.appendChild(root);
...
sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
String encodedSig =
encoder.encodeBuffer(sig);
root.appendChild (
doc.createProcessingInstruction("DigSign" + encodedSig, null) );
root.appendChild (
doc.createProcessingInstruction("DigSign" + encodedSig, null) );
What
kind of character is allowed in processing instructions?
-Lei
-----Original Message-----
From: Mark Sizer [mailto:[EMAIL PROTECTED]
Sent: Monday, April 02, 2001 12:18 PM
To: '[EMAIL PROTECTED]'
Subject: RE: embed digital signature in XMLI base64 encode my digital signatures before stuffing them into XML - it works fine.I'm using an open-source package from Germany, but I believe there is a base64 encoder/decoder buried in the Xerces packages somewhere. If not, Sun has one, too.-----Original Message-----
From: Lei Chen [mailto:[EMAIL PROTECTED]
Sent: Monday, April 02, 2001 9:42 AM
To: '[EMAIL PROTECTED]'
Subject: embed digital signature in XMLHi 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 gotjava.lang.InstantiationError: org/w3c/dom/DOMExceptionat 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
