Package eu.europa.esig.dss.validation
Class SignedDocumentValidator
java.lang.Object
eu.europa.esig.dss.validation.SignedDocumentValidator
- All Implemented Interfaces:
DocumentValidator,ProcessExecutorProvider<DocumentProcessExecutor>
- Direct Known Subclasses:
AbstractASiCContainerValidator,AbstractJWSDocumentValidator,CMSDocumentValidator,DefaultEvidenceRecordValidator,DetachedTimestampValidator,PDFDocumentValidator,XMLDocumentValidator
Validates a 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
FieldsModifier and TypeFieldDescriptionprotected final DocumentAnalyzerThis class performs analysis of the document, tokens extraction as well as cryptographic validationprotected DocumentProcessExecutorThis variable can hold a specificDocumentProcessExecutor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSignedDocumentValidator(DocumentAnalyzer documentAnalyzer) The constructor with a nullsignatureScopeFinder -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThis method verifies whether the configuration of the current instance of a document validator is validstatic SignedDocumentValidatorfromDocument(DSSDocument dssDocument) This method guesses the document format and returns an appropriate document validator.Returns a default for a validator process executorRetrieves the detached evidence records found in the documentRetrieves the detached timestamps found in the documentfinal XmlDiagnosticDataThis method retrievesXmlDiagnosticDatacontaining all information relevant for the validation process, including the certificate and revocation tokens obtained from online resources, e.g.Returns the current instance ofDocumentAnalyzergetOriginalDocuments(AdvancedSignature advancedSignature) This method returns the signed document(s) without their signature(s)getOriginalDocuments(String signatureId) This method returns the signed document(s) without their signature(s)getSignatureById(String signatureId) Returns the signature with the given id.Deprecated.since DSS 6.1.Retrieves the signatures found in the document<T extends AdvancedSignature>
ValidationDataContainergetValidationData(Collection<T> signatures) Extracts a validation data for provided collection of signatures<T extends AdvancedSignature>
ValidationDataContainergetValidationData(Collection<T> signatures, Collection<TimestampToken> detachedTimestamps) Extracts a validation data for provided collection of signatures and/or timestampsprotected SignedDocumentDiagnosticDataBuilderThis method creates a format-specific implementation of theSignedDocumentDiagnosticDataBuilderbooleanisSupported(DSSDocument dssDocument) Checks if the document is supported by the current validatorprotected final ReportsprocessValidationPolicy(XmlDiagnosticData diagnosticData, ValidationPolicy validationPolicy) Executes the validation regarding the givenvalidationPolicyprotected DocumentProcessExecutorThis 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-S signatures.voidsetDefaultDigestAlgorithm(DigestAlgorithm digestAlgorithm) This method allows to change the Digest Algorithm that will be used for tokens' digest calculation Default :DigestAlgorithm.SHA256voidsetDetachedContents(List<DSSDocument> detachedContents) Sets theListofDSSDocumentcontaining the original contents to sign, for detached signature scenarios.voidsetDetachedEvidenceRecordDocuments(List<DSSDocument> detachedEvidenceRecordDocuments) Sets aListofDSSDocumentcontaining the evidence record documents covering the signature document.voidsetEnableEtsiValidationReport(boolean enableEtsiValidationReport) This method allows to specify if the ETSI Validation Report must be generated.voidsetIncludeSemantics(boolean include) This method allows to enable/disable the semantics inclusion in the reports (Indication / SubIndication meanings) Disabled by defaultvoidSets Locale for report messages generationvoidsetManifestFile(ManifestFile manifestFile) Sets a relatedManifestFileto the document to be validated.voidsetProcessExecutor(DocumentProcessExecutor processExecutor) This method provides the possibility to set the specificCustomProcessExecutorvoidsetSignaturePolicyProvider(SignaturePolicyProvider signaturePolicyProvider) This method allows to set a provider for Signature policiesvoidsetSigningCertificateSource(CertificateSource signingCertificateSource) Set a certificate source which allows to find the signing certificate by kid or certificate's digestvoidsetSkipValidationContextExecution(boolean skipValidationContextExecution) Deprecated.since DSS 6.1.voidsetTokenExtractionStrategy(TokenExtractionStrategy tokenExtractionStrategy) This method allows to set the token extraction strategy to follow in the diagnostic data generation.voidsetTokenIdentifierProvider(TokenIdentifierProvider tokenIdentifierProvider) Sets the TokenIdentifierProvidervoidsetValidationContextExecutor(ValidationContextExecutor validationContextExecutor) This method setsValidationContextExecutorfor validation of the preparedValidationContextDefault:eu.europa.esig.dss.validation.executor.context.DefaultValidationContextExecutor(performs basic validation of tokens, including certificate chain building and revocation data extraction, without processing of validity checks)voidsetValidationLevel(ValidationLevel validationLevel) This method allows to specify the validation level (Basic / Timestamp / Long Term / Archival).voidsetValidationTime(Date validationTime) Allows to define a custom validation timeValidates the document and all its signatures.validateDocument(DSSDocument policyDocument) Validates the document and all its signatures.validateDocument(ConstraintsParameters validationPolicyJaxb) Validates the document and all its signatures.validateDocument(ValidationPolicy validationPolicy) Validates the document and all its signatures.validateDocument(File policyFile) Validates the document and all its signatures.validateDocument(InputStream policyDataStream) Validates the document and all its signatures.validateDocument(String policyResourcePath) Validates the document and all its signatures.validateDocument(URL validationPolicyURL) Validates the document and all its signatures.
-
Field Details
-
documentAnalyzer
This class performs analysis of the document, tokens extraction as well as cryptographic validation -
processExecutor
This variable can hold a specificDocumentProcessExecutor
-
-
Constructor Details
-
SignedDocumentValidator
The constructor with a nullsignatureScopeFinder- Parameters:
documentAnalyzer-DocumentAnalyzer
-
-
Method Details
-
fromDocument
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
Checks if the document is supported by the current validator- Parameters:
dssDocument-DSSDocumentto check- Returns:
- TRUE if the document is supported, FALSE otherwise
-
getDocumentAnalyzer
Returns the current instance ofDocumentAnalyzer- Returns:
DocumentAnalyzer
-
setSigningCertificateSource
Description copied from interface:DocumentValidatorSet a certificate source which allows to find the signing certificate by kid or certificate's digest- Specified by:
setSigningCertificateSourcein interfaceDocumentValidator- Parameters:
signingCertificateSource- the certificate source
-
setCertificateVerifier
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-CertificateVerifier
-
setValidationContextExecutor
Description copied from interface:DocumentValidatorThis method setsValidationContextExecutorfor validation of the preparedValidationContextDefault:eu.europa.esig.dss.validation.executor.context.DefaultValidationContextExecutor(performs basic validation of tokens, including certificate chain building and revocation data extraction, without processing of validity checks)- Specified by:
setValidationContextExecutorin interfaceDocumentValidator- Parameters:
validationContextExecutor-ValidationContextExecutor
-
setTokenIdentifierProvider
Description copied from interface:DocumentValidatorSets the TokenIdentifierProvider- Specified by:
setTokenIdentifierProviderin interfaceDocumentValidator- Parameters:
tokenIdentifierProvider-TokenIdentifierProvider
-
setDetachedContents
Description copied from interface:DocumentValidatorSets theListofDSSDocumentcontaining the original contents to sign, for detached signature scenarios.- Specified by:
setDetachedContentsin interfaceDocumentValidator- Parameters:
detachedContents- theListofDSSDocumentto set
-
setDetachedEvidenceRecordDocuments
Description copied from interface:DocumentValidatorSets aListofDSSDocumentcontaining the evidence record documents covering the signature document.- Specified by:
setDetachedEvidenceRecordDocumentsin interfaceDocumentValidator- Parameters:
detachedEvidenceRecordDocuments- theListofDSSDocumentto set
-
setContainerContents
Description copied from interface:DocumentValidatorSets theListofDSSDocumentcontaining the original container content for ASiC-S signatures.- Specified by:
setContainerContentsin interfaceDocumentValidator- Parameters:
containerContents- theListofDSSDocumentto set
-
setManifestFile
Description copied from interface:DocumentValidatorSets a relatedManifestFileto the document to be validated.- Specified by:
setManifestFilein interfaceDocumentValidator- Parameters:
manifestFile- aManifestFileto set
-
setValidationTime
Allows to define a custom validation time- Specified by:
setValidationTimein interfaceDocumentValidator- Parameters:
validationTime-Date
-
setSkipValidationContextExecution
Deprecated.since DSS 6.1. Please use#setValidationContextExecutor(SkipValidationContextExecutor.INSTANCE)method insteadSets if the validation context execution shall be skipped (skips certificate chain building, revocation requests, ...)- Parameters:
skipValidationContextExecution- if the context validation shall be skipped
-
setSignaturePolicyProvider
Description copied from interface:DocumentValidatorThis method allows to set a provider for Signature policies- Specified by:
setSignaturePolicyProviderin interfaceDocumentValidator- Parameters:
signaturePolicyProvider-SignaturePolicyProvider
-
setDefaultDigestAlgorithm
Description copied from interface:DocumentValidatorThis method allows to change the Digest Algorithm that will be used for tokens' digest calculation Default :DigestAlgorithm.SHA256- Specified by:
setDefaultDigestAlgorithmin interfaceDocumentValidator- Parameters:
digestAlgorithm-DigestAlgorithmto use
-
setTokenExtractionStrategy
Description copied from interface:DocumentValidatorThis method allows to set the token extraction strategy to follow in the diagnostic data generation.- Specified by:
setTokenExtractionStrategyin interfaceDocumentValidator- Parameters:
tokenExtractionStrategy- theTokenExtractionStrategy
-
setIncludeSemantics
public void setIncludeSemantics(boolean include) Description copied from interface:DocumentValidatorThis method allows to enable/disable the semantics inclusion in the reports (Indication / SubIndication meanings) Disabled by default- Specified by:
setIncludeSemanticsin interfaceDocumentValidator- Parameters:
include- true to enable the inclusion of the semantics
-
setValidationLevel
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. Default : TRUE (the ETSI Validation report will be generated).- Specified by:
setEnableEtsiValidationReportin interfaceDocumentValidator- Parameters:
enableEtsiValidationReport- - TRUE if the report must be generated, FALSE otherwise
-
setProcessExecutor
Description copied from interface:ProcessExecutorProviderThis method provides the possibility to set the specificCustomProcessExecutor- Specified by:
setProcessExecutorin interfaceProcessExecutorProvider<DocumentProcessExecutor>- Parameters:
processExecutor-ProcessExecutor
-
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
-
getDefaultProcessExecutor
Description copied from interface:ProcessExecutorProviderReturns a default for a validator process executor- Specified by:
getDefaultProcessExecutorin interfaceProcessExecutorProvider<DocumentProcessExecutor>- Returns:
- Process Executor
-
setLocale
-
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
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- Parameters:
validationPolicyURL-URL- Returns:
Reports: diagnostic data, detailed report and simple report
-
validateDocument
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
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
Description copied from interface:DocumentValidatorValidates 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:
policyDocument- contains the validation policy (xml) asDSSDocument- Returns:
Reports: diagnostic data, detailed report and simple report
-
validateDocument
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
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
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
-
assertConfigurationValid
protected void assertConfigurationValid()This method verifies whether the configuration of the current instance of a document validator is valid -
getDiagnosticData
This method retrievesXmlDiagnosticDatacontaining all information relevant for the validation process, including the certificate and revocation tokens obtained from online resources, e.g. AIA, CRL, OCSP (when applicable).- Returns:
XmlDiagnosticData
-
initializeDiagnosticDataBuilder
This method creates a format-specific implementation of theSignedDocumentDiagnosticDataBuilder- Returns:
SignedDocumentDiagnosticDataBuilder
-
processValidationPolicy
protected final Reports processValidationPolicy(XmlDiagnosticData diagnosticData, ValidationPolicy validationPolicy) Executes the validation regarding the givenvalidationPolicy- Parameters:
diagnosticData-DiagnosticDatacontained a data to be validatedvalidationPolicy-ValidationPolicy- Returns:
- validation
Reports
-
getSignatures
Description copied from interface:DocumentValidatorRetrieves the signatures found in the document- Specified by:
getSignaturesin interfaceDocumentValidator- Returns:
- a list of AdvancedSignatures for validation purposes
-
getSignatureById
Returns the signature with the given id. Processes customTokenIdentifierProviderand counter signatures- Parameters:
signatureId-Stringid of a signature to be extracted- Returns:
AdvancedSignaturewith the given id if found, NULL otherwise
-
getDetachedTimestamps
Description copied from interface:DocumentValidatorRetrieves the detached timestamps found in the document- Specified by:
getDetachedTimestampsin interfaceDocumentValidator- Returns:
- a list of TimestampToken for validation purposes
-
getDetachedEvidenceRecords
Description copied from interface:DocumentValidatorRetrieves the detached evidence records found in the document- Specified by:
getDetachedEvidenceRecordsin interfaceDocumentValidator- Returns:
- a list of Evidence Records for validation purposes
-
getOriginalDocuments
Description copied from interface:DocumentValidatorThis method returns the signed document(s) without their signature(s)- Specified by:
getOriginalDocumentsin interfaceDocumentValidator- Parameters:
signatureId- the DSS ID of the signature to extract original signer data for- Returns:
- list of
DSSDocuments
-
getOriginalDocuments
Description copied from interface:DocumentValidatorThis method returns the signed document(s) without their signature(s)- Specified by:
getOriginalDocumentsin interfaceDocumentValidator- Parameters:
advancedSignature-AdvancedSignatureto find signer documents for- Returns:
- list of
DSSDocuments
-
getValidationData
public <T extends AdvancedSignature> ValidationDataContainer getValidationData(Collection<T> signatures) Description copied from interface:DocumentValidatorExtracts a validation data for provided collection of signatures- Specified by:
getValidationDatain interfaceDocumentValidator- Type Parameters:
T-AdvancedSignatureimplementation- Parameters:
signatures- a collection ofAdvancedSignatures- Returns:
ValidationDataContainer
-
getValidationData
public <T extends AdvancedSignature> ValidationDataContainer getValidationData(Collection<T> signatures, Collection<TimestampToken> detachedTimestamps) Description copied from interface:DocumentValidatorExtracts a validation data for provided collection of signatures and/or timestamps- Specified by:
getValidationDatain interfaceDocumentValidator- Type Parameters:
T-AdvancedSignatureimplementation- Parameters:
signatures- a collection ofAdvancedSignaturesdetachedTimestamps- a collection of detachedTimestampTokens- Returns:
ValidationDataContainer
-
getSignaturePolicyValidatorLoader
Deprecated.since DSS 6.1. Please use#getDocumentAnalyzer#getSignaturePolicyValidatorLoadermethod insteadReturns an instance of a corresponding to the formatSignaturePolicyValidatorLoader- Returns:
SignaturePolicyValidatorLoader
-