Class TimestampToken
java.lang.Object
eu.europa.esig.dss.model.x509.Token
eu.europa.esig.dss.validation.timestamp.TimestampToken
- All Implemented Interfaces:
Serializable
public class TimestampToken extends Token
SignedToken containing a TimeStamp.
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class eu.europa.esig.dss.model.x509.Token
publicKeyOfTheSigner, signatureAlgorithm, signatureInvalidityReason, signatureValidity -
Constructor Summary
Constructors Constructor Description TimestampToken(byte[] binaries, TimestampType type)TimestampToken(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampLocation timestampLocation)TimestampToken(PdfRevision pdfTimestampRevision, TimestampType type, TimestampLocation timestampLocation)TimestampToken(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampLocation timestampLocation)TimestampToken(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampLocation timestampLocation)Constructor with an indication of the timestamp type. -
Method Summary
Modifier and Type Method Description protected TokenIdentifierbuildTokenIdentifier()Builds a token unique identifierprotected SignatureValiditycheckIsSignedBy(CertificateToken candidate)Verifies if the current token has been signed by the specified certificateTokenStringgetAbbreviation()This method returns the DSS abbreviation of the token.ArchiveTimestampTypegetArchiveTimestampType()CandidatesForSigningCertificategetCandidatesForSigningCertificate()Returns an object with signing candidatesStringgetCanonicalizationMethod()Applies only from XAdES timestampsSet<CertificateRef>getCertificateRefs()Returns the Set of contained certificate references.List<CertificateToken>getCertificates()Returns the list of wrapped certificates.TimestampCertificateSourcegetCertificateSource()ReturnsTimestampCertificateSourcefor the timestampDategetCreationDate()Returns the creation date of this token.TimestampCRLSourcegetCRLSource()ReturnsTimestampCRLSourcefor the timestampbyte[]getEncoded()Returns the encoded form of the wrapped token.StringgetFileName()This method returns the file name of a detached timestampDategetGenerationTime()Retrieves the timestamp generation time.intgetHashCode()Used only with XAdES timestamps.X500PrincipalgetIssuerX500Principal()Returns theX500Principalof the certificate which was used to sign this token.ManifestFilegetManifestFile()This method returns the covered manifest file NOTE: applicable only for ASiC-E CAdESDigestgetMessageImprint()This method returns the embedded message-imprint valueTimestampOCSPSourcegetOCSPSource()ReturnsTimestampOCSPSourcefor the timestampPdfRevisiongetPdfRevision()Returns the current PDF timestamp revisionorg.bouncycastle.cms.SignerInformationgetSignerInformation()Returns used signer information from CMS Signed Data objectSet<CertificateIdentifier>getSignerInformationStoreInfos()Returns a list of found CertificateIdentifier in the SignerInformationStoreorg.bouncycastle.tsp.TimeStampTokengetTimeStamp()List<TimestampedReference>getTimestampedReferences()List<TimestampInclude>getTimestampIncludes()Returns the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)TimestampLocationgetTimestampLocation()Retrieves the location of timestamp token.List<SignatureScope>getTimestampScopes()Returns the scope of the current timestamp (detached timestamps only)TimestampTypegetTimeStampType()Retrieves the type of the timestamp token.org.bouncycastle.asn1.cms.AttributeTablegetUnsignedAttributes()BooleanisMessageImprintDataFound()BooleanisMessageImprintDataIntact()The methodmatchDatamust be invoked previously.booleanisProcessed()booleanisSignatureValid()Indicates if the token's signature is intact.booleanmatchData(byte[] expectedMessageImprintValue)Checks if theTimeStampTokenmatches the signed data.booleanmatchData(byte[] expectedMessageImprintValue, boolean suppressMatchWarnings)Checks if theTimeStampTokenmatches the signed data.booleanmatchData(DSSDocument timestampedData)Checks if theTimeStampTokenmatches the signed data.booleanmatchData(DSSDocument timestampedData, boolean suppressMatchWarnings)Checks if theTimeStampTokenmatches the signed data.voidsetArchiveTimestampType(ArchiveTimestampType archiveTimestampType)Archive timestamps can be of different sub type.voidsetCanonicalizationMethod(String canonicalizationMethod)Allows to set the canonicalization method used by the timestamp.voidsetFileName(String fileName)Sets the filename of a detached timestampvoidsetHashCode(int hashCode)Used only with XAdES timestamps.voidsetManifestFile(ManifestFile manifestFile)Sets the manifest file covered by the current timestamp NOTE: applicable only for ASiC-E CAdESvoidsetTimestampIncludes(List<TimestampInclude> timestampIncludes)voidsetTimestampScopes(List<SignatureScope> timestampScopes)StringtoString(String indentStr)Returns a string representation of the token.Methods inherited from class eu.europa.esig.dss.model.x509.Token
equals, getDigest, getDSSId, getDSSIdAsString, getPublicKeyOfTheSigner, getSignatureAlgorithm, getSignatureValidity, hashCode, isSelfSigned, isSignedBy, toString
-
Constructor Details
-
TimestampToken
public TimestampToken(byte[] binaries, TimestampType type) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSException- Throws:
org.bouncycastle.tsp.TSPExceptionIOExceptionorg.bouncycastle.cms.CMSException
-
TimestampToken
public TimestampToken(PdfRevision pdfTimestampRevision, TimestampType type, TimestampLocation timestampLocation) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSException- Throws:
org.bouncycastle.tsp.TSPExceptionIOExceptionorg.bouncycastle.cms.CMSException
-
TimestampToken
public TimestampToken(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampLocation timestampLocation) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSException- Throws:
org.bouncycastle.tsp.TSPExceptionIOExceptionorg.bouncycastle.cms.CMSException
-
TimestampToken
public TimestampToken(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampLocation timestampLocation) throws org.bouncycastle.tsp.TSPException, IOException- Throws:
org.bouncycastle.tsp.TSPExceptionIOException
-
TimestampToken
public TimestampToken(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampLocation timestampLocation)Constructor with an indication of the timestamp type. The default constructor forTimestampToken.- Parameters:
timeStamp-TimeStampTokentype-TimestampTypetimestampedReferences- timestamped referencestimestampLocation-TimestampLocationdefines where the timestamp comes from
-
-
Method Details
-
getIssuerX500Principal
Description copied from class:TokenReturns theX500Principalof the certificate which was used to sign this token.- Specified by:
getIssuerX500Principalin classToken- Returns:
- the issuer's
X500Principal
-
getAbbreviation
Description copied from class:TokenThis method returns the DSS abbreviation of the token. It is used for debugging purpose.- Overrides:
getAbbreviationin classToken- Returns:
- an abbreviation for the certificate
-
getCertificateSource
ReturnsTimestampCertificateSourcefor the timestamp- Returns:
TimestampCertificateSource
-
getCRLSource
ReturnsTimestampCRLSourcefor the timestamp- Returns:
TimestampCRLSource
-
getOCSPSource
ReturnsTimestampOCSPSourcefor the timestamp- Returns:
TimestampOCSPSource
-
isSignatureValid
public boolean isSignatureValid()Indicates if the token's signature is intact. The method isSignedBy(CertificateToken) must be called to set this flag. Note: return false if the check isSignedBy() was not performed or the signer's public key does not much. In order to check if the validation has been performed, use the method getSignatureValidity() that returns a three-state value.- Returns:
- true if the signature is valid (== SignatureValidity.VALID)
-
checkIsSignedBy
Description copied from class:TokenVerifies if the current token has been signed by the specified certificateToken- Specified by:
checkIsSignedByin classToken- Parameters:
candidate-CertificateTokensigned candidate- Returns:
SignatureValidity
-
matchData
Checks if theTimeStampTokenmatches the signed data.- Parameters:
timestampedData- aDSSDocumentrepresenting the timestamped data- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
Checks if theTimeStampTokenmatches the signed data. This method is used when we want to test whether theTimeStampTokenmatches the signed data calculated according to ETSI TS 101 733 v2.2.1 and depending on the result re-run the message imprint calculation according to ETSI TS 101 733 v1.8.3. It is part of solution for the issue DSS-1401 (https://ec.europa.eu/cefdigital/tracker/browse/DSS-1401)- Parameters:
timestampedData- aDSSDocumentrepresenting the timestamped datasuppressMatchWarnings- if true the message imprint match warning logs are suppressed.- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
public boolean matchData(byte[] expectedMessageImprintValue)Checks if theTimeStampTokenmatches the signed data.- Parameters:
expectedMessageImprintValue- the expected message-imprint value- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
public boolean matchData(byte[] expectedMessageImprintValue, boolean suppressMatchWarnings)Checks if theTimeStampTokenmatches the signed data.- Parameters:
expectedMessageImprintValue- the expected message-imprint valuesuppressMatchWarnings- if true the message imprint match warning logs are suppressed.- Returns:
- true if the data is verified by the TimeStampToken
-
isProcessed
public boolean isProcessed() -
getPdfRevision
Returns the current PDF timestamp revision- Returns:
PdfRevision
-
getTimeStampType
Retrieves the type of the timestamp token.- Returns:
TimestampType
-
getTimestampLocation
Retrieves the location of timestamp token.- Returns:
TimestampLocation
-
getGenerationTime
Retrieves the timestamp generation time.- Returns:
Date
-
getCreationDate
Description copied from class:TokenReturns the creation date of this token. This date is mainly used to retrieve the correct issuer within a collection of renewed certificates (new certificate with the same key pair).- Specified by:
getCreationDatein classToken- Returns:
- the creation date of the token (notBefore for a certificate, productionDate for revocation data,...)
-
getMessageImprint
This method returns the embedded message-imprint value- Returns:
- a Digest DTO with the algorithm and the value
-
isMessageImprintDataFound
- Returns:
- true if the message imprint data was found, false otherwise
-
isMessageImprintDataIntact
The methodmatchDatamust be invoked previously.- Returns:
- true if the message imprint data is intact, false otherwise
-
getFileName
This method returns the file name of a detached timestamp- Returns:
String
-
setFileName
Sets the filename of a detached timestamp- Parameters:
fileName-String
-
getManifestFile
This method returns the covered manifest file NOTE: applicable only for ASiC-E CAdES- Returns:
ManifestFile
-
setManifestFile
Sets the manifest file covered by the current timestamp NOTE: applicable only for ASiC-E CAdES- Parameters:
manifestFile-ManifestFile
-
getTimestampedReferences
- Returns:
ListofTimestampReferences
-
getArchiveTimestampType
- Returns:
ArchiveTimestampTypein the case of an archive timestamp,nullotherwise
-
setArchiveTimestampType
Archive timestamps can be of different sub type.- Parameters:
archiveTimestampType-ArchiveTimestampType
-
getCanonicalizationMethod
Applies only from XAdES timestamps- Returns:
Stringrepresenting the canonicalization method used by the timestamp
-
setCanonicalizationMethod
Allows to set the canonicalization method used by the timestamp. Applies only with XAdES timestamps.- Parameters:
canonicalizationMethod-Stringrepresenting the canonicalization method
-
getEncoded
public byte[] getEncoded()Description copied from class:TokenReturns the encoded form of the wrapped token.- Specified by:
getEncodedin classToken- Returns:
- the encoded form of the wrapped token
-
getTimestampIncludes
Returns the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)- Returns:
-
setTimestampIncludes
-
getTimestampScopes
Returns the scope of the current timestamp (detached timestamps only)- Returns:
- a list of SignatureScope
-
setTimestampScopes
-
getCertificates
Returns the list of wrapped certificates.- Returns:
ListofCertificateToken
-
getCertificateRefs
Returns the Set of contained certificate references.- Returns:
SetofCertificateRef
-
getUnsignedAttributes
public org.bouncycastle.asn1.cms.AttributeTable getUnsignedAttributes() -
getTimeStamp
public org.bouncycastle.tsp.TimeStampToken getTimeStamp() -
setHashCode
public void setHashCode(int hashCode)Used only with XAdES timestamps.- Parameters:
hashCode- the hash code of the DOM element containing the timestamp
-
getHashCode
public int getHashCode()Used only with XAdES timestamps.- Returns:
- the hash code of the DOM element containing the timestamp
-
toString
Description copied from class:TokenReturns a string representation of the token. -
getSignerInformationStoreInfos
Returns a list of found CertificateIdentifier in the SignerInformationStore- Returns:
- a list of
CertificateIdentifiers
-
getCandidatesForSigningCertificate
Returns an object with signing candidates- Returns:
CandidatesForSigningCertificate
-
getSignerInformation
public org.bouncycastle.cms.SignerInformation getSignerInformation()Returns used signer information from CMS Signed Data object- Returns:
SignerInformation
-
buildTokenIdentifier
Description copied from class:TokenBuilds a token unique identifier- Specified by:
buildTokenIdentifierin classToken- Returns:
TokenIdentifier
-