Package es.gob.afirma.utils
Class UtilsTimestampPdfBc
- java.lang.Object
-
- es.gob.afirma.utils.UtilsTimestampPdfBc
-
public final class UtilsTimestampPdfBc 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.1, 18/04/2022.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.bouncycastle.tsp.TimeStampTokengetFirstTimeStampToken(org.bouncycastle.asn1.ASN1EncodableVector unsignedAttributes)Method that obtains the first time-stamp contained inside of a list of unsigned attributes.static java.util.List<org.bouncycastle.tsp.TimeStampToken>getOrderedTimeStampTokens(org.bouncycastle.asn1.ASN1EncodableVector unsignedAttributes)Method that obtains a list with the timestamps contained inside of a set of unsigned attributes.static java.security.cert.X509CertificategetSigningCertificate(org.bouncycastle.tsp.TimeStampToken tst)Method that obtain the the signing certificate of a timestamp.static org.bouncycastle.tsp.TimeStampTokengetTimeStampToken(org.bouncycastle.asn1.cms.Attribute signatureTimeStampAttribute, java.security.cert.X509Certificate signingCertificate)Method that obtains the time-stamp contained inside of asignature-time-stampattribute.static org.bouncycastle.tsp.TimeStampTokengetTimeStampToken(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 voidvalidateASN1Timestamp(org.bouncycastle.tsp.TimeStampToken tst)Method that validates an ASN.1 timestamp.static voidvalidateTimestampMessageImprint(org.bouncycastle.tsp.TimeStampToken tst, byte[] stampedData)Method that checks if the value of the messageImprint field within time-stamp token is a hash of the value indicated.
-
-
-
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.
-
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.
-
getTimeStampToken
public static org.bouncycastle.tsp.TimeStampToken getTimeStampToken(org.bouncycastle.cms.SignerInformation signerInformation) throws SigningExceptionMethod 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.
-
getFirstTimeStampToken
public static org.bouncycastle.tsp.TimeStampToken getFirstTimeStampToken(org.bouncycastle.asn1.ASN1EncodableVector unsignedAttributes) throws SigningExceptionMethod that obtains the first time-stamp contained inside of a list of unsigned attributes.- Parameters:
unsignedAttributes- Parameter that represents the list of unsigned attribute of an ASN.1 signature.- Returns:
- an object that represents the time-stamp.
- Throws:
SigningException- If one of the attributes contains a badly formed time-stamp.
-
getTimeStampToken
public static org.bouncycastle.tsp.TimeStampToken getTimeStampToken(org.bouncycastle.asn1.cms.Attribute signatureTimeStampAttribute, java.security.cert.X509Certificate signingCertificate) throws SigningExceptionMethod that obtains the time-stamp contained inside of asignature-time-stampattribute.- Parameters:
signatureTimeStampAttribute- Parameter that represents thesignature-time-stampattribute.signingCertificate- Parameter that represents the signing certificate.- Returns:
- an object that represents the time-stamp.
- Throws:
SigningException- If the time-stamp is badly encoded.
-
validateTimestampMessageImprint
public static void validateTimestampMessageImprint(org.bouncycastle.tsp.TimeStampToken tst, byte[] stampedData) throws SigningExceptionMethod that checks if the value of the messageImprint field within time-stamp token is a hash of the value indicated.- Parameters:
tst- Parameter that represents the timestamp.stampedData- Parameter that represents the data stamped to compare with it.- Throws:
SigningException- If the validation fails.
-
getOrderedTimeStampTokens
public static java.util.List<org.bouncycastle.tsp.TimeStampToken> getOrderedTimeStampTokens(org.bouncycastle.asn1.ASN1EncodableVector unsignedAttributes) throws SigningExceptionMethod that obtains a list with the timestamps contained inside of a set of unsigned attributes.- Parameters:
unsignedAttributes- Parameter that represents the set of unsigned attributes.- Returns:
- the list sorted in ascending order.
- Throws:
SigningException- If the method fails.
-
-