Record Class TimestampInfo

java.lang.Object
java.lang.Record
cloud.opencode.base.pdf.signature.TimestampInfo
Record Components:
time - timestamp time | 时间戳时间
tsaCertificate - TSA certificate | TSA 证书
hashAlgorithm - hash algorithm used | 使用的哈希算法
serialNumber - timestamp serial number | 时间戳序列号
isValid - whether timestamp is valid | 时间戳是否有效

public record TimestampInfo(Instant time, X509Certificate tsaCertificate, String hashAlgorithm, String serialNumber, boolean isValid) extends Record
Timestamp Information 时间戳信息

Contains details about a timestamp in a PDF signature.

包含 PDF 签名中时间戳的详细信息。

Features | 主要功能:

  • Timestamp time and validity status - 时间戳时间和有效性状态
  • TSA certificate and name access - TSA 证书和名称访问
  • Hash algorithm and serial number - 哈希算法和序列号

Usage Examples | 使用示例:

TimestampInfo ts = TimestampInfo.of(Instant.now());
Instant time = ts.time();
boolean valid = ts.isValid();

Security | 安全性:

  • Thread-safe: Yes — immutable record - 线程安全: 是 — 不可变记录
  • Null-safe: Partial — time is validated as non-null, other fields may be null - 空值安全: 部分 — 时间已验证非空,其他字段可能为空
Since:
JDK 25, opencode-base-pdf V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • TimestampInfo

      public TimestampInfo(Instant time, X509Certificate tsaCertificate, String hashAlgorithm, String serialNumber, boolean isValid)
      Creates a new timestamp info. 创建新的时间戳信息。
      Parameters:
      time - timestamp time | 时间戳时间
      tsaCertificate - TSA certificate | TSA 证书
      hashAlgorithm - hash algorithm used | 使用的哈希算法
      serialNumber - timestamp serial number | 时间戳序列号
      isValid - whether timestamp is valid | 时间戳是否有效
  • Method Details

    • getTsaName

      public String getTsaName()
      Gets TSA name from certificate. 从证书获取 TSA 名称。
      Returns:
      TSA name, or null if no certificate | TSA 名称,如果没有证书则返回 null
    • of

      public static TimestampInfo of(Instant time, X509Certificate tsaCertificate, String hashAlgorithm, String serialNumber)
      Creates a valid timestamp info. 创建有效的时间戳信息。
      Parameters:
      time - timestamp time | 时间戳时间
      tsaCertificate - TSA certificate | TSA 证书
      hashAlgorithm - hash algorithm | 哈希算法
      serialNumber - serial number | 序列号
      Returns:
      timestamp info | 时间戳信息
    • of

      public static TimestampInfo of(Instant time)
      Creates a timestamp info with only time. 创建仅包含时间的时间戳信息。
      Parameters:
      time - timestamp time | 时间戳时间
      Returns:
      timestamp info | 时间戳信息
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • time

      public Instant time()
      Returns the value of the time record component.
      Returns:
      the value of the time record component
    • tsaCertificate

      public X509Certificate tsaCertificate()
      Returns the value of the tsaCertificate record component.
      Returns:
      the value of the tsaCertificate record component
    • hashAlgorithm

      public String hashAlgorithm()
      Returns the value of the hashAlgorithm record component.
      Returns:
      the value of the hashAlgorithm record component
    • serialNumber

      public String serialNumber()
      Returns the value of the serialNumber record component.
      Returns:
      the value of the serialNumber record component
    • isValid

      public boolean isValid()
      Returns the value of the isValid record component.
      Returns:
      the value of the isValid record component