JdbcCacheOCSPSource extends JdbcRevocationSource<OCSP> implements OCSPSource { @Override public OCSPToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken) { return (OCSPToken) super.getRevocationToken(certificateToken, issuerCertificateToken); }  @Override final List<String> initRevocationTokenKey(CertificateToken certificateToken); @Override OCSPToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken); @Override OCSPToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken, boolean forceRefresh);  }
@Test public void test() throws Exception { OCSPToken revocationToken = null; CertificateToken certificateToken = DSSUtils.loadCertificate(new File("src/test/resources/ec.europa.eu.crt")); CertificateToken rootToken = DSSUtils.loadCertificate(new File("src/test/resources/CALT.crt")); revocationToken = ocspSource.getRevocationToken(certificateToken, rootToken); assertNull(revocationToken); OnlineOCSPSource onlineOCSPSource = new OnlineOCSPSource(); ocspSource.setProxySource(onlineOCSPSource); ocspSource.setDefaultNextUpdateDelay(180L); revocationToken = ocspSource.getRevocationToken(certificateToken, rootToken); assertNotNull(revocationToken); assertNotNull(revocationToken.getRevocationTokenKey()); assertEquals(RevocationOrigin.EXTERNAL, revocationToken.getExternalOrigin()); requestTime = new Date(); OCSPToken savedRevocationToken = ocspSource.getRevocationToken(certificateToken, rootToken); assertNotNull(savedRevocationToken); assertEquals(revocationToken.getRevocationTokenKey(), savedRevocationToken.getRevocationTokenKey()); assertEquals(revocationToken.getAbbreviation(), savedRevocationToken.getAbbreviation()); assertEquals(revocationToken.getCreationDate(), savedRevocationToken.getCreationDate()); assertEquals(revocationToken.getDSSIdAsString(), savedRevocationToken.getDSSIdAsString()); assertEquals(Hex.encodeHexString(revocationToken.getEncoded()), Hex.encodeHexString(savedRevocationToken.getEncoded())); assertEquals(Hex.encodeHexString(revocationToken.getIssuerX500Principal().getEncoded()), Hex.encodeHexString(savedRevocationToken.getIssuerX500Principal().getEncoded())); assertEquals(revocationToken.getNextUpdate(), savedRevocationToken.getNextUpdate()); assertEquals(RevocationOrigin.CACHED, savedRevocationToken.getExternalOrigin()); assertNotEquals(revocationToken.getExternalOrigin(), savedRevocationToken.getExternalOrigin()); assertEquals(revocationToken.getProductionDate(), savedRevocationToken.getProductionDate()); assertEquals(Hex.encodeHexString(revocationToken.getPublicKeyOfTheSigner().getEncoded()), Hex.encodeHexString(savedRevocationToken.getPublicKeyOfTheSigner().getEncoded())); assertEquals(revocationToken.getReason(), savedRevocationToken.getReason()); assertEquals(revocationToken.getRelatedCertificateID(), savedRevocationToken.getRelatedCertificateID()); assertEquals(revocationToken.getRevocationDate(), savedRevocationToken.getRevocationDate()); assertEquals(revocationToken.getSignatureAlgorithm().getEncryptionAlgorithm().name(), savedRevocationToken.getSignatureAlgorithm().getEncryptionAlgorithm().name()); assertEquals(revocationToken.getSourceURL(), savedRevocationToken.getSourceURL()); assertEquals(revocationToken.getStatus(), savedRevocationToken.getStatus()); assertEquals(revocationToken.getThisUpdate(), savedRevocationToken.getThisUpdate()); storedRevocationToken = ocspSource.getRevocationToken(certificateToken, rootToken); assertNotNull(storedRevocationToken); assertEquals(RevocationOrigin.CACHED, storedRevocationToken.getExternalOrigin()); OCSPToken refreshedRevocationToken = ocspSource.getRevocationToken(certificateToken, rootToken); assertNotNull(refreshedRevocationToken); assertEquals(RevocationOrigin.CACHED, refreshedRevocationToken.getExternalOrigin()); ocspSource.setMaxNextUpdateDelay(1L); Thread.sleep(1000); refreshedRevocationToken = ocspSource.getRevocationToken(certificateToken, rootToken); assertNotNull(refreshedRevocationToken); assertEquals(RevocationOrigin.EXTERNAL, refreshedRevocationToken.getExternalOrigin()); }