使用iText的脱机PDF时间戳 [英] Offline PDF timestamping using iText

查看:229
本文介绍了使用iText的脱机PDF时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用iText或任何其他组件为PDF文档脱机添加时间戳?

is it possible to timestamp PDF document offline using iText or any other component?

我使用iText和TSAClient类搜索了标准解决方案,但它要求TSA作为在线服务。我们有来自TSA(包括私钥)的证书,其目的是创建时间戳签名,但我找不到任何技术方法如何使用iText。

I've googled standard solution utilizing iText and TSAClient class but it requires TSA as online service. We have certificate from TSA (including private key) whose purpose is to create timestamp signatures but I can't find any technical way how to do it with iText.

谢谢你任何指导。
Richmond

Thanks for any guidance. Richmond

推荐答案


我使用iText和TSAClient类搜索了标准解决方案但是它要求TSA作为在线服务。

I've googled standard solution utilizing iText and TSAClient class but it requires TSA as online service.

TSAClient 不是最终类,只是一个接口:

TSAClient is not a final class but merely an interface:

/**
 * Time Stamp Authority client (caller) interface.
 * <p>
 * Interface used by the PdfPKCS7 digital signature builder to call
 * Time Stamp Authority providing RFC 3161 compliant time stamp token.
 * @author Martin Brunecky, 07/17/2007
 * @since   2.1.6
 */
public interface TSAClient {
    /**
     * Get the time stamp token size estimate.
     * Implementation must return value large enough to accomodate the entire token
     * returned by getTimeStampToken() _prior_ to actual getTimeStampToken() call.
     * @return  an estimate of the token size
     */
    public int getTokenSizeEstimate();

    /**
     * Get RFC 3161 timeStampToken.
     * Method may return null indicating that timestamp should be skipped.
     * @param caller PdfPKCS7 - calling PdfPKCS7 instance (in case caller needs it)
     * @param imprint byte[] - data imprint to be time-stamped
     * @return byte[] - encoded, TSA signed data of the timeStampToken
     * @throws Exception - TSA request failed
     */
    public byte[] getTimeStampToken(PdfPKCS7 caller, byte[] imprint) throws Exception;

}

因此,您所要做的就是实现该接口以您想要的任何方式生成时间戳。即使评论似乎暗示某些在线服务,您只需返回一些 byte [] 时间戳,标记给定的 byte []印记

Thus, all you have to do is implement that interface to generate time stamps in any way you want. Even though the comments seem to imply some online service, you merely have to return some byte[] time stamp stamping the given byte[] imprint.

有人说过,这样的时间戳并不值得这个名字。你能保证你打算在可接受的误差范围内创建正确的时间戳吗?

That been said, time stamping like that does not really merit the name. Can you guarantee the time stamps you intend to create to be correct within an acceptable error range?

因此,你很难找到现有的 TSAClient 实现。但现有的安全库(如Bouncy Castle)应该可以很容易地创建时间戳请求响应。

Thus, you hardly will find an existing TSAClient implementation for that. But existing security libraries (like Bouncy Castle) should make creating time stamp request responses quite easy.

这篇关于使用iText的脱机PDF时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆