Class UtilsTimestamp


  • public final class UtilsTimestamp
    extends java.lang.Object

    Class that contains methods related to the manage of timestamps.

    Project:

    Library for the integration with the services of @Firma, eVisor and TS@.

    Version:
    1.1, 18/04/2022.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Logger LOGGER
      Attribute that represents the object that manages the log of the class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkInputDocumentRFC3161TimeStamp​(org.w3c.dom.Element inputDocuments, org.bouncycastle.tsp.TimeStampToken tst)
      Method that checks if the input document associated to a renovation of a RFC 3161 time-stamp is structurally correct.
      static void checkInputDocumentXMLTimeStamp​(org.w3c.dom.Element inputDocuments, org.w3c.dom.Element signature)
      Method that checks if the input document associated to a renovation of a XML time-stamp is structurally correct.
      static java.util.Date getGenTimeXMLTimestamp​(org.w3c.dom.Element xmlTimestamp)
      Method that obtains the gentime from a XML timestamp.
      static java.security.cert.X509Certificate getSigningCertificate​(org.bouncycastle.tsp.TimeStampToken tst)
      Method that obtain the the signing certificate of a timestamp.
      static org.bouncycastle.tsp.TimeStampToken getTimestampFromRFC3161Service​(byte[] dataToStamp, java.lang.String applicationID, java.lang.String tsaCommunicationMode)
      Method that obtains an ASN.1 timestamp from TS@ RFC 3161 service.
      static org.bouncycastle.tsp.TimeStampToken getTimestampFromRFC3161Service​(byte[] dataToStamp, java.lang.String applicationID, java.lang.String tsaCommunicationMode, java.lang.String idClient)
      Method that obtains an ASN.1 timestamp from TS@ RFC 3161 service.
      static org.bouncycastle.tsp.TimeStampToken getTimeStampToken​(org.bouncycastle.cms.SignerInformation signerInformation)
      Method that obtains the timestamp from the information about a signer of a signature, if it contains a timestamp.
      static void validateASN1Timestamp​(org.bouncycastle.tsp.TimeStampToken tst)
      Method that validates an ASN.1 timestamp.
      static void validateXMLTimestamp​(org.w3c.dom.Element tst)
      Method that validates a XML timestamp.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        public static final Logger LOGGER
        Attribute that represents the object that manages the log of the class.
    • Method Detail

      • getTimestampFromRFC3161Service

        public static org.bouncycastle.tsp.TimeStampToken getTimestampFromRFC3161Service​(byte[] dataToStamp,
                                                                                         java.lang.String applicationID,
                                                                                         java.lang.String tsaCommunicationMode,
                                                                                         java.lang.String idClient)
                                                                                  throws SigningException
        Method that obtains an ASN.1 timestamp from TS@ RFC 3161 service.
        Parameters:
        dataToStamp - Parameter that represents the data to stamp.
        applicationID - Parameter that represents the identifier of the client application.
        tsaCommunicationMode - Parameter that represents the protocol defined to communicate with TS@. The allowed values are:
        idClient - Parameter that represents the client application identifier.
        Returns:
        an object that represents the ASN.1 timestamp.
        Throws:
        SigningException - If the method fails.
      • getTimestampFromRFC3161Service

        public static org.bouncycastle.tsp.TimeStampToken getTimestampFromRFC3161Service​(byte[] dataToStamp,
                                                                                         java.lang.String applicationID,
                                                                                         java.lang.String tsaCommunicationMode)
                                                                                  throws SigningException
        Method that obtains an ASN.1 timestamp from TS@ RFC 3161 service.
        Parameters:
        dataToStamp - Parameter that represents the data to stamp.
        applicationID - Parameter that represents the identifier of the client application.
        tsaCommunicationMode - Parameter that represents the protocol defined to communicate with TS@. The allowed values are:
        Returns:
        an object that represents the ASN.1 timestamp.
        Throws:
        SigningException - If the method fails.
      • getSigningCertificate

        public static java.security.cert.X509Certificate getSigningCertificate​(org.bouncycastle.tsp.TimeStampToken tst)
                                                                        throws SigningException
        Method that obtain the the signing certificate of a timestamp.
        Parameters:
        tst - Parameter that represents the timestamp.
        Returns:
        an object that represents the certificate.
        Throws:
        SigningException - If the method fails.
      • validateXMLTimestamp

        public static void validateXMLTimestamp​(org.w3c.dom.Element tst)
                                         throws SigningException
        Method that validates a XML timestamp.
        Parameters:
        tst - Parameter that represents the XML timestamp.
        Throws:
        SigningException - If the validation fails.
      • validateASN1Timestamp

        public static void validateASN1Timestamp​(org.bouncycastle.tsp.TimeStampToken tst)
                                          throws SigningException
        Method that validates an ASN.1 timestamp.
        Parameters:
        tst - Parameter that represents the ASN.1 timestamp to validate.
        Throws:
        SigningException - If the method fails or the timestamp isn't valid.
      • getTimeStampToken

        public static org.bouncycastle.tsp.TimeStampToken getTimeStampToken​(org.bouncycastle.cms.SignerInformation signerInformation)
                                                                     throws SigningException
        Method that obtains the timestamp from the information about a signer of a signature, if it contains a timestamp.
        Parameters:
        signerInformation - Parameter that represents the information of the signer.
        Returns:
        an object that represents the timestamp, or null.
        Throws:
        SigningException - If the timestamp is malformed.
      • checkInputDocumentXMLTimeStamp

        public static void checkInputDocumentXMLTimeStamp​(org.w3c.dom.Element inputDocuments,
                                                          org.w3c.dom.Element signature)
                                                   throws TSAServiceInvokerException
        Method that checks if the input document associated to a renovation of a XML time-stamp is structurally correct.
        Parameters:
        inputDocuments - Parameter that represents the dss:InputDocuments element of the time-stamp renovation request.
        signature - Parameter that represents the ds:Signature element of the time-stamp renovation request.
        Throws:
        TSAServiceInvokerException - If the validation fails.
      • checkInputDocumentRFC3161TimeStamp

        public static void checkInputDocumentRFC3161TimeStamp​(org.w3c.dom.Element inputDocuments,
                                                              org.bouncycastle.tsp.TimeStampToken tst)
                                                       throws TSAServiceInvokerException
        Method that checks if the input document associated to a renovation of a RFC 3161 time-stamp is structurally correct.
        Parameters:
        inputDocuments - Parameter that represents the dss:InputDocuments element of the time-stamp renovation request.
        tst - Parameter that represents thr RFC 3161 time-stamp.
        Throws:
        TSAServiceInvokerException - If the input document isn't valid.
      • getGenTimeXMLTimestamp

        public static java.util.Date getGenTimeXMLTimestamp​(org.w3c.dom.Element xmlTimestamp)
                                                     throws SigningException
        Method that obtains the gentime from a XML timestamp.
        Parameters:
        xmlTimestamp - Parameter that represents the XML timestamp.
        Returns:
        an object that represents the gentime.
        Throws:
        SigningException - If the gentime cannot parse to UTC format.