Class TimestampToken
java.lang.Object
eu.europa.esig.dss.model.x509.Token
eu.europa.esig.dss.validation.timestamp.TimestampToken
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PdfTimestampToken
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)
Default constructorTimestampToken(byte[] binaries, TimestampType type, List<TimestampedReference> timestampedReferences)
Default constructor with timestamped referencesTimestampToken(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences)
Default constructor with timestamped referencesTimestampToken(org.bouncycastle.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences)
Constructor with an indication of the timestamp type. -
Method Summary
Modifier and Type Method Description protected TokenIdentifier
buildTokenIdentifier()
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 publicKeyString
getAbbreviation()
This method returns the DSS abbreviation of the token.ArchiveTimestampType
getArchiveTimestampType()
CandidatesForSigningCertificate
getCandidatesForSigningCertificate()
Returns an object with signing candidatesString
getCanonicalizationMethod()
Applies only from XAdES timestampsSet<CertificateRef>
getCertificateRefs()
Returns the Set of contained certificate references.List<CertificateToken>
getCertificates()
Returns the list of wrapped certificates.TimestampCertificateSource
getCertificateSource()
ReturnsTimestampCertificateSource
for the timestampDate
getCreationDate()
Returns the creation date of this token.TimestampCRLSource
getCRLSource()
ReturnsTimestampCRLSource
for the timestampbyte[]
getEncoded()
Returns the encoded form of the wrapped token.String
getFileName()
This method returns the file name of a detached timestampDate
getGenerationTime()
Retrieves the timestamp generation time.X500Principal
getIssuerX500Principal()
Returns theX500Principal
of the certificate which was used to sign this token.ManifestFile
getManifestFile()
This method returns the covered manifest file NOTE: applicable only for ASiC-E CAdESDigest
getMessageImprint()
This method returns the embedded message-imprint valueTimestampOCSPSource
getOCSPSource()
ReturnsTimestampOCSPSource
for the timestamporg.bouncycastle.cms.SignerInformation
getSignerInformation()
Returns used signer information from CMS Signed Data objectSet<CertificateIdentifier>
getSignerInformationStoreInfos()
Returns a list of found CertificateIdentifier in the SignerInformationStoreorg.bouncycastle.tsp.TimeStampToken
getTimeStamp()
Gets BouncyCastle implementation of a TimestampTokenSignatureAttribute
getTimestampAttribute()
Gets the timestamp's element attribute (XAdES, JAdES)List<TimestampedReference>
getTimestampedReferences()
List<TimestampInclude>
getTimestampIncludes()
Returns the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)List<SignatureScope>
getTimestampScopes()
Returns the scope of the current timestamp (detached timestamps only)TimestampType
getTimeStampType()
Retrieves the type of the timestamp token.org.bouncycastle.asn1.cms.AttributeTable
getUnsignedAttributes()
Gets unsigned attribute tableBoolean
isMessageImprintDataFound()
Boolean
isMessageImprintDataIntact()
The methodmatchData
must be invoked previously.boolean
isProcessed()
Checks if the timestamp's signature has been validatedboolean
isSignatureValid()
Indicates if the token's signature is intact.boolean
isSignedBy(CertificateToken certificateToken)
Checks if the OCSP token is signed by the given publicKeyboolean
isSignedBy(PublicKey publicKey)
Checks if the OCSP token is signed by the given publicKeyboolean
matchData(byte[] expectedMessageImprintValue)
Checks if theTimeStampToken
matches the signed data.boolean
matchData(byte[] expectedMessageImprintValue, 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.void
setArchiveTimestampType(ArchiveTimestampType archiveTimestampType)
Archive timestamps can be of different sub type.void
setCanonicalizationMethod(String canonicalizationMethod)
Allows to set the canonicalization method used by the timestamp.void
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
setTimestampAttribute(SignatureAttribute attribute)
Sets the timestamp's element attribute (XAdES, JAdES)void
setTimestampIncludes(List<TimestampInclude> timestampIncludes)
Sets the covered references by the current timestamp (XAdES IndividualDataObjectsTimeStamp)void
setTimestampScopes(List<SignatureScope> timestampScopes)
Sets timestamp's signature scopesString
toString(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, toString
-
Constructor Details
-
TimestampToken
public TimestampToken(byte[] binaries, TimestampType type) throws org.bouncycastle.tsp.TSPException, IOException, org.bouncycastle.cms.CMSExceptionDefault 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.CMSExceptionDefault 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(org.bouncycastle.cms.CMSSignedData cms, TimestampType type, List<TimestampedReference> timestampedReferences) throws org.bouncycastle.tsp.TSPException, IOExceptionDefault constructor 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.tsp.TimeStampToken timeStamp, TimestampType type, List<TimestampedReference> timestampedReferences)Constructor with an indication of the timestamp type. The default constructor forTimestampToken
.- Parameters:
timeStamp
-TimeStampToken
type
-TimestampType
timestampedReferences
- timestamped references timestamp comes from
-
-
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
-
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)
-
isSignedBy
Checks if the OCSP 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. This method is used when we want to test whether theTimeStampToken
matches 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
- 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
public boolean matchData(byte[] expectedMessageImprintValue)Checks if theTimeStampToken
matches 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 theTimeStampToken
matches 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()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
Retrieves the timestamp generation time.- Returns:
Date
-
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
-
isMessageImprintDataFound
- Returns:
- true if the message imprint data was found, false otherwise
-
isMessageImprintDataIntact
The methodmatchData
must 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:
List
ofTimestampReference
s
-
getArchiveTimestampType
- Returns:
ArchiveTimestampType
in the case of an archive timestamp,null
otherwise
-
setArchiveTimestampType
Archive timestamps can be of different sub type.- Parameters:
archiveTimestampType
-ArchiveTimestampType
-
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
-
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
-
getTimeStamp
public org.bouncycastle.tsp.TimeStampToken getTimeStamp()Gets BouncyCastle implementation of a TimestampToken- Returns:
TimeStampToken
-
getTimestampAttribute
Gets the timestamp's element attribute (XAdES, JAdES)- Returns:
SignatureAttribute
-
setTimestampAttribute
Sets the timestamp's element attribute (XAdES, JAdES)- Parameters:
attribute
-SignatureAttribute
-
toString
Description copied from class:Token
Returns a string representation of the token. -
getSignerInformationStoreInfos
Returns a list of found CertificateIdentifier in the SignerInformationStore- Returns:
- a list of
CertificateIdentifier
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
-