Package eu.europa.esig.dss.validation
Class SignatureValidationContext
java.lang.Object
eu.europa.esig.dss.validation.SignatureValidationContext
- All Implemented Interfaces:
ValidationContext
public class SignatureValidationContext extends Object implements ValidationContext
During the validation of a signature, the software retrieves different X509 artifacts like Certificate, CRL and OCSP
Response. The SignatureValidationContext is a "cache" for
one validation request that contains every object retrieved so far.
-
Field Summary
Fields Modifier and Type Field Description protected Date
currentTime
This is the time at what the validation is carried out.protected CertificatePool
validationCertificatePool
The certificate pool which encapsulates all certificates used during the validation process and extracted from all used sources -
Constructor Summary
Constructors Constructor Description SignatureValidationContext()
This constructor is used during the signature creation process.SignatureValidationContext(CertificatePool validationCertificatePool)
This constructor is used when a signature need to be validated. -
Method Summary
Modifier and Type Method Description void
addCertificateTokenForVerification(CertificateToken certificateToken)
Adds a new certificate token to the list of tokens to verify.void
addRevocationTokensForVerification(List<RevocationToken> revocationTokens)
Adds a list of new revocation tokens to the list of tokens to verify.void
addTimestampTokenForVerification(TimestampToken timestampToken)
Adds a new timestamp token to the list of tokens to verify.Map<CertificateToken,Set<CertificateSourceType>>
getCertificateSourceTypes()
Returns a map ofCertificateSourceType
byCertificateToken
which contains the sources where the certificate was found.Date
getCurrentTime()
Set<CertificateToken>
getProcessedCertificates()
Returns a read only list of all certificates used in the process of the validation of all signatures from the given document.Set<RevocationToken>
getProcessedRevocations()
Returns a read only list of all revocations used in the process of the validation of all signatures from the given document.Set<TimestampToken>
getProcessedTimestamps()
Returns a read only list of all timestamps processed during the validation of all signatures from the given document.void
initialize(CertificateVerifier certificateVerifier)
boolean
isAllCertificateValid()
This method allows to verify if all processed certificates are not revokedboolean
isAllPOECoveredByRevocationData()
This method allows to verify if all POE (timestamp tokens) are covered by a revocation databoolean
isAllRequiredRevocationDataPresent()
This method allows to verify if all processed certificates have a revocation databoolean
isAllTimestampValid()
This method allows to verify if all processed timestamps are valid and intactboolean
isAtLeastOneRevocationDataPresentAfterBestSignatureTime(CertificateToken signingCertificate)
This method allows to verify if there is at least one revocation data present after the earliest available timestamp token producing timevoid
setCurrentTime(Date currentTime)
This function sets the validation time.void
validate()
Carries out the validation process in recursive manner for not yet checked tokens.
-
Field Details
-
validationCertificatePool
The certificate pool which encapsulates all certificates used during the validation process and extracted from all used sources -
currentTime
This is the time at what the validation is carried out. It is used only for test purpose.
-
-
Constructor Details
-
SignatureValidationContext
public SignatureValidationContext()This constructor is used during the signature creation process. The certificate pool is created within initialize method. -
SignatureValidationContext
This constructor is used when a signature need to be validated.- Parameters:
validationCertificatePool
- The pool of certificates used during the validation process
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceValidationContext
- Parameters:
certificateVerifier
- The certificates verifier (eg: using the TSL as list of trusted certificates).
-
getCurrentTime
- Specified by:
getCurrentTime
in interfaceValidationContext
-
setCurrentTime
Description copied from interface:ValidationContext
This function sets the validation time.- Specified by:
setCurrentTime
in interfaceValidationContext
- Parameters:
currentTime
- the currentDate
-
addRevocationTokensForVerification
Description copied from interface:ValidationContext
Adds a list of new revocation tokens to the list of tokens to verify. If the revocation token has already been added then it is ignored.- Specified by:
addRevocationTokensForVerification
in interfaceValidationContext
- Parameters:
revocationTokens
- a list ofRevocationToken
revocation tokens to verify
-
addCertificateTokenForVerification
Description copied from interface:ValidationContext
Adds a new certificate token to the list of tokens to verify. If the certificate token has already been added then it is ignored.- Specified by:
addCertificateTokenForVerification
in interfaceValidationContext
- Parameters:
certificateToken
-CertificateToken
certificate token to verify
-
addTimestampTokenForVerification
Description copied from interface:ValidationContext
Adds a new timestamp token to the list of tokens to verify. If the timestamp token has already been added then it is ignored.- Specified by:
addTimestampTokenForVerification
in interfaceValidationContext
- Parameters:
timestampToken
-TimestampToken
timestamp token to verify
-
validate
Description copied from interface:ValidationContext
Carries out the validation process in recursive manner for not yet checked tokens.- Specified by:
validate
in interfaceValidationContext
- Throws:
DSSException
- if an error occurred
-
isAllRequiredRevocationDataPresent
public boolean isAllRequiredRevocationDataPresent()Description copied from interface:ValidationContext
This method allows to verify if all processed certificates have a revocation data- Specified by:
isAllRequiredRevocationDataPresent
in interfaceValidationContext
- Returns:
- true if at least one revocation data is present for each certificate
-
isAllPOECoveredByRevocationData
public boolean isAllPOECoveredByRevocationData()Description copied from interface:ValidationContext
This method allows to verify if all POE (timestamp tokens) are covered by a revocation data- Specified by:
isAllPOECoveredByRevocationData
in interfaceValidationContext
- Returns:
- true if all POE have at least one revocation data issued after the POE creation
-
isAllTimestampValid
public boolean isAllTimestampValid()Description copied from interface:ValidationContext
This method allows to verify if all processed timestamps are valid and intact- Specified by:
isAllTimestampValid
in interfaceValidationContext
- Returns:
- true if all processed timestamps are valid
-
isAllCertificateValid
public boolean isAllCertificateValid()Description copied from interface:ValidationContext
This method allows to verify if all processed certificates are not revoked- Specified by:
isAllCertificateValid
in interfaceValidationContext
- Returns:
- true if all processed certificates are still valid
-
isAtLeastOneRevocationDataPresentAfterBestSignatureTime
public boolean isAtLeastOneRevocationDataPresentAfterBestSignatureTime(CertificateToken signingCertificate)Description copied from interface:ValidationContext
This method allows to verify if there is at least one revocation data present after the earliest available timestamp token producing time- Specified by:
isAtLeastOneRevocationDataPresentAfterBestSignatureTime
in interfaceValidationContext
- Parameters:
signingCertificate
-CertificateToken
signing certificate of the signature to be checked- Returns:
- true if there is at least one revocation data issued after the earliest timestamp time
-
getProcessedCertificates
Description copied from interface:ValidationContext
Returns a read only list of all certificates used in the process of the validation of all signatures from the given document. This list includes the certificate to check, certification chain certificates, OCSP response certificate...- Specified by:
getProcessedCertificates
in interfaceValidationContext
- Returns:
- The list of CertificateToken(s)
-
getCertificateSourceTypes
Description copied from interface:ValidationContext
Returns a map ofCertificateSourceType
byCertificateToken
which contains the sources where the certificate was found.- Specified by:
getCertificateSourceTypes
in interfaceValidationContext
- Returns:
- a map of CertificateSourceType by CertificateToken
-
getProcessedRevocations
Description copied from interface:ValidationContext
Returns a read only list of all revocations used in the process of the validation of all signatures from the given document.- Specified by:
getProcessedRevocations
in interfaceValidationContext
- Returns:
- The list of CertificateToken(s)
-
getProcessedTimestamps
Description copied from interface:ValidationContext
Returns a read only list of all timestamps processed during the validation of all signatures from the given document.- Specified by:
getProcessedTimestamps
in interfaceValidationContext
- Returns:
- The list of CertificateToken(s)
-