Package eu.europa.esig.dss.service.ocsp
Class OnlineOCSPSource
java.lang.Object
eu.europa.esig.dss.service.ocsp.OnlineOCSPSource
- All Implemented Interfaces:
OCSPSource,RevocationSource<OCSP>,RevocationSourceAlternateUrlsSupport<OCSP>,Serializable
public class OnlineOCSPSource
extends Object
implements OCSPSource, RevocationSourceAlternateUrlsSupport<OCSP>
Online OCSP repository. This implementation will contact the OCSP Responder
to retrieve the OCSP response.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an OCSP source The default constructor for OnlineOCSPSource.OnlineOCSPSource(DataLoader dataLoader) Creates an Online OCSP Source with the providedDataLoaderinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertOCSPResponseValid(org.bouncycastle.cert.ocsp.BasicOCSPResp basicOCSPResp, org.bouncycastle.cert.ocsp.SingleResp latestSingleResponse, byte[] expectedNonce) Verifies whether an OCSP response is validprotected byte[]buildOCSPRequest(CertificateToken certificateToken, CertificateToken issuerToken, byte[] nonce) Builds an OCSP request forcertificateTokenprotected org.bouncycastle.cert.ocsp.BasicOCSPRespexecuteOCSPRequest(String ocspAccessLocation, byte[] request) Executes arequestto the givenocspAccessLocationand returns an OCSP basic response, when applicablegetOCSPAccessURLs(CertificateToken certificateToken, List<String> alternativeUrls) Extracts a list of OCSP access URLs to be used in the provided order to retrieve an OCSP responsegetRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken) This method retrieves aRevocationTokenfor the certificateTokengetRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken, List<String> alternativeUrls) Gets anRevocationTokenfor the given certificate / issuer's certificate couple.voidsetAlertOnInvalidNonce(StatusAlert alertOnInvalidNonce) Sets a behavior when the nonce of the OCSP Response does not match the nonce sent within the request Default : ExceptionOnStatusAlert (throws an exception if nonce does not match)voidsetAlertOnInvalidUpdateTime(StatusAlert alertOnInvalidUpdateTime) Sets a behavior when the current time is out of the range of thisUpdate and nextUpdate fields extracted from the OCSP Response.voidsetAlertOnNonexistentNonce(StatusAlert alertOnNonexistentNonce) Sets a behavior when the obtained OCSP Response does not contain the nonce even that the nonce has been enforced (i.e.voidsetCertIDDigestAlgorithm(DigestAlgorithm certIDDigestAlgorithm) This method allows setting of DigestAlgorithm to be used in hash calculation for CertID element in an OCSP request buildingvoidsetDataLoader(DataLoader dataLoader) Set the DataLoader to use for querying a revocation server.voidsetNextUpdateTolerancePeriod(long nextUpdateTolerancePeriod) Clients MAY allow configuration of a small tolerance period for acceptance of responses after nextUpdate to handle minor clock differences relative to responders and caches.voidsetNonceSource(NonceSource nonceSource) Set the NonceSource to use for querying the OCSP server.
-
Constructor Details
-
OnlineOCSPSource
public OnlineOCSPSource()Create an OCSP source The default constructor for OnlineOCSPSource. The defaultOCSPDataLoaderis set. It is possible to change it with#setDataLoader(dataLoader). -
OnlineOCSPSource
Creates an Online OCSP Source with the providedDataLoaderinstance. It is still possible to change the defined instance with#setDataLoader(dataLoader).- Parameters:
dataLoader-DataLoaderto use
-
-
Method Details
-
setDataLoader
Set the DataLoader to use for querying a revocation server.- Parameters:
dataLoader- the component that allows to retrieve an OCSP response using HTTP.
-
setNonceSource
Set the NonceSource to use for querying the OCSP server.- Parameters:
nonceSource- the component that prevents the replay attack.
-
setCertIDDigestAlgorithm
This method allows setting of DigestAlgorithm to be used in hash calculation for CertID element in an OCSP request building- Parameters:
certIDDigestAlgorithm-DigestAlgorithm
-
setAlertOnInvalidNonce
Sets a behavior when the nonce of the OCSP Response does not match the nonce sent within the request Default : ExceptionOnStatusAlert (throws an exception if nonce does not match)- Parameters:
alertOnInvalidNonce-StatusAlert
-
setAlertOnNonexistentNonce
Sets a behavior when the obtained OCSP Response does not contain the nonce even that the nonce has been enforced (i.e.nonceSourceis specified). Default : LogOnStatusAlert (logs a warning in case the OCSP Response does not contain the nonce)- Parameters:
alertOnNonexistentNonce-StatusAlert
-
setAlertOnInvalidUpdateTime
Sets a behavior when the current time is out of the range of thisUpdate and nextUpdate fields extracted from the OCSP Response. The check is executed only when nonce is not checked. Default : SilentOnStatusAlert (skips the check validation)- Parameters:
alertOnInvalidUpdateTime-StatusAlert
-
setNextUpdateTolerancePeriod
public void setNextUpdateTolerancePeriod(long nextUpdateTolerancePeriod) Clients MAY allow configuration of a small tolerance period for acceptance of responses after nextUpdate to handle minor clock differences relative to responders and caches. I.e. currentTime shall not be after nextUpdate + nextUpdateTolerancePeriod. The setting is applicable only whencheckOCSPResponseUpdateTimeis enabled and no nonce is checked. Default : 0- Parameters:
nextUpdateTolerancePeriod- the tolerance period in milliseconds
-
getRevocationToken
public OCSPToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken) Description copied from interface:RevocationSourceThis method retrieves aRevocationTokenfor the certificateToken- Specified by:
getRevocationTokenin interfaceOCSPSource- Specified by:
getRevocationTokenin interfaceRevocationSource<OCSP>- Parameters:
certificateToken- TheCertificateTokenfor which the request is madeissuerCertificateToken- TheCertificateTokenwhich is the issuer of the certificateToken- Returns:
- an instance of
RevocationToken
-
getRevocationToken
public OCSPToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken, List<String> alternativeUrls) Description copied from interface:RevocationSourceAlternateUrlsSupportGets anRevocationTokenfor the given certificate / issuer's certificate couple. The coherence between the response and the request is checked.- Specified by:
getRevocationTokenin interfaceRevocationSourceAlternateUrlsSupport<OCSP>- Parameters:
certificateToken- TheCertificateTokenfor which the request is madeissuerCertificateToken- TheCertificateTokenwhich is the issuer of the certificateTokenalternativeUrls- The list of alternative urls to call- Returns:
RevocationTokencontaining information about the validity of the cert
-
getOCSPAccessURLs
protected List<String> getOCSPAccessURLs(CertificateToken certificateToken, List<String> alternativeUrls) Extracts a list of OCSP access URLs to be used in the provided order to retrieve an OCSP response- Parameters:
certificateToken-CertificateTokento retrieve OCSP response foralternativeUrls- a list ofStringrepresenting alternative URL sources- Returns:
- a list of
Stringurls
-
buildOCSPRequest
protected byte[] buildOCSPRequest(CertificateToken certificateToken, CertificateToken issuerToken, byte[] nonce) Builds an OCSP request forcertificateToken- Parameters:
certificateToken-CertificateTokento retrieve an OCSP token forissuerToken-CertificateTokenrepresenting an issuer certificate ofcertificateTokennonce- byte array containing a unique nonce- Returns:
- byte array representing an OCSP request
-
executeOCSPRequest
protected org.bouncycastle.cert.ocsp.BasicOCSPResp executeOCSPRequest(String ocspAccessLocation, byte[] request) throws IOException, org.bouncycastle.cert.ocsp.OCSPException Executes arequestto the givenocspAccessLocationand returns an OCSP basic response, when applicable- Parameters:
ocspAccessLocation-Stringrepresenting a URL to execute requestrequest- byte array containing OCSP request- Returns:
BasicOCSPResp- Throws:
IOException- if an error occurs on OCSP request executionorg.bouncycastle.cert.ocsp.OCSPException- if an error occurs on OCSP response reading
-
assertOCSPResponseValid
protected void assertOCSPResponseValid(org.bouncycastle.cert.ocsp.BasicOCSPResp basicOCSPResp, org.bouncycastle.cert.ocsp.SingleResp latestSingleResponse, byte[] expectedNonce) Verifies whether an OCSP response is valid- Parameters:
basicOCSPResp-BasicOCSPResplatestSingleResponse-SingleRespexpectedNonce- byte array
-