Class SignedDocumentValidator
- All Implemented Interfaces:
DocumentValidator
,ProcessExecutorProvider<DocumentProcessExecutor>
- Direct Known Subclasses:
AbstractASiCContainerValidator
,AbstractJWSDocumentValidator
,CMSDocumentValidator
,DefaultEvidenceRecordValidator
,DetachedTimestampValidator
,PDFDocumentValidator
,XMLDocumentValidator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DocumentAnalyzer
This class performs analysis of the document, tokens extraction as well as cryptographic validationprotected DocumentProcessExecutor
This variable can hold a specificDocumentProcessExecutor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SignedDocumentValidator
(DocumentAnalyzer documentAnalyzer) The constructor with a nullsignatureScopeFinder
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
This method verifies whether the configuration of the current instance of a document validator is validstatic SignedDocumentValidator
fromDocument
(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 XmlDiagnosticData
This method retrievesXmlDiagnosticData
containing all information relevant for the validation process, including the certificate and revocation tokens obtained from online resources, e.g.Returns the current instance ofDocumentAnalyzer
getOriginalDocuments
(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.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 SignedDocumentDiagnosticDataBuilder
This method creates a format-specific implementation of theSignedDocumentDiagnosticDataBuilder
boolean
isSupported
(DSSDocument dssDocument) Checks if the document is supported by the current validatorprotected ValidationPolicy
loadValidationPolicy
(DSSDocument policyDocument, DSSDocument cryptographicSuiteDocument) This method loads a validation policy from thepolicyDocument
and acryptographicSuiteDocument
.protected final Reports
processValidationPolicy
(XmlDiagnosticData diagnosticData, ValidationPolicy validationPolicy) Executes the validation regarding the givenvalidationPolicy
protected DocumentProcessExecutor
This method returns the process executor.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.void
setContainerContents
(List<DSSDocument> containerContents) Sets theList
ofDSSDocument
containing the original container content for ASiC-S signatures.void
setDefaultDigestAlgorithm
(DigestAlgorithm digestAlgorithm) This method allows to change the Digest Algorithm that will be used for tokens' digest calculation Default :DigestAlgorithm.SHA256
void
setDetachedContents
(List<DSSDocument> detachedContents) Sets theList
ofDSSDocument
containing the original contents to sign, for detached signature scenarios.void
setDetachedEvidenceRecordDocuments
(List<DSSDocument> detachedEvidenceRecordDocuments) Sets aList
ofDSSDocument
containing the evidence record documents covering the signature document.void
setEnableEtsiValidationReport
(boolean enableEtsiValidationReport) This method allows to specify if the ETSI Validation Report must be generated.void
setIncludeSemantics
(boolean include) This method allows to enable/disable the semantics inclusion in the reports (Indication / SubIndication meanings) Disabled by defaultvoid
Sets Locale for report messages generationvoid
setManifestFile
(ManifestFile manifestFile) Sets a relatedManifestFile
to the document to be validated.void
setProcessExecutor
(DocumentProcessExecutor processExecutor) This method provides the possibility to set the specificCustomProcessExecutor
void
setSignaturePolicyProvider
(SignaturePolicyProvider signaturePolicyProvider) This method allows to set a provider for Signature policiesvoid
setSigningCertificateSource
(CertificateSource signingCertificateSource) Set a certificate source which allows to find the signing certificate by kid or certificate's digestvoid
setTokenExtractionStrategy
(TokenExtractionStrategy tokenExtractionStrategy) This method allows to set the token extraction strategy to follow in the diagnostic data generation.void
setTokenIdentifierProvider
(TokenIdentifierProvider tokenIdentifierProvider) Sets the TokenIdentifierProvidervoid
setValidationContextExecutor
(ValidationContextExecutor validationContextExecutor) This method setsValidationContextExecutor
for validation of the preparedValidationContext
Default: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)void
setValidationLevel
(ValidationLevel validationLevel) This method allows to specify the validation level (Basic / Timestamp / Long Term / Archival).void
setValidationTime
(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
(DSSDocument policyDocument, DSSDocument cryptographicSuiteDocument) Validates the document and all its signatures, using the provided validation policy.validateDocument
(ValidationPolicy validationPolicy) Validates the document and all its signatures.validateDocument
(File policyFile) Validates the document and all its signatures.validateDocument
(File policyFile, File cryptographicSuiteFile) Validates the document and all its signatures, using the provided validation policy.validateDocument
(InputStream policyDataStream) Validates the document and all its signatures.validateDocument
(InputStream policyDataStream, InputStream cryptographicSuiteStream) Validates the document and all its signatures, using the provided validation policy.validateDocument
(String policyResourcePath) Validates the document and all its signatures.validateDocument
(String policyResourcePath, String cryptographicSuitePath) Validates the document and all its signatures, using the provided validation policy.validateDocument
(URL validationPolicyURL) Validates the document and all its signatures.validateDocument
(URL validationPolicyURL, URL cryptographicSuiteURL) Validates the document and all its signatures, using the provided validation policy.
-
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 ofDSSDocument
to 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
-DSSDocument
to check- Returns:
- TRUE if the document is supported, FALSE otherwise
-
getDocumentAnalyzer
Returns the current instance ofDocumentAnalyzer
- Returns:
DocumentAnalyzer
-
setSigningCertificateSource
Description copied from interface:DocumentValidator
Set a certificate source which allows to find the signing certificate by kid or certificate's digest- Specified by:
setSigningCertificateSource
in 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 theCommonTrustedCertificateSource
or in adjunct certificate source is not taken into account.- Specified by:
setCertificateVerifier
in interfaceDocumentValidator
- Parameters:
certificateVerifier
-CertificateVerifier
-
setValidationContextExecutor
Description copied from interface:DocumentValidator
This method setsValidationContextExecutor
for validation of the preparedValidationContext
Default: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:
setValidationContextExecutor
in interfaceDocumentValidator
- Parameters:
validationContextExecutor
-ValidationContextExecutor
-
setTokenIdentifierProvider
Description copied from interface:DocumentValidator
Sets the TokenIdentifierProvider- Specified by:
setTokenIdentifierProvider
in interfaceDocumentValidator
- Parameters:
tokenIdentifierProvider
-TokenIdentifierProvider
-
setDetachedContents
Description copied from interface:DocumentValidator
Sets theList
ofDSSDocument
containing the original contents to sign, for detached signature scenarios.- Specified by:
setDetachedContents
in interfaceDocumentValidator
- Parameters:
detachedContents
- theList
ofDSSDocument
to set
-
setDetachedEvidenceRecordDocuments
Description copied from interface:DocumentValidator
Sets aList
ofDSSDocument
containing the evidence record documents covering the signature document.- Specified by:
setDetachedEvidenceRecordDocuments
in interfaceDocumentValidator
- Parameters:
detachedEvidenceRecordDocuments
- theList
ofDSSDocument
to set
-
setContainerContents
Description copied from interface:DocumentValidator
Sets theList
ofDSSDocument
containing the original container content for ASiC-S signatures.- Specified by:
setContainerContents
in interfaceDocumentValidator
- Parameters:
containerContents
- theList
ofDSSDocument
to set
-
setManifestFile
Description copied from interface:DocumentValidator
Sets a relatedManifestFile
to the document to be validated.- Specified by:
setManifestFile
in interfaceDocumentValidator
- Parameters:
manifestFile
- aManifestFile
to set
-
setValidationTime
Allows to define a custom validation time- Specified by:
setValidationTime
in interfaceDocumentValidator
- Parameters:
validationTime
-Date
-
setSignaturePolicyProvider
Description copied from interface:DocumentValidator
This method allows to set a provider for Signature policies- Specified by:
setSignaturePolicyProvider
in interfaceDocumentValidator
- Parameters:
signaturePolicyProvider
-SignaturePolicyProvider
-
setDefaultDigestAlgorithm
Description copied from interface:DocumentValidator
This method allows to change the Digest Algorithm that will be used for tokens' digest calculation Default :DigestAlgorithm.SHA256
- Specified by:
setDefaultDigestAlgorithm
in interfaceDocumentValidator
- Parameters:
digestAlgorithm
-DigestAlgorithm
to use
-
setTokenExtractionStrategy
Description copied from interface:DocumentValidator
This method allows to set the token extraction strategy to follow in the diagnostic data generation.- Specified by:
setTokenExtractionStrategy
in interfaceDocumentValidator
- Parameters:
tokenExtractionStrategy
- theTokenExtractionStrategy
-
setIncludeSemantics
public void setIncludeSemantics(boolean include) Description copied from interface:DocumentValidator
This method allows to enable/disable the semantics inclusion in the reports (Indication / SubIndication meanings) Disabled by default- Specified by:
setIncludeSemantics
in interfaceDocumentValidator
- Parameters:
include
- true to enable the inclusion of the semantics
-
setValidationLevel
Description copied from interface:DocumentValidator
This method allows to specify the validation level (Basic / Timestamp / Long Term / Archival). By default, the selected validation is ARCHIVAL- Specified by:
setValidationLevel
in interfaceDocumentValidator
- Parameters:
validationLevel
-ValidationLevel
-
setEnableEtsiValidationReport
public void setEnableEtsiValidationReport(boolean enableEtsiValidationReport) Description copied from interface:DocumentValidator
This method allows to specify if the ETSI Validation Report must be generated. Default : TRUE (the ETSI Validation report will be generated).- Specified by:
setEnableEtsiValidationReport
in interfaceDocumentValidator
- Parameters:
enableEtsiValidationReport
- - TRUE if the report must be generated, FALSE otherwise
-
setProcessExecutor
Description copied from interface:ProcessExecutorProvider
This method provides the possibility to set the specificCustomProcessExecutor
- Specified by:
setProcessExecutor
in 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:ProcessExecutorProvider
Returns a default for a validator process executor- Specified by:
getDefaultProcessExecutor
in interfaceProcessExecutorProvider<DocumentProcessExecutor>
- Returns:
- Process Executor
-
setLocale
Sets Locale for report messages generation- Parameters:
locale
-Locale
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures. The default constraint file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures. If the validation policy URL is set then the policy constraints are retrieved from this location. If null the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
validationPolicyURL
-URL
- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures. The policyResourcePath specifies the constraint file. If null or empty the default file is used.- Specified by:
validateDocument
in 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:DocumentValidator
Validates the document and all its signatures. TheFile
parameter specifies the constraint file. If null or file does not exist the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
policyFile
- contains the validation policy (xml) asFile
- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures. The policyDataStream contains the constraint file. If null the default file is used.- Specified by:
validateDocument
in 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:
validateDocument
in interfaceDocumentValidator
- Parameters:
policyDataStream
- theInputStream
with the validation policy- Returns:
- the validation reports
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures, using the provided validation policy. If cryptographic suite is set, the constraints from validation policy will be overwritten by the constraints retrieved from the cryptographic suite. When set, the cryptographic suite constraints are applied with the default behavior, using FAIL level. For a customizable cryptographic suite and its applicability context, please useeu.europa.esig.dss.validation.policy.ValidationPolicyLoader
.The format of validation policy should correspond to the DSS XML Validation policy (please include 'dss-policy-jaxb' module in your classpath), unless a custom validation policy has been implemented. The format of cryptographic suite should correspond to XML or JSON schema as defined in ETSI TS 119 322 (please include 'dss-policy-crypto-xml' or 'dss-policy-crypto-json' to the classpath), unless a custom cryptographic suite has been implemented.
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:
validateDocument
in interfaceDocumentValidator
- Parameters:
validationPolicyURL
-URL
to the used validation policy filecryptographicSuiteURL
-URL
to the used cryptographic suite file- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures, using the provided validation policy. If cryptographic suite is set, the constraints from validation policy will be overwritten by the constraints retrieved from the cryptographic suite. When set, the cryptographic suite constraints are applied with the default behavior, using FAIL level. For a customizable cryptographic suite and its applicability context, please useeu.europa.esig.dss.validation.policy.ValidationPolicyLoader
.The format of validation policy should correspond to the DSS XML Validation policy (please include 'dss-policy-jaxb' module in your classpath), unless a custom validation policy has been implemented. The format of cryptographic suite should correspond to XML or JSON schema as defined in ETSI TS 119 322 (please include 'dss-policy-crypto-xml' or 'dss-policy-crypto-json' to the classpath), unless a custom cryptographic suite has been implemented.
The
policyResourcePath
andcryptographicSuitePath
specify the constraint file. If null or empty the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
policyResourcePath
-String
path to the validation policy file, located against the classpath (getClass().getResourceAsStream), and NOT the filesystemcryptographicSuitePath
-String
path to the cryptographic suite file, located against the classpath (getClass().getResourceAsStream), and NOT the filesystem- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures, using the provided validation policy. If cryptographic suite is set, the constraints from validation policy will be overwritten by the constraints retrieved from the cryptographic suite. When set, the cryptographic suite constraints are applied with the default behavior, using FAIL level. For a customizable cryptographic suite and its applicability context, please useeu.europa.esig.dss.validation.policy.ValidationPolicyLoader
.The format of validation policy should correspond to the DSS XML Validation policy (please include 'dss-policy-jaxb' module in your classpath), unless a custom validation policy has been implemented. The format of cryptographic suite should correspond to XML or JSON schema as defined in ETSI TS 119 322 (please include 'dss-policy-crypto-xml' or 'dss-policy-crypto-json' to the classpath), unless a custom cryptographic suite has been implemented.
The
File
parameters specify the constraint file. If null the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
policyFile
-File
containing the validation policycryptographicSuiteFile
-File
containing the cryptographic suite- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures, using the provided validation policy. If cryptographic suite is set, the constraints from validation policy will be overwritten by the constraints retrieved from the cryptographic suite. When set, the cryptographic suite constraints are applied with the default behavior, using FAIL level. For a customizable cryptographic suite and its applicability context, please useeu.europa.esig.dss.validation.policy.ValidationPolicyLoader
.The format of validation policy should correspond to the DSS XML Validation policy (please include 'dss-policy-jaxb' module in your classpath), unless a custom validation policy has been implemented. The format of cryptographic suite should correspond to XML or JSON schema as defined in ETSI TS 119 322 (please include 'dss-policy-crypto-xml' or 'dss-policy-crypto-json' to the classpath), unless a custom cryptographic suite has been implemented.
The
DSSDocument
parameters contains the constraint files. If null the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
policyDocument
-DSSDocument
containing the validation policycryptographicSuiteDocument
-DSSDocument
containing the cryptographic suite- Returns:
Reports
: diagnostic data, detailed report and simple report
-
loadValidationPolicy
protected ValidationPolicy loadValidationPolicy(DSSDocument policyDocument, DSSDocument cryptographicSuiteDocument) This method loads a validation policy from thepolicyDocument
and acryptographicSuiteDocument
. When a document is not provided, a default policy or cryptographic suite is used, respectively.- Parameters:
policyDocument
-DSSDocument
containing the validation policy documentcryptographicSuiteDocument
-DSSDocument
containing the cryptographic suite document- Returns:
ValidationPolicy
-
validateDocument
Description copied from interface:DocumentValidator
Validates the document and all its signatures, using the provided validation policy. If cryptographic suite is set, the constraints from validation policy will be overwritten by the constraints retrieved from the cryptographic suite. When set, the cryptographic suite constraints are applied with the default behavior, using FAIL level. For a customizable cryptographic suite and its applicability context, please useeu.europa.esig.dss.validation.policy.ValidationPolicyLoader
.The format of validation policy should correspond to the DSS XML Validation policy (please include 'dss-policy-jaxb' module in your classpath), unless a custom validation policy has been implemented. The format of cryptographic suite should correspond to XML or JSON schema as defined in ETSI TS 119 322 (please include 'dss-policy-crypto-xml' or 'dss-policy-crypto-json' to the classpath), unless a custom cryptographic suite has been implemented.
The
InputStream
parameters contains the constraint files. If null the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
policyDataStream
-InputStream
containing the validation policycryptographicSuiteStream
-InputStream
containing the cryptographic suite- Returns:
Reports
: diagnostic data, detailed report and simple report
-
validateDocument
Validates the document and all its signatures. ThevalidationPolicyDom
contains the constraint file. If null or empty the default file is used.- Specified by:
validateDocument
in interfaceDocumentValidator
- Parameters:
validationPolicy
- theValidationPolicy
to 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 retrievesXmlDiagnosticData
containing 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
-DiagnosticData
contained a data to be validatedvalidationPolicy
-ValidationPolicy
- Returns:
- validation
Reports
-
getSignatures
Description copied from interface:DocumentValidator
Retrieves the signatures found in the document- Specified by:
getSignatures
in interfaceDocumentValidator
- Returns:
- a list of AdvancedSignatures for validation purposes
-
getSignatureById
Returns the signature with the given id. Processes customTokenIdentifierProvider
and counter signatures- Parameters:
signatureId
-String
id of a signature to be extracted- Returns:
AdvancedSignature
with the given id if found, NULL otherwise
-
getDetachedTimestamps
Description copied from interface:DocumentValidator
Retrieves the detached timestamps found in the document- Specified by:
getDetachedTimestamps
in interfaceDocumentValidator
- Returns:
- a list of TimestampToken for validation purposes
-
getDetachedEvidenceRecords
Description copied from interface:DocumentValidator
Retrieves the detached evidence records found in the document- Specified by:
getDetachedEvidenceRecords
in interfaceDocumentValidator
- Returns:
- a list of Evidence Records for validation purposes
-
getOriginalDocuments
Description copied from interface:DocumentValidator
This method returns the signed document(s) without their signature(s)- Specified by:
getOriginalDocuments
in interfaceDocumentValidator
- Parameters:
signatureId
- the DSS ID of the signature to extract original signer data for- Returns:
- list of
DSSDocument
s
-
getOriginalDocuments
Description copied from interface:DocumentValidator
This method returns the signed document(s) without their signature(s)- Specified by:
getOriginalDocuments
in interfaceDocumentValidator
- Parameters:
advancedSignature
-AdvancedSignature
to find signer documents for- Returns:
- list of
DSSDocument
s
-
getValidationData
public <T extends AdvancedSignature> ValidationDataContainer getValidationData(Collection<T> signatures) Description copied from interface:DocumentValidator
Extracts a validation data for provided collection of signatures- Specified by:
getValidationData
in interfaceDocumentValidator
- Type Parameters:
T
-AdvancedSignature
implementation- Parameters:
signatures
- a collection ofAdvancedSignature
s- Returns:
ValidationDataContainer
-
getValidationData
public <T extends AdvancedSignature> ValidationDataContainer getValidationData(Collection<T> signatures, Collection<TimestampToken> detachedTimestamps) Description copied from interface:DocumentValidator
Extracts a validation data for provided collection of signatures and/or timestamps- Specified by:
getValidationData
in interfaceDocumentValidator
- Type Parameters:
T
-AdvancedSignature
implementation- Parameters:
signatures
- a collection ofAdvancedSignature
sdetachedTimestamps
- a collection of detachedTimestampToken
s- Returns:
ValidationDataContainer
-