开发者

Problem with timestamping a PDF using Java and iText

Im writing a app for signing and timestamping PDFs using iText and Java. Because we (in Slovenia) have different approach f开发者_Go百科or getting timestamp from our TSA (via web service, using certificate and password) I cannot use those methods from iText. I have a Perl script for this. So.. how, or with which parts of code can I write timestamp and digest (from a web service response) to a PDF??


I'm not if I'm following exactly what you're asking for, but it sounds like you want to adjust the date that is reported for the signing of the PDF.

Assuming you are using PdfStamper to sign the document, after you have created the signature try

pdfStamper.getSignatureAppearence().setSignDate(calendar)

where calendar is a Calendar instance you have created using a response from your timestamp web service.

Getting iText to include TSA information along with the signature is a bit more involved. Its a bit outside of my knowledge area, but from my understanding, you need to use an externally generated certificate, and most people do it using BouncyCastle.

This discussion has an example of how to do it. You'll eventually want to be making use of TSAClientBouncyCastle when getting the encrypted certificate. This page has an alternate example including OCSP information as well.

If you get this worked out, please add in your solution so that there's a more authoritative answer on stackoverflow.


here is an example

http://itextpdf.sourceforge.net/howtosign.html#signtsocspjava

you have to replace

   sap.setCrypto(null, chain, null, PdfSignatureAppearance.SELF_SIGNED);

for

sap.setCrypto(pk, chain, null, PdfSignatureAppearance.WINCER_SIGNED);

and put these correct version of libs

- org.bouncycastle -> bcprov-jdk16 1.40
- org.bouncycastle -> bctsp-jdk16 1.38
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜