Class ERSArchiveTimeStamp

java.lang.Object
org.bouncycastle.tsp.ers.ERSArchiveTimeStamp

public class ERSArchiveTimeStamp extends Object
Carrier for an RFC 4998 ArchiveTimeStamp - an RFC 3161 time-stamp token together with the reduced hash tree (a sequence of PartialHashtrees) that binds a particular data object or data group to the time-stamped root hash. Provides operations to recover the root hash, confirm a data object is present, and validate the underlying time-stamp signature.
  • Constructor Details

    • ERSArchiveTimeStamp

      public ERSArchiveTimeStamp(byte[] archiveTimeStamp, DigestCalculatorProvider digCalcProv) throws TSPException, ERSException
      Create an archive time-stamp from an encoded ArchiveTimeStamp.
      Parameters:
      archiveTimeStamp - the DER encoded ArchiveTimeStamp.
      digCalcProv - provider for the digest calculator matching the structure's digest algorithm.
      Throws:
      TSPException
      ERSException
    • ERSArchiveTimeStamp

      public ERSArchiveTimeStamp(org.bouncycastle.asn1.tsp.ArchiveTimeStamp archiveTimeStamp, DigestCalculatorProvider digCalcProv) throws TSPException, ERSException
      Create an archive time-stamp from a parsed ArchiveTimeStamp structure.
      Parameters:
      archiveTimeStamp - the ArchiveTimeStamp to wrap.
      digCalcProv - provider for the digest calculator matching the structure's digest algorithm.
      Throws:
      TSPException
      ERSException
  • Method Details

    • getDigestAlgorithmIdentifier

      public org.bouncycastle.asn1.x509.AlgorithmIdentifier getDigestAlgorithmIdentifier()
    • validatePresent

      public void validatePresent(ERSData data, Date atDate) throws ERSException
      Validate that the passed in data object/group is present in this archive time-stamp at the given date - that its hash appears in the reduced hash tree and the recovered root hash matches the time-stamp imprint.
      Parameters:
      data - the data object or data group to check for.
      atDate - date the data is expected to be valid at; the time-stamp must not be in the future relative to it.
      Throws:
      ERSException - if the data is not present, or the time-stamp generation time is after atDate.
    • isContaining

      public boolean isContaining(ERSData data, Date atDate) throws ERSException
      Return true if the passed in data object/group is present in this archive time-stamp at the given date. Equivalent to validatePresent(ERSData, Date) but returning a boolean rather than throwing on absence.
      Parameters:
      data - the data object or data group to check for.
      atDate - date the data is expected to be valid at.
      Returns:
      true if the data is present, false otherwise.
      Throws:
      ArchiveTimeStampValidationException - if the time-stamp generation time is after atDate.
      ERSException
    • validatePresent

      public void validatePresent(boolean isDataGroup, byte[] hash, Date atDate) throws ERSException
      Validate that data with the given hash is present in this archive time-stamp at the given date.
      Parameters:
      isDataGroup - true if the hash represents a data group rather than a single object.
      hash - the (pre-computed) hash of the data object/group to check for.
      atDate - date the data is expected to be valid at.
      Throws:
      ERSException - if the hash is not present, or the time-stamp generation time is after atDate.
    • getTimeStampToken

      public TimeStampToken getTimeStampToken()
    • getSigningCertificate

      public X509CertificateHolder getSigningCertificate()
      Return the TimeStamp signing certificate if it is present.
      Returns:
      the TimeStamp signing certificate.
    • validate

      public void validate(SignerInformationVerifier verifier) throws TSPException
      Validate the time stamp associated with this ArchiveTimeStamp.
      Parameters:
      verifier - signer verifier for the contained time stamp.
      Throws:
      TSPException - in case of validation failure or error.
    • getGenTime

      public Date getGenTime()
      Return the generation time of the time-stamp associated with this archive time stamp.
      Returns:
      the time the associated time-stamp was created.
    • getExpiryTime

      public Date getExpiryTime()
      Return the not-after date for the time-stamp's signing certificate if it is present.
      Returns:
      the issuing TSP server not-after date, or null if not present.
    • toASN1Structure

      public org.bouncycastle.asn1.tsp.ArchiveTimeStamp toASN1Structure()
      Return the underlying ASN.1 ArchiveTimeStamp structure.
      Returns:
      the ArchiveTimeStamp this object wraps.
    • getEncoded

      public byte[] getEncoded() throws IOException
      return the ASN.1 encoded representation of this object.
      Throws:
      IOException
    • fromTimeStampToken

      public static ERSArchiveTimeStamp fromTimeStampToken(TimeStampToken tspToken, DigestCalculatorProvider digCalcProv) throws TSPException, ERSException
      Build an ArchiveTimeStamp from a regular time stamp token.
      Parameters:
      tspToken - the TimeStampToken in the regular time stamp.
      digCalcProv - a digest calculator provider for use with the time stamp.
      Returns:
      an ERSArchiveTimeStamp containing the time stamp.
      Throws:
      TSPException - on a failure to parse the time stamp token data.
      ERSException - on a failure to convert the time stamp token to an archive time stamp.