JdbcCacheCRLSource extends JdbcRevocationSource<CRL> implements CRLSource { @Override public CRLToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken) { return (CRLToken) super.getRevocationToken(certificateToken, issuerCertificateToken); }  @Override List<String> initRevocationTokenKey(CertificateToken certificateToken); @Override CRLToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken); @Override CRLToken getRevocationToken(CertificateToken certificateToken, CertificateToken issuerCertificateToken, boolean forceRefresh);  }
@Test public void test() throws Exception { CRLToken revocationToken = null; CertificateToken certificateToken = DSSUtils.loadCertificate(new File("src/test/resources/citizen_ca.crt")); CertificateToken caToken = DSSUtils.loadCertificate(new File("src/test/resources/belgiumrs2.crt")); revocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNull(revocationToken); OnlineCRLSource onlineCRLSource = new OnlineCRLSource(); crlSource.setProxySource(onlineCRLSource); revocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(revocationToken); assertNotNull(revocationToken.getRevocationTokenKey()); assertEquals(RevocationOrigin.EXTERNAL, revocationToken.getExternalOrigin()); CRLToken savedRevocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(savedRevocationToken); compareTokens(revocationToken, savedRevocationToken); assertEquals(RevocationOrigin.CACHED, savedRevocationToken.getExternalOrigin()); CRLToken forceRefresh = crlSource.getRevocationToken(certificateToken, caToken, true); assertNotNull(forceRefresh); assertEquals(RevocationOrigin.EXTERNAL, forceRefresh.getExternalOrigin()); savedRevocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(savedRevocationToken); compareTokens(revocationToken, savedRevocationToken); assertEquals(RevocationOrigin.CACHED, savedRevocationToken.getExternalOrigin()); crlSource.setMaxNextUpdateDelay(1L); Thread.sleep(1000); forceRefresh = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(forceRefresh); assertEquals(RevocationOrigin.EXTERNAL, forceRefresh.getExternalOrigin()); crlSource.setMaxNextUpdateDelay(null); forceRefresh = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(forceRefresh); assertEquals(RevocationOrigin.CACHED, forceRefresh.getExternalOrigin()); }
@Test public void testExpired() throws SQLException { CRLToken revocationToken = null; CertificateToken certificateToken = DSSUtils.loadCertificate(new File("src/test/resources/ec.europa.eu.crt")); CertificateToken caToken = DSSUtils.loadCertificate(new File("src/test/resources/CALT.crt")); revocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNull(revocationToken); OnlineCRLSource onlineCRLSource = new OnlineCRLSource(); crlSource.setProxySource(onlineCRLSource); revocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(revocationToken); assertNotNull(revocationToken.getRevocationTokenKey()); assertEquals(RevocationOrigin.EXTERNAL, revocationToken.getExternalOrigin()); CRLToken savedRevocationToken = crlSource.getRevocationToken(certificateToken, caToken); assertNotNull(savedRevocationToken); assertEquals(revocationToken.getRevocationTokenKey(), savedRevocationToken.getRevocationTokenKey()); assertEquals(revocationToken.getNextUpdate(), savedRevocationToken.getNextUpdate()); assertEquals(RevocationOrigin.EXTERNAL, savedRevocationToken.getExternalOrigin()); }