Package eu.europa.esig.dss.validation
Class SignatureValidationContext
java.lang.Object
eu.europa.esig.dss.validation.SignatureValidationContext
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionprotected Date
This is the time at what the validation is carried out. -
Constructor Summary
ConstructorDescriptionDefault constructor instantiating object with null or empty values and current time -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCertificateTokenForVerification
(CertificateToken certificateToken) Adds a new certificate token to the list of tokens to verify.void
addDocumentCertificateSource
(CertificateSource certificateSource) Adds an extracted certificate source to the used list of sourcesvoid
addDocumentCertificateSource
(ListCertificateSource listCertificateSource) Adds a list certificate source to the used list of sourcesvoid
addDocumentCRLSource
(OfflineRevocationSource<CRL> crlSource) Adds an extracted CRL source to the used list of sourcesvoid
addDocumentCRLSource
(ListRevocationSource<CRL> crlSource) Adds a list CRL source to the used list of sourcesvoid
addDocumentOCSPSource
(OfflineRevocationSource<OCSP> ocspSource) Adds an extracted OCSP source to the used list of sourcesvoid
addDocumentOCSPSource
(ListRevocationSource<OCSP> ocspSource) Adds a listd OCSP source to the used list of sourcesvoid
addRevocationTokenForVerification
(RevocationToken<?> revocationToken) Adds a new revocation token to the list of tokens to verify.void
addSignatureForVerification
(AdvancedSignature signature) Adds a new signature to collect the information to verify.void
addTimestampTokenForVerification
(TimestampToken timestampToken) Adds a new timestamp token to the list of tokens to verify.boolean
Deprecated.boolean
This method allows to verify if all POE (timestamp tokens) are covered by a revocation data Additionally, an alert can be handledCertificateVerifier.setAlertOnUncoveredPOE(eu.europa.esig.dss.alert.StatusAlert)
boolean
This method allows to verify if all processed certificates have a revocation data Additionally, an alert can be handledCertificateVerifier.setAlertOnMissingRevocationData(eu.europa.esig.dss.alert.StatusAlert)
boolean
This method allows to verify if all processed timestamps are valid and intact.boolean
This method allows to verify if there is at least one revocation data present after the earliest available timestamp token producing time Additionally, an alert can be handledCertificateVerifier.setAlertOnNoRevocationAfterBestSignatureTime(eu.europa.esig.dss.alert.StatusAlert)
boolean
checkCertificateNotRevoked
(CertificateToken certificateToken) This method allows to verify if the certificate is not revoked Additionally, an alert can be handledCertificateVerifier.setAlertOnRevokedCertificate(eu.europa.esig.dss.alert.StatusAlert)
boolean
checkCertificatesNotRevoked
(AdvancedSignature signature) This method allows to verify if signature certificates are not revoked Additionally, an alert can be handledCertificateVerifier.setAlertOnRevokedCertificate(eu.europa.esig.dss.alert.StatusAlert)
boolean
checkSignatureNotExpired
(AdvancedSignature signature) This method verifies if the signing certificate has not been expired yet or has a still valid timestamp Additionally, an alert can be handledCertificateVerifier.setAlertOnExpiredSignature(eu.europa.esig.dss.alert.StatusAlert)
Returns a list of allCertificateSource
s used during the validation process.Gets the current validation time.Returns a list of allCertificateSource
s extracted from a validating document (signature(s), timestamp(s))Returns a list of all CRLOfflineRevocationSource
s extracted from a validating documentReturns a list of all OCSPOfflineRevocationSource
s extracted from a validating documentReturns a read only list of all certificates used in the process of the validation of all signatures from the given document.Returns a read only list of all revocations used in the process of the validation of all signatures from the given document.Returns a read only list of all timestamps processed during the validation of all signatures from the given document.getValidationData
(AdvancedSignature signature) Returns a validation data for the given signature's certificate chaingetValidationData
(TimestampToken timestampToken) Returns a validation data for the given timestampToken's certificate chainvoid
initialize
(CertificateVerifier certificateVerifier) This method initializes theValidationContext
by retrieving the relevant data fromcertificateVerifier
protected boolean
isTimestampValid
(TimestampToken timestampToken) This method verifies whether atimestampToken
is valid and can be used as a valid POE for covered objectsvoid
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
-
currentTime
This is the time at what the validation is carried out. It is used only for test purpose.
-
-
Constructor Details
-
SignatureValidationContext
public SignatureValidationContext()Default constructor instantiating object with null or empty values and current time
-
-
Method Details
-
initialize
Description copied from interface:ValidationContext
This method initializes theValidationContext
by retrieving the relevant data fromcertificateVerifier
- Specified by:
initialize
in interfaceValidationContext
- Parameters:
certificateVerifier
- The certificate verifier (eg: using the TSL as list of trusted certificates).
-
addSignatureForVerification
Description copied from interface:ValidationContext
Adds a new signature to collect the information to verify.- Specified by:
addSignatureForVerification
in interfaceValidationContext
- Parameters:
signature
-AdvancedSignature
to extract data to be verified
-
addDocumentCertificateSource
Description copied from interface:ValidationContext
Adds an extracted certificate source to the used list of sources- Specified by:
addDocumentCertificateSource
in interfaceValidationContext
- Parameters:
certificateSource
-CertificateSource
-
addDocumentCertificateSource
Description copied from interface:ValidationContext
Adds a list certificate source to the used list of sources- Specified by:
addDocumentCertificateSource
in interfaceValidationContext
- Parameters:
listCertificateSource
-ListCertificateSource
-
addDocumentCRLSource
Description copied from interface:ValidationContext
Adds an extracted CRL source to the used list of sources- Specified by:
addDocumentCRLSource
in interfaceValidationContext
- Parameters:
crlSource
-OfflineRevocationSource
for CRL
-
addDocumentCRLSource
Description copied from interface:ValidationContext
Adds a list CRL source to the used list of sources- Specified by:
addDocumentCRLSource
in interfaceValidationContext
- Parameters:
crlSource
-ListRevocationSource
for CRL
-
addDocumentOCSPSource
Description copied from interface:ValidationContext
Adds an extracted OCSP source to the used list of sources- Specified by:
addDocumentOCSPSource
in interfaceValidationContext
- Parameters:
ocspSource
-OfflineRevocationSource
for OCSP
-
addDocumentOCSPSource
Description copied from interface:ValidationContext
Adds a listd OCSP source to the used list of sources- Specified by:
addDocumentOCSPSource
in interfaceValidationContext
- Parameters:
ocspSource
-ListRevocationSource
for OCSP
-
getCurrentTime
Description copied from interface:ValidationContext
Gets the current validation time.- Specified by:
getCurrentTime
in interfaceValidationContext
- Returns:
Date
-
setCurrentTime
Description copied from interface:ValidationContext
This function sets the validation time.- Specified by:
setCurrentTime
in interfaceValidationContext
- Parameters:
currentTime
- the currentDate
-
getAllCertificateSources
Description copied from interface:ValidationContext
Returns a list of allCertificateSource
s used during the validation process. It is represented by sources extracted from the provided document (e.g. signatures, timestamps) as well as the sources obtained during the validation process (e.g. AIA, OCSP).- Specified by:
getAllCertificateSources
in interfaceValidationContext
- Returns:
ListCertificateSource
-
getDocumentCertificateSource
Description copied from interface:ValidationContext
Returns a list of allCertificateSource
s extracted from a validating document (signature(s), timestamp(s))- Specified by:
getDocumentCertificateSource
in interfaceValidationContext
- Returns:
ListCertificateSource
-
getDocumentCRLSource
Description copied from interface:ValidationContext
Returns a list of all CRLOfflineRevocationSource
s extracted from a validating document- Specified by:
getDocumentCRLSource
in interfaceValidationContext
- Returns:
ListRevocationSource
-
getDocumentOCSPSource
Description copied from interface:ValidationContext
Returns a list of all OCSPOfflineRevocationSource
s extracted from a validating document- Specified by:
getDocumentOCSPSource
in interfaceValidationContext
- Returns:
ListRevocationSource
-
addRevocationTokenForVerification
Description copied from interface:ValidationContext
Adds a new revocation token to the list of tokens to verify. If the revocation token has already been added then it is ignored.- Specified by:
addRevocationTokenForVerification
in interfaceValidationContext
- Parameters:
revocationToken
- an instance 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
-
isTimestampValid
This method verifies whether atimestampToken
is valid and can be used as a valid POE for covered objects- Parameters:
timestampToken
-TimestampToken
to be checked- Returns:
- TRUE if the timestamp is valid, FALSE otherwise
-
validate
public void validate()Description copied from interface:ValidationContext
Carries out the validation process in recursive manner for not yet checked tokens.- Specified by:
validate
in interfaceValidationContext
-
checkAllRequiredRevocationDataPresent
public boolean checkAllRequiredRevocationDataPresent()Description copied from interface:ValidationContext
This method allows to verify if all processed certificates have a revocation data Additionally, an alert can be handledCertificateVerifier.setAlertOnMissingRevocationData(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkAllRequiredRevocationDataPresent
in interfaceValidationContext
- Returns:
- true if all needed revocation data are present
-
checkAllPOECoveredByRevocationData
public boolean checkAllPOECoveredByRevocationData()Description copied from interface:ValidationContext
This method allows to verify if all POE (timestamp tokens) are covered by a revocation data Additionally, an alert can be handledCertificateVerifier.setAlertOnUncoveredPOE(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkAllPOECoveredByRevocationData
in interfaceValidationContext
- Returns:
- true if all timestamps are covered by a usable revocation data
-
checkAllTimestampsValid
public boolean checkAllTimestampsValid()Description copied from interface:ValidationContext
This method allows to verify if all processed timestamps are valid and intact. Additionally, an alert can be handledCertificateVerifier.setAlertOnInvalidTimestamp(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkAllTimestampsValid
in interfaceValidationContext
- Returns:
- true if all timestamps are valid
-
checkAllCertificatesValid
Deprecated.Description copied from interface:ValidationContext
This method allows to verify if all processed certificates are not revoked Additionally, an alert can be handledCertificateVerifier.setAlertOnRevokedCertificate(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkAllCertificatesValid
in interfaceValidationContext
- Returns:
- true if all certificates are valid
-
checkCertificateNotRevoked
Description copied from interface:ValidationContext
This method allows to verify if the certificate is not revoked Additionally, an alert can be handledCertificateVerifier.setAlertOnRevokedCertificate(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkCertificateNotRevoked
in interfaceValidationContext
- Parameters:
certificateToken
-CertificateToken
certificate to be checked- Returns:
- true if all certificates are valid
-
checkCertificatesNotRevoked
Description copied from interface:ValidationContext
This method allows to verify if signature certificates are not revoked Additionally, an alert can be handledCertificateVerifier.setAlertOnRevokedCertificate(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkCertificatesNotRevoked
in interfaceValidationContext
- Parameters:
signature
-AdvancedSignature
signature to be checked- Returns:
- true if all certificates are valid
-
checkAtLeastOneRevocationDataPresentAfterBestSignatureTime
public boolean checkAtLeastOneRevocationDataPresentAfterBestSignatureTime(AdvancedSignature signature) 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 Additionally, an alert can be handledCertificateVerifier.setAlertOnNoRevocationAfterBestSignatureTime(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkAtLeastOneRevocationDataPresentAfterBestSignatureTime
in interfaceValidationContext
- Parameters:
signature
-AdvancedSignature
signature to be checked- Returns:
- true if the signing certificate is covered with a updated revocation data (after signature-timestamp production time)
-
checkSignatureNotExpired
Description copied from interface:ValidationContext
This method verifies if the signing certificate has not been expired yet or has a still valid timestamp Additionally, an alert can be handledCertificateVerifier.setAlertOnExpiredSignature(eu.europa.esig.dss.alert.StatusAlert)
- Specified by:
checkSignatureNotExpired
in interfaceValidationContext
- Parameters:
signature
-AdvancedSignature
signature to be verified- Returns:
- true if the signing certificate or its POE(s) not yet expired, false otherwise
-
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)
-
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 RevocationToken(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 TimestampTokens(s)
-
getValidationData
Description copied from interface:ValidationContext
Returns a validation data for the given signature's certificate chain- Specified by:
getValidationData
in interfaceValidationContext
- Parameters:
signature
-AdvancedSignature
to extract validation data for- Returns:
ValidationData
-
getValidationData
Description copied from interface:ValidationContext
Returns a validation data for the given timestampToken's certificate chain- Specified by:
getValidationData
in interfaceValidationContext
- Parameters:
timestampToken
-TimestampToken
to extract validation data for- Returns:
ValidationData
-