aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Parsing JAXB after signing content with bouncycastle PKCS7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Parsing JAXB after signing content with bouncycastle PKCS7" Watch "Parsing JAXB after signing content with bouncycastle PKCS7" New topic
Author

Parsing JAXB after signing content with bouncycastle PKCS7

Markus Jesner
Greenhorn

Joined: Nov 16, 2011
Posts: 4
Hello!

I've following problem:

I fill a XML (with JaxB generated object factory, ... etc) and marshall a String.
e.g.



I have to generate a signature of this content.
Therefore I've to use bouncycastle library.

I found some examples .. my code looks like this:
(privatekey+certificate are from the keystore and are okay)



I will get a signature containing funny charactes like these:

ž6ʁsF4í$¿ñ’ ... and so on.

When I try to copy (textpad) I got an error: "cannot copy .. text containg null (code=0) chars".
I have to add this signature to the xml tag (<signature>) and then marshall the message once again.

I got following exception:
Ok .. that means to me, that the signature could not be in the xml as tag because it would be invalid?

Is the way i to this okay?
I've done some Xml signing with the dsig lib from java and apache santuario. But they will create a own tag etc.

Any ideas?
Thank you very much!

Greetings from Austria,
Max






Markus Jesner
Greenhorn

Joined: Nov 16, 2011
Posts: 4
Okay,

to geht a "good looking" string that can be used fort he xml, you have to encode the byte[] to bas64.

byte[] data = ...
String s = new String(Base64.encode(data));
 
Don't get me started about those stupid light bulbs.
 
subject: Parsing JAXB after signing content with bouncycastle PKCS7