Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing JAXB after signing content with bouncycastle PKCS7

 
Markus Jesner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic