Package eu.europa.esig.dss.validation
Class SignedDocumentValidator
- java.lang.Object
-
- eu.europa.esig.dss.validation.SignedDocumentValidator
-
- All Implemented Interfaces:
DocumentValidator,ProcessExecutorProvider<SignatureProcessExecutor>
- Direct Known Subclasses:
AbstractASiCContainerValidator,CMSDocumentValidator,PDFDocumentValidator,XMLDocumentValidator
public abstract class SignedDocumentValidator extends Object implements DocumentValidator, ProcessExecutorProvider<SignatureProcessExecutor>
Validate the signed document. The content of the document is determined automatically. It can be: XML, CAdES(p7m), PDF or ASiC(zip). SignatureScopeFinder can be set using the appropriate setter (ex. setCadesSignatureScopeFinder). By default, this class will use the default SignatureScopeFinder as defined by eu.europa.esig.dss.validation.scope.SignatureScopeFinderFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected CertificateVerifiercertificateVerifierThe reference to the certificate verifier.protected List<DSSDocument>containerContentsIn case of an ASiC signature thisListof container documents.protected List<DSSDocument>detachedContentsIn case of a detached signature thisListcontains the signed documents.protected DSSDocumentdocumentThe document to be validated (with the signature(s))protected List<ManifestFile>manifestFilesList of all foundManifestFilesprotected SignatureProcessExecutorprocessExecutorThis variable can hold a specificSignatureProcessExecutorprotected CertificateTokenprovidedSigningCertificateTokenprotected SignaturePolicyProvidersignaturePolicyProviderprotected SignatureScopeFindersignatureScopeFinderprotected CertificatePoolvalidationCertPoolThis is the pool of certificates used in the validation process.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSignedDocumentValidator(SignatureScopeFinder signatureScopeFinder)
-
Method Summary
Modifier and Type Method Description voiddefineSigningCertificate(CertificateToken token)This method allows to define the signing certificate.protected voidensureSignaturePolicyDetectorInitialized()static SignedDocumentValidatorfromDocument(DSSDocument dssDocument)This method guesses the document format and returns an appropriate document validator.protected ContainerInfogetContainerInfo()This method allows to retrieve the container information (ASiC Container)abstract booleanisSupported(DSSDocument dssDocument)List<AdvancedSignature>prepareSignatureValidationContext(ValidationContext validationContext)Prepares and fillsvalidationContextfor the signature validationList<AdvancedSignature>processSignaturesValidation(ValidationContext validationContext, List<AdvancedSignature> allSignatureList, boolean structuralValidation)This method process the signature validation on the givenallSignatureListprotected ReportsprocessValidationPolicy(XmlDiagnosticData diagnosticData, ValidationPolicy validationPolicy)SignatureProcessExecutorprovideProcessExecutorInstance()This method returns the process executor.voidsetCertificateVerifier(CertificateVerifier certificateVerifier)To carry out the validation process of the signature(s) some external sources of certificates and of revocation data can be needed.voidsetContainerContents(List<DSSDocument> containerContents)Sets theListofDSSDocumentcontaining the original container content for ASiC signatures.voidsetDetachedContents(List<DSSDocument> detachedContents)Sets theListofDSSDocumentcontaining the original contents to sign, for detached signature scenarios.voidsetEnableEtsiValidationReport(boolean enableEtsiValidationReport)This method allows to specify if the ETSI Validation Report must be generated.voidsetManifestFiles(List<ManifestFile> manifestFiles)Sets theListofManifestFiles found in the signature file.voidsetProcessExecutor(SignatureProcessExecutor processExecutor)This method provides the possibility to set the specificCustomProcessExecutorvoidsetSignaturePolicyProvider(SignaturePolicyProvider signaturePolicyProvider)This method allows to set a provider for Signature policiesvoidsetValidationLevel(ValidationLevel validationLevel)This method allows to specify the validation level (Basic / Timestamp / Long Term / Archival).ReportsvalidateDocument()Validates the document and all its signatures.ReportsvalidateDocument(ConstraintsParameters validationPolicyJaxb)Validates the document and all its signatures.ReportsvalidateDocument(ValidationPolicy validationPolicy)Validates the document and all its signatures.ReportsvalidateDocument(File policyFile)Validates the document and all its signatures.ReportsvalidateDocument(InputStream policyDataStream)Validates the document and all its signatures.ReportsvalidateDocument(String policyResourcePath)Validates the document and all its signatures.ReportsvalidateDocument(URL validationPolicyURL)Validates the document and all its signatures.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface eu.europa.esig.dss.validation.DocumentValidator
getOriginalDocuments, getOriginalDocuments, getSignatures
-
-
-
-
Field Detail
-
processExecutor
protected SignatureProcessExecutor processExecutor
This variable can hold a specificSignatureProcessExecutor
-
validationCertPool
protected CertificatePool validationCertPool
This is the pool of certificates used in the validation process. The pools present in the certificate verifier are merged and added to this pool.
-
document
protected DSSDocument document
The document to be validated (with the signature(s))
-
detachedContents
protected List<DSSDocument> detachedContents
In case of a detached signature thisListcontains the signed documents.
-
containerContents
protected List<DSSDocument> containerContents
In case of an ASiC signature thisListof container documents.
-
manifestFiles
protected List<ManifestFile> manifestFiles
List of all foundManifestFiles
-
providedSigningCertificateToken
protected CertificateToken providedSigningCertificateToken
-
certificateVerifier
protected CertificateVerifier certificateVerifier
The reference to the certificate verifier. The current DSS implementation proposesCommonCertificateVerifier. This verifier encapsulates the references to different sources used in the signature validation process.
-
signatureScopeFinder
protected final SignatureScopeFinder signatureScopeFinder
-
signaturePolicyProvider
protected SignaturePolicyProvider signaturePolicyProvider
-
-
Constructor Detail
-
SignedDocumentValidator
protected SignedDocumentValidator(SignatureScopeFinder signatureScopeFinder)
-
-
Method Detail
-
fromDocument
public static SignedDocumentValidator fromDocument(DSSDocument dssDocument)
This method guesses the document format and returns an appropriate document validator.- Parameters:
dssDocument- The instance ofDSSDocumentto validate- Returns:
- returns the specific instance of SignedDocumentValidator in terms of the document type
-
isSupported
public abstract boolean isSupported(DSSDocument dssDocument)
-
defineSigningCertificate
public void defineSigningCertificate(CertificateToken token)
Description copied from interface:DocumentValidatorThis method allows to define the signing certificate. It is useful in the case of non AdES signatures.- Specified by:
defineSigningCertificatein interfaceDocumentValidator
-
setCertificateVerifier
public void setCertificateVerifier(CertificateVerifier certificateVerifier)
To carry out the validation process of the signature(s) some external sources of certificates and of revocation data can be needed. The certificate verifier is used to pass these values. Note that once this setter is called any change in the content of theCommonTrustedCertificateSourceor in adjunct certificate source is not taken into account.- Specified by:
setCertificateVerifierin interfaceDocumentValidator- Parameters:
certificateVerifier-
-
setDetachedContents
public void setDetachedContents(List<DSSDocument> detachedContents)
Description copied from interface:DocumentValidatorSets theListofDSSDocumentcontaining the original contents to sign, for detached signature scenarios.- Specified by:
setDetachedContentsin interfaceDocumentValidator- Parameters:
detachedContents- theListofDSSDocumentto set
-
setContainerContents
public void setContainerContents(List<DSSDocument> containerContents)
Description copied from interface:DocumentValidatorSets theListofDSSDocumentcontaining the original container content for ASiC signatures.- Specified by:
setContainerContentsin interfaceDocumentValidator- Parameters:
containerContents- theListofDSSDocumentto set
-
setManifestFiles
public void setManifestFiles(List<ManifestFile> manifestFiles)
Description copied from interface:DocumentValidatorSets theListofManifestFiles found in the signature file.- Specified by:
setManifestFilesin interfaceDocumentValidator- Parameters:
manifestFiles- theListofManifestFileto set
-
setValidationLevel
public void setValidationLevel(ValidationLevel validationLevel)
Description copied from interface:DocumentValidatorThis method allows to specify the validation level (Basic / Timestamp / Long Term / Archival). By default, the selected validation is ARCHIVAL- Specified by:
setValidationLevelin interfaceDocumentValidator- Parameters:
validationLevel-ValidationLevel
-
setEnableEtsiValidationReport
public void setEnableEtsiValidationReport(boolean enableEtsiValidationReport)
Description copied from interface:DocumentValidatorThis method allows to specify if the ETSI Validation Report must be generated. By default the value if TRUE (the ETSI Validation report will be generated).- Specified by:
setEnableEtsiValidationReportin interfaceDocumentValidator- Parameters:
enableEtsiValidationReport- - TRUE if the report must be generated, FALSE otherwise
-
validateDocument
public Reports validateDocument()
Description copied from interface:DocumentValidatorValidates the document and all its signatures. The default constraint file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Returns:
Reports: diagnostic data, detailed report and simple report
-
validateDocument
public Reports validateDocument(URL validationPolicyURL)
Description copied from interface:DocumentValidatorValidates the document and all its signatures. If the validation policy URL is set then the policy constraints are retrieved from this location. If null or empty the default file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Returns:
Reports: diagnostic data, detailed report and simple report
-
validateDocument
public Reports validateDocument(String policyResourcePath)
Description copied from interface:DocumentValidatorValidates the document and all its signatures. The policyResourcePath specifies the constraint file. If null or empty the default file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Parameters:
policyResourcePath- is located against the classpath (getClass().getResourceAsStream), and NOT the filesystem- Returns:
Reports: diagnostic data, detailed report and simple report
-
validateDocument
public Reports validateDocument(File policyFile)
Description copied from interface:DocumentValidatorValidates the document and all its signatures. TheFileparameter specifies the constraint file. If null or empty the default file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Parameters:
policyFile- contains the validation policy (xml) asFile- Returns:
Reports: diagnostic data, detailed report and simple report
-
validateDocument
public Reports validateDocument(InputStream policyDataStream)
Validates the document and all its signatures. The policyDataStream contains the constraint file. If null or empty the default file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Parameters:
policyDataStream- theInputStreamwith the validation policy- Returns:
- the validation reports
-
validateDocument
public Reports validateDocument(ConstraintsParameters validationPolicyJaxb)
Validates the document and all its signatures. ThevalidationPolicyDomcontains the constraint file. If null or empty the default file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Parameters:
validationPolicyJaxb- theConstraintsParametersto use in the validation process- Returns:
- the validation reports
-
validateDocument
public Reports validateDocument(ValidationPolicy validationPolicy)
Validates the document and all its signatures. ThevalidationPolicyDomcontains the constraint file. If null or empty the default file is used.- Specified by:
validateDocumentin interfaceDocumentValidator- Parameters:
validationPolicy- theValidationPolicyto use in the validation process- Returns:
- the validation reports
-
prepareSignatureValidationContext
public List<AdvancedSignature> prepareSignatureValidationContext(ValidationContext validationContext)
Description copied from interface:DocumentValidatorPrepares and fillsvalidationContextfor the signature validation- Specified by:
prepareSignatureValidationContextin interfaceDocumentValidator- Parameters:
validationContext-ValidationContextto prepare- Returns:
- list of
AdvancedSignatures to be validated
-
processSignaturesValidation
public List<AdvancedSignature> processSignaturesValidation(ValidationContext validationContext, List<AdvancedSignature> allSignatureList, boolean structuralValidation)
Description copied from interface:DocumentValidatorThis method process the signature validation on the givenallSignatureList- Specified by:
processSignaturesValidationin interfaceDocumentValidator- Parameters:
validationContext- prepared and filledValidationContextallSignatureList- list ofAdvancedSignatures to be validatedstructuralValidation- specifies if structure of the signature must be validated- Returns:
- list of validated
AdvancedSignatures
-
getContainerInfo
protected ContainerInfo getContainerInfo()
This method allows to retrieve the container information (ASiC Container)- Returns:
- the container information
-
processValidationPolicy
protected Reports processValidationPolicy(XmlDiagnosticData diagnosticData, ValidationPolicy validationPolicy)
-
setSignaturePolicyProvider
public void setSignaturePolicyProvider(SignaturePolicyProvider signaturePolicyProvider)
Description copied from interface:DocumentValidatorThis method allows to set a provider for Signature policies- Specified by:
setSignaturePolicyProviderin interfaceDocumentValidator
-
ensureSignaturePolicyDetectorInitialized
protected void ensureSignaturePolicyDetectorInitialized()
-
setProcessExecutor
public void setProcessExecutor(SignatureProcessExecutor processExecutor)
Description copied from interface:ProcessExecutorProviderThis method provides the possibility to set the specificCustomProcessExecutor- Specified by:
setProcessExecutorin interfaceProcessExecutorProvider<SignatureProcessExecutor>
-
provideProcessExecutorInstance
public SignatureProcessExecutor provideProcessExecutorInstance()
This method returns the process executor. If the instance of this class is not yet instantiated then the new instance is created.- Returns:
SignatureProcessExecutor
-
-