Package eu.europa.esig.dss.validation
Class DefaultAdvancedSignature
java.lang.Object
eu.europa.esig.dss.validation.DefaultAdvancedSignature
- All Implemented Interfaces:
AdvancedSignature
,Serializable
- Direct Known Subclasses:
CAdESSignature
,XAdESSignature
public abstract class DefaultAdvancedSignature extends Object implements AdvancedSignature
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected List<DSSDocument>
detachedContents
In case of a detached signature this is the signed document.protected List<ManifestFile>
manifestFiles
In case of a ASiC-E signature this is the list of found manifest files.protected SignatureCertificateSource
offlineCertificateSource
protected CertificateToken
providedSigningCertificateToken
In the case of a non AdES signature the signing certificate is not mandatory within the signature and can be provided by the driving application.protected List<ReferenceValidation>
referenceValidations
This variable contains a list of reference validations (reference tag for XAdES or message-digest for CAdES)protected OfflineCRLSource
signatureCRLSource
protected SignatureCryptographicVerification
signatureCryptographicVerification
This variable contains the result of the signature mathematical validation.protected SignatureIdentifier
signatureIdentifier
protected OfflineOCSPSource
signatureOCSPSource
protected SignaturePolicy
signaturePolicy
protected TimestampSource
signatureTimestampSource
protected String
structureValidation
-
Constructor Summary
Constructors Constructor Description DefaultAdvancedSignature()
-
Method Summary
Modifier and Type Method Description void
addExternalTimestamp(TimestampToken timestamp)
This method allows to add an external timestamp.boolean
areAllSelfSignedCertificates()
Checks if all certificate chains present in the signature are self-signedprotected abstract SignatureIdentifier
buildSignatureIdentifier()
Build and definessignatureIdentifier
valueboolean
equals(Object obj)
void
findSignatureScope(SignatureScopeFinder signatureScopeFinder)
List<TimestampToken>
getAllTimestamps()
Returns a list of all timestamps found in the signatureList<TimestampToken>
getArchiveTimestamps()
Returns the archive TimestampsCandidatesForSigningCertificate
getCandidatesForSigningCertificate()
ETSI TS 101 733 V2.2.1 (2013-04) 5.6.3 Signature Verification Process ...the public key from the first certificate identified in the sequence of certificate identifiers from SigningCertificate shall be the key used to verify the digital signature.List<CertificateToken>
getCertificates()
Returns an unmodifiable list of all certificate tokens encapsulated in the signatureListCertificateSource
getCertificateSourcesExceptLastArchiveTimestamp()
ListCertificateSource
getCompleteCertificateSource()
Gets a ListCertificateSource representing a merged source fromsignatureCertificateSource
and all included to the signature timestamp objectsListRevocationSource
getCompleteCRLSource()
Gets a ListRevocationSource representing a merged source fromsignatureCRLSourse
and all included to the signature timestamp objectsListRevocationSource
getCompleteOCSPSource()
Gets a ListRevocationSource representing a merged source fromsignatureOCSPSourse
and all included to the signature timestamp objectsList<DSSDocument>
getContainerContents()
List<TimestampToken>
getContentTimestamps()
Returns the content timestampsList<DSSDocument>
getDetachedContents()
List<TimestampToken>
getDocumentTimestamps()
Returns a list of timestamps defined with the 'DocTimeStamp' type NOTE: applicable only for PAdESSignatureIdentifier
getDSSId()
This method returns theSignatureIdentifier
.String
getId()
This method returns the DSS unique signature id.List<DSSDocument>
getManifestedDocuments()
AdvancedSignature
getMasterSignature()
byte[]
getMessageDigestValue()
Returns a digest value incorporated in an attribute "message-digest" in CMS Signed DataPdfRevision
getPdfRevision()
Retrieves a PdfRevision (PAdES) related to the current signatureSignaturePolicy
getPolicyId()
Returns the Signature Policy OID from the signature.CertificateToken
getProvidedSigningCertificateToken()
SignatureCryptographicVerification
getSignatureCryptographicVerification()
String
getSignatureFilename()
This method returns the signature filename (useful for ASiC and multiple signature files)List<SignatureScope>
getSignatureScopes()
List<TimestampToken>
getSignatureTimestamps()
Returns the signature timestampsValidationContext
getSignatureValidationContext(CertificateVerifier certificateVerifier)
This method validates the signing certificate and all timestamps.Set<CertificateIdentifier>
getSignerInformationStoreInfos()
Returns a Set of CertificateIdentifier extracted from a SignerInformationStore of CMS Signed DataList<SignerRole>
getSignerRoles()
Returns the list of roles of the signer.CertificateToken
getSigningCertificateToken()
This method returns the signing certificate token or null if there is no valid signing certificate.String
getStructureValidationResult()
List<TimestampToken>
getTimestampsX1()
Returns the time-stamp which is placed on the digital signature (XAdES example: ds:SignatureValue element), the signature time-stamp(s) present in the AdES-T form, the certification path references and the revocation status references.List<TimestampToken>
getTimestampsX2()
Returns the time-stamp which is computed over the concatenation of CompleteCertificateRefs and CompleteRevocationRefs elements (XAdES example).int
hashCode()
boolean
hasLTAProfile()
boolean
hasLTProfile()
boolean
hasTProfile()
boolean
isCounterSignature()
Checks if the current signature is a counter signature (i.e. has a Master signature)boolean
isDocHashOnlyValidation()
Returns true if the validation of the signature has been performed only on Signer's Document Representation (SDR).boolean
isHashOnlyValidation()
Returns true if the validation of the signature has been performed only on Data To Be Signed Representation (DTBSR).void
prepareOfflineCertificateVerifier(CertificateVerifier certificateVerifier)
This method prepares an offline CertificateVerifier.void
prepareTimestamps(ValidationContext validationContext)
This method adds to theValidationContext
all timestamps to be validated.void
setContainerContents(List<DSSDocument> containerContents)
This method allows to set the container contents in the case of ASiC signature.void
setDetachedContents(List<DSSDocument> detachedContents)
This method allows to set the signed contents in the case of the detached signature.void
setManifestFiles(List<ManifestFile> manifestFiles)
This method allows to set the manifest files in the case of ASiC-E signature.void
setMasterSignature(AdvancedSignature masterSignature)
This setter allows to indicate the master signature.void
setProvidedSigningCertificateToken(CertificateToken certificateToken)
This method allows to provide a signing certificate to be used in the validation process.void
setSignatureFilename(String signatureFilename)
This method allows to set the signature filename (useful in case of ASiC)String
toString()
void
validateStructure()
This method allows the structure validation of the signature.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface eu.europa.esig.dss.validation.AdvancedSignature
checkSignatureIntegrity, checkSignaturePolicy, getCertificateSource, getCertifiedSignerRoles, getClaimedSignerRoles, getCommitmentTypeIndications, getContentHints, getContentIdentifier, getContentType, getCounterSignatures, getCRLSource, getDAIdentifier, getDataFoundUpToLevel, getDigestAlgorithm, getEncryptionAlgorithm, getMaskGenerationFunction, getMimeType, getOCSPSource, getReferenceValidations, getSignatureAlgorithm, getSignatureDigestReference, getSignatureForm, getSignatureLevels, getSignatureProductionPlace, getSignatureValue, getSignedAssertions, getSigningTime, getTimestampSource
-
Field Details
-
providedSigningCertificateToken
In the case of a non AdES signature the signing certificate is not mandatory within the signature and can be provided by the driving application. -
detachedContents
In case of a detached signature this is the signed document. -
manifestFiles
In case of a ASiC-E signature this is the list of found manifest files. -
referenceValidations
This variable contains a list of reference validations (reference tag for XAdES or message-digest for CAdES) -
signatureCryptographicVerification
This variable contains the result of the signature mathematical validation. It is initialised when the methodcheckSignatureIntegrity
is called. -
structureValidation
-
offlineCertificateSource
-
signatureCRLSource
-
signatureOCSPSource
-
signatureTimestampSource
-
signaturePolicy
-
signatureIdentifier
-
-
Constructor Details
-
DefaultAdvancedSignature
public DefaultAdvancedSignature()
-
-
Method Details
-
buildSignatureIdentifier
Build and definessignatureIdentifier
value -
getSignatureFilename
Description copied from interface:AdvancedSignature
This method returns the signature filename (useful for ASiC and multiple signature files)- Specified by:
getSignatureFilename
in interfaceAdvancedSignature
- Returns:
- the signature filename
-
setSignatureFilename
Description copied from interface:AdvancedSignature
This method allows to set the signature filename (useful in case of ASiC)- Specified by:
setSignatureFilename
in interfaceAdvancedSignature
-
getDetachedContents
- Specified by:
getDetachedContents
in interfaceAdvancedSignature
- Returns:
- in the case of the detached signature this is the
List
of signed contents.
-
setDetachedContents
Description copied from interface:AdvancedSignature
This method allows to set the signed contents in the case of the detached signature.- Specified by:
setDetachedContents
in interfaceAdvancedSignature
- Parameters:
detachedContents
-List
ofDSSDocument
representing the signed detached contents.
-
getContainerContents
- Specified by:
getContainerContents
in interfaceAdvancedSignature
- Returns:
- in case of ASiC signature returns a list of container documents
-
setContainerContents
Description copied from interface:AdvancedSignature
This method allows to set the container contents in the case of ASiC signature.- Specified by:
setContainerContents
in interfaceAdvancedSignature
- Parameters:
containerContents
-List
ofDSSDocument
representing the container contents.
-
setManifestFiles
Description copied from interface:AdvancedSignature
This method allows to set the manifest files in the case of ASiC-E signature.- Specified by:
setManifestFiles
in interfaceAdvancedSignature
- Parameters:
manifestFiles
-List
ofManifestFile
s
-
getDSSId
Description copied from interface:AdvancedSignature
This method returns theSignatureIdentifier
.- Specified by:
getDSSId
in interfaceAdvancedSignature
- Returns:
- unique
SignatureIdentifier
-
getId
Description copied from interface:AdvancedSignature
This method returns the DSS unique signature id. It allows to unambiguously identify each signature.- Specified by:
getId
in interfaceAdvancedSignature
- Returns:
- The signature unique Id
-
getManifestedDocuments
- Specified by:
getManifestedDocuments
in interfaceAdvancedSignature
- Returns:
- in case of ASiC-E signature returns a list of
DSSDocument
s contained in the related signature manifest
-
getCompleteCertificateSource
Description copied from interface:AdvancedSignature
Gets a ListCertificateSource representing a merged source fromsignatureCertificateSource
and all included to the signature timestamp objects- Specified by:
getCompleteCertificateSource
in interfaceAdvancedSignature
- Returns:
ListCertificateSource
-
getCertificateSourcesExceptLastArchiveTimestamp
-
getCompleteCRLSource
Description copied from interface:AdvancedSignature
Gets a ListRevocationSource representing a merged source fromsignatureCRLSourse
and all included to the signature timestamp objects- Specified by:
getCompleteCRLSource
in interfaceAdvancedSignature
- Returns:
ListRevocationSource
-
getCompleteOCSPSource
Description copied from interface:AdvancedSignature
Gets a ListRevocationSource representing a merged source fromsignatureOCSPSourse
and all included to the signature timestamp objects- Specified by:
getCompleteOCSPSource
in interfaceAdvancedSignature
- Returns:
ListRevocationSource
-
getCandidatesForSigningCertificate
ETSI TS 101 733 V2.2.1 (2013-04) 5.6.3 Signature Verification Process ...the public key from the first certificate identified in the sequence of certificate identifiers from SigningCertificate shall be the key used to verify the digital signature.- Specified by:
getCandidatesForSigningCertificate
in interfaceAdvancedSignature
- Returns:
-
prepareOfflineCertificateVerifier
This method prepares an offline CertificateVerifier. The instance is used to know if all required revocation data are present- Parameters:
certificateVerifier
- the configured CertificateVerifier with all external sources
-
getSignatureValidationContext
This method validates the signing certificate and all timestamps.- Returns:
- signature validation context containing all certificates and revocation data used during the validation process.
-
getCertificates
Returns an unmodifiable list of all certificate tokens encapsulated in the signature- Specified by:
getCertificates
in interfaceAdvancedSignature
- Returns:
- a list of certificate contained within the signature
- See Also:
AdvancedSignature.getCertificates()
-
setMasterSignature
Description copied from interface:AdvancedSignature
This setter allows to indicate the master signature. It means that this is a countersignature.- Specified by:
setMasterSignature
in interfaceAdvancedSignature
- Parameters:
masterSignature
-AdvancedSignature
-
getMasterSignature
- Specified by:
getMasterSignature
in interfaceAdvancedSignature
- Returns:
AdvancedSignature
-
isCounterSignature
public boolean isCounterSignature()Description copied from interface:AdvancedSignature
Checks if the current signature is a counter signature (i.e. has a Master signature)- Specified by:
isCounterSignature
in interfaceAdvancedSignature
- Returns:
- TRUE if it is a counter signature, FALSE otherwise
-
getSignatureCryptographicVerification
- Specified by:
getSignatureCryptographicVerification
in interfaceAdvancedSignature
- Returns:
- SignatureCryptographicVerification with all the information collected during the validation process.
-
getSignerRoles
Description copied from interface:AdvancedSignature
Returns the list of roles of the signer.- Specified by:
getSignerRoles
in interfaceAdvancedSignature
- Returns:
- list of the
SignerRole
s
-
getProvidedSigningCertificateToken
- Specified by:
getProvidedSigningCertificateToken
in interfaceAdvancedSignature
- Returns:
- This method returns the provided signing certificate or
null
-
setProvidedSigningCertificateToken
Description copied from interface:AdvancedSignature
This method allows to provide a signing certificate to be used in the validation process. It can happen in the case of a non-AdES signature without the signing certificate within the signature.- Specified by:
setProvidedSigningCertificateToken
in interfaceAdvancedSignature
- Parameters:
certificateToken
-CertificateToken
representing the signing certificate token.
-
getSigningCertificateToken
Description copied from interface:AdvancedSignature
This method returns the signing certificate token or null if there is no valid signing certificate. Note that to determinate the signing certificate the signature must be validated: the methodcheckSignatureIntegrity
must be called.- Specified by:
getSigningCertificateToken
in interfaceAdvancedSignature
- Returns:
-
prepareTimestamps
This method adds to theValidationContext
all timestamps to be validated.- Specified by:
prepareTimestamps
in interfaceAdvancedSignature
- Parameters:
validationContext
-ValidationContext
to which the timestamps must be added
-
validateStructure
public void validateStructure()Description copied from interface:AdvancedSignature
This method allows the structure validation of the signature.- Specified by:
validateStructure
in interfaceAdvancedSignature
-
getStructureValidationResult
- Specified by:
getStructureValidationResult
in interfaceAdvancedSignature
-
getPolicyId
Description copied from interface:AdvancedSignature
Returns the Signature Policy OID from the signature.- Specified by:
getPolicyId
in interfaceAdvancedSignature
- Returns:
SignaturePolicy
-
findSignatureScope
- Specified by:
findSignatureScope
in interfaceAdvancedSignature
-
getSignatureScopes
- Specified by:
getSignatureScopes
in interfaceAdvancedSignature
-
getContentTimestamps
Description copied from interface:AdvancedSignature
Returns the content timestamps- Specified by:
getContentTimestamps
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
-
getSignatureTimestamps
Description copied from interface:AdvancedSignature
Returns the signature timestamps- Specified by:
getSignatureTimestamps
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
-
getTimestampsX1
Description copied from interface:AdvancedSignature
Returns the time-stamp which is placed on the digital signature (XAdES example: ds:SignatureValue element), the signature time-stamp(s) present in the AdES-T form, the certification path references and the revocation status references.- Specified by:
getTimestampsX1
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
-
getTimestampsX2
Description copied from interface:AdvancedSignature
Returns the time-stamp which is computed over the concatenation of CompleteCertificateRefs and CompleteRevocationRefs elements (XAdES example).- Specified by:
getTimestampsX2
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
-
getArchiveTimestamps
Description copied from interface:AdvancedSignature
Returns the archive Timestamps- Specified by:
getArchiveTimestamps
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
s
-
getDocumentTimestamps
Description copied from interface:AdvancedSignature
Returns a list of timestamps defined with the 'DocTimeStamp' type NOTE: applicable only for PAdES- Specified by:
getDocumentTimestamps
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
s
-
getAllTimestamps
Description copied from interface:AdvancedSignature
Returns a list of all timestamps found in the signature- Specified by:
getAllTimestamps
in interfaceAdvancedSignature
- Returns:
List
ofTimestampToken
s
-
addExternalTimestamp
Description copied from interface:AdvancedSignature
This method allows to add an external timestamp. The given timestamp must be processed before.- Specified by:
addExternalTimestamp
in interfaceAdvancedSignature
- Parameters:
timestamp
- the timestamp token
-
hasTProfile
public boolean hasTProfile() -
hasLTProfile
public boolean hasLTProfile() -
areAllSelfSignedCertificates
public boolean areAllSelfSignedCertificates()Description copied from interface:AdvancedSignature
Checks if all certificate chains present in the signature are self-signed- Specified by:
areAllSelfSignedCertificates
in interfaceAdvancedSignature
- Returns:
- TRUE if all certificates are self-signed, false otherwise
-
hasLTAProfile
public boolean hasLTAProfile() -
isDocHashOnlyValidation
public boolean isDocHashOnlyValidation()Description copied from interface:AdvancedSignature
Returns true if the validation of the signature has been performed only on Signer's Document Representation (SDR). (An SDR typically is built on a cryptographic hash of the Signer's Document)- Specified by:
isDocHashOnlyValidation
in interfaceAdvancedSignature
- Returns:
- true of it is DocHashOnly validation, false otherwise
-
isHashOnlyValidation
public boolean isHashOnlyValidation()Description copied from interface:AdvancedSignature
Returns true if the validation of the signature has been performed only on Data To Be Signed Representation (DTBSR). EN 319 102-1 v1.1.1 (4.2.8 Data to be signed representation (DTBSR)): The DTBS preparation component shall take the DTBSF and hash it according to the hash algorithm specified in the cryptographic suite. The result of this process is the DTBSR, which is then used to create the signature. NOTE: In order for the produced hash to be representative of the DTBSF, the hashing function has the property that it is computationally infeasible to find collisions for the expected signature lifetime. Should the hash function become weak in the future, additional security measures, such as applying time-stamp tokens, can be taken.- Specified by:
isHashOnlyValidation
in interfaceAdvancedSignature
- Returns:
- true of it is HashOnly validation, false otherwise
-
getMessageDigestValue
public byte[] getMessageDigestValue()Description copied from interface:AdvancedSignature
Returns a digest value incorporated in an attribute "message-digest" in CMS Signed Data- Specified by:
getMessageDigestValue
in interfaceAdvancedSignature
- Returns:
- a byte array representing a signed content digest value
-
getSignerInformationStoreInfos
Description copied from interface:AdvancedSignature
Returns a Set of CertificateIdentifier extracted from a SignerInformationStore of CMS Signed Data- Specified by:
getSignerInformationStoreInfos
in interfaceAdvancedSignature
- Returns:
- a Set of
CertificateIdentifier
s
-
getPdfRevision
Description copied from interface:AdvancedSignature
Retrieves a PdfRevision (PAdES) related to the current signature- Specified by:
getPdfRevision
in interfaceAdvancedSignature
- Returns:
PdfRevision
-
equals
-
hashCode
public int hashCode() -
toString
-