-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed #17: CRL download is not parallel
- Loading branch information
Showing
2 changed files
with
82 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/cz/tomasdvorak/eet/client/security/crl/InMemoryCRLStoreTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cz.tomasdvorak.eet.client.security.crl; | ||
|
||
import cz.tomasdvorak.eet.client.security.ServerKey; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.security.cert.*; | ||
import java.util.*; | ||
|
||
public class InMemoryCRLStoreTest { | ||
|
||
private X509Certificate[] certificates; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
certificates = getFromClasspath("/keys/rca15_rsa.der", "/keys/2qca16_rsa.der", "/keys/crls-prod-cert.pem"); | ||
} | ||
|
||
@Test | ||
public void getCRLStore() throws Exception { | ||
CertStore crlStore = InMemoryCRLStore.INSTANCE.getCRLStore(certificates); | ||
final Collection<?> collection = ((CollectionCertStoreParameters) crlStore.getCertStoreParameters()).getCollection(); | ||
final int size = collection.size(); | ||
Assert.assertEquals(6, size); | ||
|
||
final Set<String> expectedDns = new HashSet<String>(Arrays.asList( | ||
"SERIALNUMBER=NTRCZ-26439395, CN=I.CA Root CA/RSA, O=\"První certifikační autorita, a.s.\", C=CZ", | ||
"SERIALNUMBER=NTRCZ-26439395, O=\"První certifikační autorita, a.s.\", CN=I.CA Qualified 2 CA/RSA 02/2016, C=CZ" | ||
)); | ||
|
||
final Set<String> foundDns = new HashSet<String>(); | ||
|
||
for (Object o : collection) { | ||
X509CRL crl = (X509CRL) o; | ||
final String name = crl.getIssuerDN().getName(); | ||
foundDns.add(name); | ||
} | ||
|
||
Assert.assertEquals(expectedDns, foundDns); | ||
} | ||
|
||
private X509Certificate[] getFromClasspath(final String... paths) throws CertificateException { | ||
final List<X509Certificate> certificates = new LinkedList<X509Certificate>(); | ||
for (String path : paths) { | ||
final CertificateFactory cf = CertificateFactory.getInstance("X.509"); | ||
final X509Certificate certificate = (X509Certificate) cf.generateCertificate(getClass().getResourceAsStream(path)); | ||
certificates.add(certificate); | ||
} | ||
return certificates.toArray(new X509Certificate[certificates.size()]); | ||
} | ||
|
||
} |