Class AbstractTimestampSource<SignatureAttribute extends ISignatureAttribute>
java.lang.Object
eu.europa.esig.dss.validation.timestamp.AbstractTimestampSource<SignatureAttribute>
- All Implemented Interfaces:
SignatureTimestampSource,Serializable
- Direct Known Subclasses:
CAdESTimestampSource,XAdESTimestampSource
public abstract class AbstractTimestampSource<SignatureAttribute extends ISignatureAttribute> extends Object implements SignatureTimestampSource
Contains a set of
TimestampTokens found in a DefaultAdvancedSignature object- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected CertificatePoolcertificatePoolprotected ListCRLSourcecrlSourceRevocation sources containing merged data from timestampsprotected ListOCSPSourceocspSourceprotected SignatureCertificateSourcesignatureCertificateSourceSources obtained from a signature objectprotected SignatureCRLSourcesignatureCRLSourceprotected StringsignatureIdprotected SignatureOCSPSourcesignatureOCSPSourceprotected List<SignatureScope>signatureScopesprotected CommonCertificateSourcetimestampCertificateSourceLocal timestamp source to store certificate values found in timestamps -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTimestampSource(AdvancedSignature signature)Default constructor -
Method Summary
Modifier and Type Method Description protected voidaddEncapsulatedValuesFromTimestamp(List<TimestampedReference> references, TimestampToken timestampedTimestamp)Adds to thereferenceslist all validation data embedded to thetimestampedTimestampvoidaddExternalTimestamp(TimestampToken timestamp)This method allows to add an external timestamp.protected voidaddReference(List<TimestampedReference> referenceList, TimestampedReference referenceToAdd)AddsreferenceToAddtoreferenceListwithout duplicatesprotected voidaddReferences(List<TimestampedReference> referenceList, List<TimestampedReference> referencesToAdd)AddsreferencesToAddtoreferenceListwithout duplicatesprotected voidaddReferencesForPreviousTimestamps(List<TimestampedReference> references, List<TimestampToken> timestampedTimestamps)protected voidcreateAndValidate()Creates and validates all timestamps Must be called only onceprotected List<TimestampedReference>createReferencesForCertificates(Collection<CertificateToken> certificates)Creates a list ofTimestampedReferences for the provided list ofcertificatesprotected List<TimestampedReference>getAllContentTimestampReferences()Returns a list ofTimestampedReferences obtained from thesignatureScopesList<TimestampToken>getAllTimestamps()List<TimestampToken>getArchiveTimestamps()protected abstract ArchiveTimestampTypegetArchiveTimestampType(SignatureAttribute unsignedAttribute)ReturnsArchiveTimestampTypefor the givenunsignedAttributeMap<String,List<CertificateToken>>getCertificateMapWithinTimestamps(boolean skipLastArchiveTimestamp)Returns a map between all found timestamps and their certificatesprotected abstract List<Digest>getCertificateRefDigests(SignatureAttribute unsignedAttribute)Returns a list ofDigests from the givenunsignedAttributeList<CertificateToken>getCertificates()Returns a list of all found certificates in the timestampsList<TimestampToken>getContentTimestamps()List<TimestampToken>getDocumentTimestamps()protected abstract List<EncapsulatedCertificateTokenIdentifier>getEncapsulatedCertificateIdentifiers(SignatureAttribute unsignedAttribute)Returns a list ofEncapsulatedCertificateTokenIdentifiers obtained from the givenunsignedAttributeprotected abstract List<CRLBinary>getEncapsulatedCRLIdentifiers(SignatureAttribute unsignedAttribute)Returns a list ofCRLBinarys obtained from the givenunsignedAttributeprotected abstract List<OCSPResponseBinary>getEncapsulatedOCSPIdentifiers(SignatureAttribute unsignedAttribute)Returns a list ofOCSPResponseBinarys obtained from the givenunsignedAttributeprotected abstract List<TimestampedReference>getIndividualContentTimestampedReferences(SignatureAttribute signedAttribute)Returns a list ofTimestampedReferences for an "individual-data-objects-timestamp" NOTE: Used only in XAdESprotected abstract List<Digest>getRevocationRefCRLDigests(SignatureAttribute unsignedAttribute)Returns a list of CRL revocation refDigests from the givenunsignedAttributeprotected abstract List<Digest>getRevocationRefOCSPDigests(SignatureAttribute unsignedAttribute)Returns a list of OCSP revocation refDigests from the givenunsignedAttributeprotected List<TimestampedReference>getSignatureSignedDataReferences()Returns a list of allTimestampedReferences found into CMS SignedData of the signature NOTE: used only in ASiC-E CAdESprotected List<TimestampedReference>getSignatureTimestampReferences()Returns a list ofTimestampedReferencefor a "signature-timestamp" elementList<TimestampToken>getSignatureTimestamps()protected List<TimestampedReference>getSignedDataReferences(TimestampToken timestampToken)Returns a list ofTimestampedReferences for the giventimestampTokenfound into signed properties of the signature NOTE: used only in CAdES.protected abstract SignatureProperties<SignatureAttribute>getSignedSignatureProperties()Returns the 'signed-signature-properties' element of the signatureprotected List<TimestampedReference>getSigningCertificateTimestampReferences()Returns a list ofTimestampedReferences created from signing certificates of the signatureListCRLSourcegetTimestampCRLSources()Returns a mergedListCRLSourceof all embedded timestamp CRL sourcesprotected abstract TimestampDataBuildergetTimestampDataBuilder()Returns a relatedTimestampDataBuilderprotected List<TimestampedReference>getTimestampedCertificateRefs(SignatureAttribute unsignedAttribute)Returns a list ofTimestampedReferencecertificate refs found in the givenunsignedAttributeprotected List<TimestampedReference>getTimestampedCertificateValues(SignatureAttribute unsignedAttribute)protected List<TimestampedReference>getTimestampedRevocationRefs(SignatureAttribute unsignedAttribute)Returns a list ofTimestampedReferencerevocation refs found in the givenunsignedAttributeprotected List<TimestampedReference>getTimestampedRevocationValues(SignatureAttribute unsignedAttribute)ListOCSPSourcegetTimestampOCSPSources()Returns a mergedListOCSPSourceof all embedded timestamp OCSP sourcesList<TimestampToken>getTimestampsX1()List<TimestampToken>getTimestampsX2()protected List<TimestampedReference>getTimestampValidationData(SignatureAttribute unsignedAttribute)Returns a list ofTimestampedReferences encapsulated to the "timestamp-validation-data"unsignedAttributeprotected abstract SignatureProperties<SignatureAttribute>getUnsignedSignatureProperties()Returns the 'unsigned-signature-properties' element of the signatureprotected abstract booleanisAllDataObjectsTimestamp(SignatureAttribute signedAttribute)Determines if the givensignedAttributeis an instance of "data-objects-timestamp" element NOTE: Applicable only for XAdESprotected abstract booleanisArchiveTimestamp(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "archive-timestamp" elementprotected abstract booleanisAttributeCertificateRef(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "attribute-certificate-ref" elementprotected abstract booleanisAttributeRevocationRef(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "attribute-revocation-ref" elementprotected abstract booleanisCertificateValues(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "certificate-values" elementprotected abstract booleanisCompleteCertificateRef(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "complete-certificate-ref" elementprotected abstract booleanisCompleteRevocationRef(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "complete-revocation-ref" elementprotected abstract booleanisContentTimestamp(SignatureAttribute signedAttribute)Determines if the givensignedAttributeis an instance of "content-timestamp" element NOTE: Applicable only for CAdESprotected abstract booleanisIndividualDataObjectsTimestamp(SignatureAttribute signedAttribute)Determines if the givensignedAttributeis an instance of "individual-data-objects-timestamp" element NOTE: Applicable only for XAdESprotected abstract booleanisRefsOnlyTimestamp(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "refs-only-timestamp" elementprotected abstract booleanisRevocationValues(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "revocation-values" elementprotected abstract booleanisSigAndRefsTimestamp(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "sig-and-refs-timestamp" elementprotected abstract booleanisSignatureTimestamp(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "signature-timestamp" elementprotected abstract booleanisTimeStampValidationData(SignatureAttribute unsignedAttribute)Determines if the givenunsignedAttributeis an instance of "timestamp-validation-data" elementprotected abstract TimestampTokenmakeTimestampToken(SignatureAttribute signatureAttribute, TimestampType timestampType, List<TimestampedReference> references)Creates a timestamp token from the providedsignatureAttributeprotected voidmakeTimestampTokens()Populates all the lists by data found into the signatureprotected voidpopulateTimestampCertificateSource(List<CertificateToken> certificates)Addscertificatesto thetimestampCertificateSourceprotected voidvalidateTimestamps()Validates list of all timestamps present in the source
-
Field Details
-
signatureCertificateSource
Sources obtained from a signature object -
signatureCRLSource
-
signatureOCSPSource
-
signatureId
-
signatureScopes
-
certificatePool
-
crlSource
Revocation sources containing merged data from timestamps -
ocspSource
-
timestampCertificateSource
Local timestamp source to store certificate values found in timestamps
-
-
Constructor Details
-
AbstractTimestampSource
Default constructor- Parameters:
signature-AdvancedSignatureis being validated
-
-
Method Details
-
getContentTimestamps
- Specified by:
getContentTimestampsin interfaceSignatureTimestampSource
-
getSignatureTimestamps
- Specified by:
getSignatureTimestampsin interfaceSignatureTimestampSource
-
getTimestampsX1
- Specified by:
getTimestampsX1in interfaceSignatureTimestampSource
-
getTimestampsX2
- Specified by:
getTimestampsX2in interfaceSignatureTimestampSource
-
getArchiveTimestamps
- Specified by:
getArchiveTimestampsin interfaceSignatureTimestampSource
-
getDocumentTimestamps
- Specified by:
getDocumentTimestampsin interfaceSignatureTimestampSource
-
getAllTimestamps
- Specified by:
getAllTimestampsin interfaceSignatureTimestampSource
-
getTimestampCRLSources
Description copied from interface:SignatureTimestampSourceReturns a mergedListCRLSourceof all embedded timestamp CRL sources- Specified by:
getTimestampCRLSourcesin interfaceSignatureTimestampSource- Returns:
ListCRLSource
-
getTimestampOCSPSources
Description copied from interface:SignatureTimestampSourceReturns a mergedListOCSPSourceof all embedded timestamp OCSP sources- Specified by:
getTimestampOCSPSourcesin interfaceSignatureTimestampSource- Returns:
ListOCSPSource
-
createAndValidate
protected void createAndValidate()Creates and validates all timestamps Must be called only once -
addExternalTimestamp
Description copied from interface:SignatureTimestampSourceThis method allows to add an external timestamp. The given timestamp must be processed before.- Specified by:
addExternalTimestampin interfaceSignatureTimestampSource- Parameters:
timestamp- the timestamp token
-
makeTimestampTokens
protected void makeTimestampTokens()Populates all the lists by data found into the signature -
getSignedSignatureProperties
Returns the 'signed-signature-properties' element of the signature- Returns:
SignatureProperties
-
getUnsignedSignatureProperties
Returns the 'unsigned-signature-properties' element of the signature- Returns:
SignatureProperties
-
isContentTimestamp
Determines if the givensignedAttributeis an instance of "content-timestamp" element NOTE: Applicable only for CAdES- Parameters:
signedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Data Objects Timestamp, FALSE otherwise
-
isAllDataObjectsTimestamp
Determines if the givensignedAttributeis an instance of "data-objects-timestamp" element NOTE: Applicable only for XAdES- Parameters:
signedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Data Objects Timestamp, FALSE otherwise
-
isIndividualDataObjectsTimestamp
Determines if the givensignedAttributeis an instance of "individual-data-objects-timestamp" element NOTE: Applicable only for XAdES- Parameters:
signedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Data Objects Timestamp, FALSE otherwise
-
isSignatureTimestamp
Determines if the givenunsignedAttributeis an instance of "signature-timestamp" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Signature Timestamp, FALSE otherwise
-
isCompleteCertificateRef
Determines if the givenunsignedAttributeis an instance of "complete-certificate-ref" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Complete Certificate Ref, FALSE otherwise
-
isAttributeCertificateRef
Determines if the givenunsignedAttributeis an instance of "attribute-certificate-ref" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis an Attribute Certificate Ref, FALSE otherwise
-
isCompleteRevocationRef
Determines if the givenunsignedAttributeis an instance of "complete-revocation-ref" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Complete Revocation Ref, FALSE otherwise
-
isAttributeRevocationRef
Determines if the givenunsignedAttributeis an instance of "attribute-revocation-ref" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis an Attribute Revocation Ref, FALSE otherwise
-
isRefsOnlyTimestamp
Determines if the givenunsignedAttributeis an instance of "refs-only-timestamp" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Refs Only TimeStamp, FALSE otherwise
-
isSigAndRefsTimestamp
Determines if the givenunsignedAttributeis an instance of "sig-and-refs-timestamp" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Sig And Refs TimeStamp, FALSE otherwise
-
isCertificateValues
Determines if the givenunsignedAttributeis an instance of "certificate-values" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Certificate Values, FALSE otherwise
-
isRevocationValues
Determines if the givenunsignedAttributeis an instance of "revocation-values" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a Revocation Values, FALSE otherwise
-
isArchiveTimestamp
Determines if the givenunsignedAttributeis an instance of "archive-timestamp" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis an Archive TimeStamp, FALSE otherwise
-
isTimeStampValidationData
Determines if the givenunsignedAttributeis an instance of "timestamp-validation-data" element- Parameters:
unsignedAttribute-ISignatureAttributeto process- Returns:
- TRUE if the
unsignedAttributeis a TimeStamp Validation Data, FALSE otherwise
-
makeTimestampToken
protected abstract TimestampToken makeTimestampToken(SignatureAttribute signatureAttribute, TimestampType timestampType, List<TimestampedReference> references)Creates a timestamp token from the providedsignatureAttribute- Parameters:
signatureAttribute-ISignatureAttributeto create timestamp fromtimestampType- a targetTimestampTypereferences- list ofTimestampedReferences covered by the current timestamp- Returns:
TimestampToken
-
getAllContentTimestampReferences
Returns a list ofTimestampedReferences obtained from thesignatureScopes- Returns:
- list of
TimestampedReferences
-
getIndividualContentTimestampedReferences
protected abstract List<TimestampedReference> getIndividualContentTimestampedReferences(SignatureAttribute signedAttribute)Returns a list ofTimestampedReferences for an "individual-data-objects-timestamp" NOTE: Used only in XAdES- Parameters:
signedAttribute-AbstractTimestampSource- Returns:
- a list of
TimestampedReferences
-
getSignatureTimestampReferences
Returns a list ofTimestampedReferencefor a "signature-timestamp" element- Returns:
- list of
TimestampedReferences
-
getSigningCertificateTimestampReferences
Returns a list ofTimestampedReferences created from signing certificates of the signature- Returns:
- list of
TimestampedReferences
-
createReferencesForCertificates
protected List<TimestampedReference> createReferencesForCertificates(Collection<CertificateToken> certificates)Creates a list ofTimestampedReferences for the provided list ofcertificates- Parameters:
certificates- collection ofCertificateTokens- Returns:
- list of
TimestampedReferences
-
getTimestampedCertificateRefs
protected List<TimestampedReference> getTimestampedCertificateRefs(SignatureAttribute unsignedAttribute)Returns a list ofTimestampedReferencecertificate refs found in the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto find references from- Returns:
- list of
TimestampedReferences
-
getCertificateRefDigests
Returns a list ofDigests from the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get certRef Digests from- Returns:
- list of
Digests
-
getTimestampedRevocationRefs
protected List<TimestampedReference> getTimestampedRevocationRefs(SignatureAttribute unsignedAttribute)Returns a list ofTimestampedReferencerevocation refs found in the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto find references from- Returns:
- list of
TimestampedReferences
-
getRevocationRefCRLDigests
Returns a list of CRL revocation refDigests from the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get CRLRef Digests from- Returns:
- list of
Digests
-
getRevocationRefOCSPDigests
Returns a list of OCSP revocation refDigests from the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get OCSPRef Digests from- Returns:
- list of
Digests
-
getTimestampedCertificateValues
protected List<TimestampedReference> getTimestampedCertificateValues(SignatureAttribute unsignedAttribute) -
getEncapsulatedCertificateIdentifiers
protected abstract List<EncapsulatedCertificateTokenIdentifier> getEncapsulatedCertificateIdentifiers(SignatureAttribute unsignedAttribute)Returns a list ofEncapsulatedCertificateTokenIdentifiers obtained from the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get certificate identifiers from- Returns:
- list of
EncapsulatedCertificateTokenIdentifiers
-
getTimestampedRevocationValues
protected List<TimestampedReference> getTimestampedRevocationValues(SignatureAttribute unsignedAttribute) -
getEncapsulatedCRLIdentifiers
protected abstract List<CRLBinary> getEncapsulatedCRLIdentifiers(SignatureAttribute unsignedAttribute)Returns a list ofCRLBinarys obtained from the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get CRL identifiers from- Returns:
- list of
CRLBinarys
-
getEncapsulatedOCSPIdentifiers
protected abstract List<OCSPResponseBinary> getEncapsulatedOCSPIdentifiers(SignatureAttribute unsignedAttribute)Returns a list ofOCSPResponseBinarys obtained from the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get OCSP identifiers from- Returns:
- list of
OCSPResponseBinarys
-
getSignedDataReferences
Returns a list ofTimestampedReferences for the giventimestampTokenfound into signed properties of the signature NOTE: used only in CAdES. NeedstimestampTokento be initialized before- Parameters:
timestampToken-TimestampTokento get SignedData references for- Returns:
- list of
TimestampedReferences
-
getSignatureSignedDataReferences
Returns a list of allTimestampedReferences found into CMS SignedData of the signature NOTE: used only in ASiC-E CAdES- Returns:
- list of
TimestampedReferences
-
getTimestampValidationData
protected List<TimestampedReference> getTimestampValidationData(SignatureAttribute unsignedAttribute)Returns a list ofTimestampedReferences encapsulated to the "timestamp-validation-data"unsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get timestamped references from- Returns:
- list of
TimestampedReferences
-
addReference
protected void addReference(List<TimestampedReference> referenceList, TimestampedReference referenceToAdd)AddsreferenceToAddtoreferenceListwithout duplicates- Parameters:
referenceList- - list ofTimestampedReferences to be extendedreferenceToAdd- -TimestampedReferenceto be added
-
addReferences
protected void addReferences(List<TimestampedReference> referenceList, List<TimestampedReference> referencesToAdd)AddsreferencesToAddtoreferenceListwithout duplicates- Parameters:
referenceList- - list ofTimestampedReferences to be extendedreferencesToAdd- -TimestampedReferences to be added
-
addReferencesForPreviousTimestamps
protected void addReferencesForPreviousTimestamps(List<TimestampedReference> references, List<TimestampToken> timestampedTimestamps) -
addEncapsulatedValuesFromTimestamp
protected void addEncapsulatedValuesFromTimestamp(List<TimestampedReference> references, TimestampToken timestampedTimestamp)Adds to thereferenceslist all validation data embedded to thetimestampedTimestamp- Parameters:
references- list ofTimestampedReferences to extendtimestampedTimestamp-TimestampTokento extract embedded values from
-
getArchiveTimestampType
protected abstract ArchiveTimestampType getArchiveTimestampType(SignatureAttribute unsignedAttribute)ReturnsArchiveTimestampTypefor the givenunsignedAttribute- Parameters:
unsignedAttribute-AbstractTimestampSourceto get archive timestamp type for
-
validateTimestamps
protected void validateTimestamps()Validates list of all timestamps present in the source -
getTimestampDataBuilder
Returns a relatedTimestampDataBuilder- Returns:
TimestampDataBuilder
-
getCertificateMapWithinTimestamps
public Map<String,List<CertificateToken>> getCertificateMapWithinTimestamps(boolean skipLastArchiveTimestamp)Description copied from interface:SignatureTimestampSourceReturns a map between all found timestamps and their certificates- Specified by:
getCertificateMapWithinTimestampsin interfaceSignatureTimestampSource- Parameters:
skipLastArchiveTimestamp- in case if the last Archive Timestamp is not needed to be returned- Returns:
- a map between timestamp-id and list of related
CertificateTokens
-
getCertificates
Description copied from interface:SignatureTimestampSourceReturns a list of all found certificates in the timestamps- Specified by:
getCertificatesin interfaceSignatureTimestampSource- Returns:
- a list of
CertificateTokens
-
populateTimestampCertificateSource
Addscertificatesto thetimestampCertificateSource- Parameters:
certificates- list ofCertificateTokens
-