Package eu.europa.esig.dss.spi.x509.tsp
Class TimestampToken
java.lang.Object
eu.europa.esig.dss.model.x509.Token
eu.europa.esig.dss.spi.x509.tsp.TimestampToken
- All Implemented Interfaces:
IdentifierBasedObject
,Serializable
- Direct Known Subclasses:
PdfTimestampToken
SignedToken containing a TimeStamp.
- See Also:
-
Field Summary
Fields inherited from class eu.europa.esig.dss.model.x509.Token
publicKeyOfTheSigner, signatureAlgorithm, signatureInvalidityReason, signatureValidity
-
Constructor Summary
ConstructorDescriptionTimestampToken
(byte[] binaries, TimestampType type) Default constructorTimestampToken
(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences) Default constructor with timestamped referencesTimestampToken
(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampIdentifierBuilder identifierBuilder) Default constructor with timestamped references and identifier builderTimestampToken
(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences) Constructor from CMS with timestamped referencesTimestampToken
(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampIdentifierBuilder identifierBuilder) Constructor from CMS with timestamped references and identifier builderTimestampToken
(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences) Constructor with an indication of the timestamp type and time-stamped references.TimestampToken
(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampIdentifierBuilder identifierBuilder) Constructor with an indication of the timestamp type, time-stamped references and an identifier builder. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDetachedEvidenceRecord
(EvidenceRecord evidenceRecord) Adds an evidence record to the time-stamp's listprotected boolean
This method verifies whether the corresponding reference validations are validprotected TokenIdentifier
Builds a token unique identifierprotected SignatureValidity
checkIsSignedBy
(CertificateToken candidate) Checks if timestamp is signed by teh given certificateprotected SignatureValidity
checkIsSignedBy
(PublicKey publicKey) Verifies if the current token has been signed by the specified publicKeyThis method returns the DSS abbreviation of the token.Gets theArchiveTimestampType
, when applicableReturns an object with signing candidatesApplies only from XAdES timestampsReturns the Set of contained certificate references.Returns the list of wrapped certificates.ReturnsTimestampCertificateSource
for the timestampReturns the creation date of this token.ReturnsTimestampCRLSource
for the timestampGets a list of detached evidence records covering the time-stamp, when applicablebyte[]
getDigest
(DigestAlgorithm digestAlgorithm) Returns the digest value of the wrapped tokenThis method returns aDigestAlgorithm
used for message-imprint computation of the timestamp tokenbyte[]
Returns the encoded form of the wrapped token.Gets theEvidenceRecordTimestampType
, when applicableThis method returns the file name of a detached timestampRetrieves the timestamp generation time.Returns theX500Principal
of the certificate which was used to sign this token.This method returns the covered manifest file NOTE: applicable only for ASiC-E CAdESThis method returns the embedded message-imprint valueReturnsTimestampOCSPSource
for the timestampReturns a list of timestamped data reference validations (used for Evidence Record timestamps)org.bouncycastle.cms.SignerInformation
Returns used signer information from CMS Signed Data objectReturns a list of found CertificateIdentifier in the SignerInformationStoreorg.bouncycastle.tsp.TimeStampToken
Gets BouncyCastle implementation of a TimestampTokenGets list ofTimestampedReference
s covered by the current timestampprotected TimestampIdentifierBuilder
Returns aTimestampTokenIdentifierBuilder
implementationReturns the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)Returns the scope of the current timestamp (detached timestamps only)Retrieves the type of the timestamp token.Returns a TSTInfo.tsa attribute identifying the timestamp issuer, when attribute is presentorg.bouncycastle.asn1.cms.AttributeTable
Gets unsigned attribute tableboolean
Checks if the data for message-imprint computation has been foundboolean
The methodmatchData
must be invoked previously.boolean
Checks if the timestamp's signature has been validatedboolean
isSignedBy
(CertificateToken certificateToken) Checks if the timestamp token is signed by the given publicKeyboolean
isSignedBy
(PublicKey publicKey) Checks if the OCSP token is signed by the given publicKeyboolean
isValid()
Indicated if the signature is intact and the message-imprint matches the computed message-imprint.boolean
matchData
(byte[] expectedMessageImprintDigest) Checks if theTimeStampToken
matches the signed data.boolean
matchData
(byte[] expectedMessageImprintDigest, boolean suppressMatchWarnings) Checks if theTimeStampToken
matches the signed data.boolean
matchData
(DSSDocument timestampedData) Checks if theTimeStampToken
matches the signed data.boolean
matchData
(DSSDocument timestampedData, boolean suppressMatchWarnings) Checks if theTimeStampToken
matches the signed data.boolean
matchData
(DSSMessageDigest messageDigest) Checks if theTimeStampToken
matches the message-imprint digest with warning enabled.boolean
matchData
(DSSMessageDigest messageDigest, boolean suppressMatchWarnings) Checks if theTimeStampToken
matches the message-imprint digest.void
setArchiveTimestampType
(ArchiveTimestampType archiveTimestampType) Archive timestamps can be of different subtype.void
setCanonicalizationMethod
(String canonicalizationMethod) Allows to set the canonicalization method used by the timestamp.void
setEvidenceRecordTimestampType
(EvidenceRecordTimestampType evidenceRecordTimestampType) Sets theEvidenceRecordTimestampType
, for an evidence record's time-stampvoid
setFileName
(String fileName) Sets the filename of a detached timestampvoid
setManifestFile
(ManifestFile manifestFile) Sets the manifest file covered by the current timestamp NOTE: applicable only for ASiC-E CAdESvoid
setReferenceValidations
(List<ReferenceValidation> referenceValidations) Sets a list of timestamped data reference validations (used for Evidence Record timestamps)void
setTimestampIncludes
(List<TimestampInclude> timestampIncludes) Sets the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)void
setTimestampScopes
(List<SignatureScope> timestampScopes) Sets timestamp's signature scopesReturns a string representation of the token.Methods inherited from class eu.europa.esig.dss.model.x509.Token
equals, getDSSId, getDSSIdAsString, getInvalidityReason, getPublicKeyOfTheSigner, getSignatureAlgorithm, getSignatureValidity, hashCode, isSelfSigned, isSignatureIntact, toString
-
Constructor Details
-
TimestampToken
public TimestampToken(byte[] binaries, TimestampType type) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSException Default constructor- Parameters:
binaries
- byte arraytype
-TimestampType
- Throws:
org.bouncycastle.tsp.TSPException
- if timestamp creation exception occursIOException
- if IOException occursorg.bouncycastle.cms.CMSException
- if CMS data building exception occurs
-
TimestampToken
public TimestampToken(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSException Default constructor with timestamped references- Parameters:
binaries
- byte arraytype
-TimestampType
timestampedReferences
- a list ofTimestampedReference
s- Throws:
org.bouncycastle.tsp.TSPException
- if timestamp creation exception occursIOException
- if IOException occursorg.bouncycastle.cms.CMSException
- if CMS data building exception occurs
-
TimestampToken
public TimestampToken(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampIdentifierBuilder identifierBuilder) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSException Default constructor with timestamped references and identifier builder- Parameters:
binaries
- byte arraytype
-TimestampType
timestampedReferences
- a list ofTimestampedReference
sidentifierBuilder
-TimestampIdentifierBuilder
- Throws:
org.bouncycastle.tsp.TSPException
- if timestamp creation exception occursIOException
- if IOException occursorg.bouncycastle.cms.CMSException
- if CMS data building exception occurs
-
TimestampToken
public TimestampToken(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences) throws org.bouncycastle.tsp.TSPException, IOException Constructor from CMS with timestamped references- Parameters:
cms
-CMSSignedData
type
-TimestampType
timestampedReferences
- a list ofTimestampedReference
s- Throws:
org.bouncycastle.tsp.TSPException
- if timestamp creation exception occursIOException
- if IOException occurs
-
TimestampToken
public TimestampToken(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampIdentifierBuilder identifierBuilder) throws org.bouncycastle.tsp.TSPException, IOException Constructor from CMS with timestamped references and identifier builder- Parameters:
cms
-CMSSignedData
type
-TimestampType
timestampedReferences
- a list ofTimestampedReference
sidentifierBuilder
-TimestampIdentifierBuilder
- Throws:
org.bouncycastle.tsp.TSPException
- if timestamp creation exception occursIOException
- if IOException occurs
-
TimestampToken
public TimestampToken(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences) Constructor with an indication of the timestamp type and time-stamped references. The default constructor forTimestampToken
. Builds an implementation independent identifier.- Parameters:
timeStamp
-TimeStampToken
type
-TimestampType
timestampedReferences
- timestamped references timestamp comes from
-
TimestampToken
public TimestampToken(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences, TimestampIdentifierBuilder identifierBuilder) Constructor with an indication of the timestamp type, time-stamped references and an identifier builder.- Parameters:
timeStamp
-TimeStampToken
type
-TimestampType
timestampedReferences
- timestamped references timestamp comes fromidentifierBuilder
-TimestampIdentifierBuilder
-
-
Method Details
-
getIssuerX500Principal
Description copied from class:Token
Returns theX500Principal
of the certificate which was used to sign this token.- Specified by:
getIssuerX500Principal
in classToken
- Returns:
- the issuer's
X500Principal
-
getAbbreviation
Description copied from class:Token
This method returns the DSS abbreviation of the token. It is used for debugging purpose.- Overrides:
getAbbreviation
in classToken
- Returns:
- an abbreviation for the certificate
-
getCertificateSource
ReturnsTimestampCertificateSource
for the timestamp- Returns:
TimestampCertificateSource
-
getCRLSource
ReturnsTimestampCRLSource
for the timestamp- Returns:
TimestampCRLSource
-
getOCSPSource
ReturnsTimestampOCSPSource
for the timestamp- Returns:
TimestampOCSPSource
-
isValid
public boolean isValid()Indicated if the signature is intact and the message-imprint matches the computed message-imprint. NOTE: The method isSignedBy(CertificateToken) must be called before calling the method. SeeTimestampToken.isSignatureIntact()
for more details -
isSignedBy
Checks if the timestamp token is signed by the given publicKey- Overrides:
isSignedBy
in classToken
- Parameters:
certificateToken
- the candidate to be tested- Returns:
- true if this token is signed by the given public key
-
isSignedBy
Description copied from class:Token
Checks if the OCSP token is signed by the given publicKey- Overrides:
isSignedBy
in classToken
- Parameters:
publicKey
- the candidate to be tested- Returns:
- true if this token is signed by the given public key
-
checkIsSignedBy
Checks if timestamp is signed by teh given certificate- Parameters:
candidate
-CertificateToken
- Returns:
SignatureValidity
-
checkIsSignedBy
Description copied from class:Token
Verifies if the current token has been signed by the specified publicKey- Specified by:
checkIsSignedBy
in classToken
- Parameters:
publicKey
-PublicKey
of a signing candidate- Returns:
SignatureValidity
-
matchData
Checks if theTimeStampToken
matches the signed data.- Parameters:
timestampedData
- aDSSDocument
representing the timestamped data- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
Checks if theTimeStampToken
matches the signed data.- Parameters:
timestampedData
- aDSSDocument
representing the timestamped datasuppressMatchWarnings
- if true the message imprint match warning logs are suppressed.- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
Checks if theTimeStampToken
matches the message-imprint digest with warning enabled.- Parameters:
messageDigest
-DSSMessageDigest
representing the message-imprint digest- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
Checks if theTimeStampToken
matches the message-imprint digest.- Parameters:
messageDigest
-DSSMessageDigest
representing the message-imprint digestsuppressMatchWarnings
- 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[] expectedMessageImprintDigest) Checks if theTimeStampToken
matches the signed data.- Parameters:
expectedMessageImprintDigest
- the expected message-imprint digest value- Returns:
- true if the data is verified by the TimeStampToken
-
matchData
public boolean matchData(byte[] expectedMessageImprintDigest, boolean suppressMatchWarnings) Checks if theTimeStampToken
matches the signed data.- Parameters:
expectedMessageImprintDigest
- the expected message-imprint digest 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()Checks if the timestamp's signature has been validated- Returns:
- TRUE if the timestamp's signature has been validated, FALSE otherwise
-
getTimeStampType
Retrieves the type of the timestamp token.- Returns:
TimestampType
-
getGenerationTime
-
getCreationDate
Description copied from class:Token
Returns 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:
getCreationDate
in 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
-
getDigestAlgorithm
This method returns aDigestAlgorithm
used for message-imprint computation of the timestamp token- Returns:
DigestAlgorithm
-
isMessageImprintDataFound
public boolean isMessageImprintDataFound()Checks if the data for message-imprint computation has been found- Returns:
- true if the message imprint data was found, false otherwise
-
isMessageImprintDataIntact
public boolean isMessageImprintDataIntact()The methodmatchData
must be invoked previously.- Returns:
- true if the message imprint data is intact, false otherwise
-
getFileName
-
setFileName
-
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
Gets list ofTimestampedReference
s covered by the current timestamp- Returns:
List
ofTimestampReference
s
-
getArchiveTimestampType
Gets theArchiveTimestampType
, when applicable- Returns:
ArchiveTimestampType
in the case of an archive timestamp,null
otherwise
-
setArchiveTimestampType
Archive timestamps can be of different subtype.- Parameters:
archiveTimestampType
-ArchiveTimestampType
-
getEvidenceRecordTimestampType
Gets theEvidenceRecordTimestampType
, when applicable- Returns:
EvidenceRecordTimestampType
in the case of an evidence record archive time-stamp, null otherwise
-
setEvidenceRecordTimestampType
Sets theEvidenceRecordTimestampType
, for an evidence record's time-stamp- Parameters:
evidenceRecordTimestampType
-EvidenceRecordTimestampType
-
getCanonicalizationMethod
Applies only from XAdES timestamps- Returns:
String
representing 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
-String
representing the canonicalization method
-
getEncoded
public byte[] getEncoded()Description copied from class:Token
Returns the encoded form of the wrapped token.- Specified by:
getEncoded
in classToken
- Returns:
- the encoded form of the wrapped token
-
getTimestampIncludes
Returns the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)- Returns:
- a list of timestamp's includes
-
setTimestampIncludes
Sets the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)- Parameters:
timestampIncludes
- a list of timestamp's includes
-
getReferenceValidations
Returns a list of timestamped data reference validations (used for Evidence Record timestamps)- Returns:
- a list of
ReferenceValidation
s
-
setReferenceValidations
Sets a list of timestamped data reference validations (used for Evidence Record timestamps)- Parameters:
referenceValidations
- a list ofReferenceValidation
s
-
areReferenceValidationsValid
protected boolean areReferenceValidationsValid()This method verifies whether the corresponding reference validations are valid- Returns:
- TRUE if all reference validations are valid, FALSE otherwise
-
getDetachedEvidenceRecords
Gets a list of detached evidence records covering the time-stamp, when applicable- Returns:
- a list of
EvidenceRecord
s
-
addDetachedEvidenceRecord
Adds an evidence record to the time-stamp's list- Parameters:
evidenceRecord
-EvidenceRecord
-
getTimestampScopes
Returns the scope of the current timestamp (detached timestamps only)- Returns:
- a list of SignatureScope
-
setTimestampScopes
Sets timestamp's signature scopes- Parameters:
timestampScopes
- a list ofSignatureScope
s
-
getCertificates
Returns the list of wrapped certificates.- Returns:
List
ofCertificateToken
-
getCertificateRefs
Returns the Set of contained certificate references.- Returns:
Set
ofCertificateRef
-
getUnsignedAttributes
public org.bouncycastle.asn1.cms.AttributeTable getUnsignedAttributes()Gets unsigned attribute table- Returns:
AttributeTable
-
getTSTInfoTsa
Returns a TSTInfo.tsa attribute identifying the timestamp issuer, when attribute is present- Returns:
GeneralName
-
getTimeStamp
public org.bouncycastle.tsp.TimeStampToken getTimeStamp()Gets BouncyCastle implementation of a TimestampToken- Returns:
TimeStampToken
-
toString
-
getSignerInformationStoreInfos
Returns a list of found CertificateIdentifier in the SignerInformationStore- Returns:
- a list of
SignerIdentifier
s
-
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:Token
Builds a token unique identifier- Specified by:
buildTokenIdentifier
in classToken
- Returns:
TokenIdentifier
-
getTimestampIdentifierBuilder
Returns aTimestampTokenIdentifierBuilder
implementation- Returns:
TimestampIdentifierBuilder
-
getDigest
Description copied from class:Token
Returns the digest value of the wrapped token
-