使用 Java 和 iText 对 PDF 添加时间戳的问题
我正在编写一个使用 iText 和 Java 对 PDF 进行签名和加时间戳的应用程序。 因为我们(斯洛文尼亚)采用不同的方法从 TSA 获取时间戳(通过 Web 服务,使用证书和密码),所以我无法使用 iText 中的这些方法。我有一个 Perl 脚本用于此目的。 那么..如何或使用代码的哪些部分可以将时间戳和摘要(来自网络服务响应)写入PDF?
Im writing a app for signing and timestamping PDFs using iText and Java.
Because we (in Slovenia) have different approach for 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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我完全遵循您的要求,我不会,但听起来您想调整报告的 PDF 签名日期。
假设您使用 PdfStamper 来签署文档,在创建签名后尝试
其中 calendar 是您使用时间戳 Web 服务的响应创建的日历实例。
让 iText 将 TSA 信息与签名一起包含起来有点复杂。它有点超出了我的知识范围,但根据我的理解,您需要使用外部生成的证书,并且大多数人使用 BouncyCastle 来做到这一点。
此讨论< /a> 有一个如何执行此操作的示例。您最终会希望在获取时使用 TSAClientBouncyCastle加密的证书。此页面有一个替代示例,其中也包含 OCSP 信息。
如果您解决了这个问题,请添加您的解决方案,以便 stackoverflow 上有更权威的答案。
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
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.
这是一个示例
http://itextpdf.sourceforge.net/howtosign.html#signtsocspjava
您必须替换
并
放置这些正确版本的库
here is an example
http://itextpdf.sourceforge.net/howtosign.html#signtsocspjava
you have to replace
for
and put these correct version of libs