Class UtilsTimestampXML


  • public final class UtilsTimestampXML
    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.7, 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 java.security.cert.X509Certificate getCertificateFromXMLTimestamp​(org.w3c.dom.Element xmlTimestamp)
      Method that obtains the signing certificate of a XML time-stamp.
      static java.util.Date getGenTimeXMLTimestamp​(org.w3c.dom.Element xmlTimestamp)
      Method that obtains the gentime from a XML timestamp.
      static byte[] getSignatureTimeStampDataToStamp​(org.w3c.dom.Element dsSignature, java.lang.String inputCanonicalizationAlgorithm)
      Method that obtains the data to stamp with a time-stamp to include into a xades:SignatureTimeStamp element.
      static java.security.cert.X509Certificate getSigningCertificate​(org.bouncycastle.tsp.TimeStampToken tst)
      Method that obtain the the signing certificate of a timestamp.
      static void validateASN1Timestamp​(org.bouncycastle.tsp.TimeStampToken tst)
      Method that validates an ASN.1 timestamp.
      static void validateTimeStampReferences​(org.w3c.dom.Node xmlTST, byte[] stampedData, java.lang.String signatureTimeStampId)
      Method that validates the references contained inside of a XML time-stamp.
      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

      • 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.
      • 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.
      • getSignatureTimeStampDataToStamp

        public static byte[] getSignatureTimeStampDataToStamp​(org.w3c.dom.Element dsSignature,
                                                              java.lang.String inputCanonicalizationAlgorithm)
                                                       throws SigningException
        Method that obtains the data to stamp with a time-stamp to include into a xades:SignatureTimeStamp element.
        Parameters:
        dsSignature - Parameter that represents the ds:Signature element of the XML signature.
        inputCanonicalizationAlgorithm - Parameter that represents the canonicalization algorithm to use for generating the time-stamp.
        Returns:
        the data to stamp with the timestamp.
        Throws:
        SigningException - If the method fails.
      • getCertificateFromXMLTimestamp

        public static java.security.cert.X509Certificate getCertificateFromXMLTimestamp​(org.w3c.dom.Element xmlTimestamp)
                                                                                 throws SigningException
        Method that obtains the signing certificate of a XML time-stamp.
        Parameters:
        xmlTimestamp - Parameter that represents the dss:Timestamp element.
        Returns:
        an object that represents the signing certificate.
        Throws:
        SigningException - If the certificate cannot be retrieved.
      • validateTimeStampReferences

        public static void validateTimeStampReferences​(org.w3c.dom.Node xmlTST,
                                                       byte[] stampedData,
                                                       java.lang.String signatureTimeStampId)
                                                throws SigningException
        Method that validates the references contained inside of a XML time-stamp.
        Parameters:
        xmlTST - Parameter that represents the node as the XML time-stamp.
        stampedData - Parameter that represents the data stamped to compare with it.
        signatureTimeStampId - Parameter that represents the value of Id attribute of the xades:SignatureTimeStamp element.
        Throws:
        SigningException - If the validation fails.