Package es.gob.afirma.utils
Class UtilsTimestampXML
- java.lang.Object
-
- es.gob.afirma.utils.UtilsTimestampXML
-
public final class UtilsTimestampXML extends java.lang.ObjectClass 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.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.security.cert.X509CertificategetCertificateFromXMLTimestamp(org.w3c.dom.Element xmlTimestamp)Method that obtains the signing certificate of a XML time-stamp.static java.util.DategetGenTimeXMLTimestamp(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 axades:SignatureTimeStampelement.static java.security.cert.X509CertificategetSigningCertificate(org.bouncycastle.tsp.TimeStampToken tst)Method that obtain the the signing certificate of a timestamp.static voidvalidateASN1Timestamp(org.bouncycastle.tsp.TimeStampToken tst)Method that validates an ASN.1 timestamp.static voidvalidateTimeStampReferences(org.w3c.dom.Node xmlTST, byte[] stampedData, java.lang.String signatureTimeStampId)Method that validates the references contained inside of a XML time-stamp.static voidvalidateXMLTimestamp(org.w3c.dom.Element tst)Method that validates a XML timestamp.
-
-
-
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 SigningExceptionMethod 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 SigningExceptionMethod 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 SigningExceptionMethod 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 SigningExceptionMethod 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 SigningExceptionMethod that obtains the data to stamp with a time-stamp to include into axades:SignatureTimeStampelement.- Parameters:
dsSignature- Parameter that represents theds:Signatureelement 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 SigningExceptionMethod that obtains the signing certificate of a XML time-stamp.- Parameters:
xmlTimestamp- Parameter that represents thedss:Timestampelement.- 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 SigningExceptionMethod 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 ofIdattribute of thexades:SignatureTimeStampelement.- Throws:
SigningException- If the validation fails.
-
-