Search in sources :

Example 1 with CRLRevocationManager

use of org.nhindirect.stagent.cert.impl.CRLRevocationManager in project nhin-d by DirectProject.

the class CRLManagerTest method testCrlManager.

/**
     * Test the CRLManager class with normal and non-normal input.
     */
public void testCrlManager() {
    String tmp = this.getClass().getClassLoader().getResource("crl/certs.crl").getPath();
    final String workingDir = tmp.substring(0, tmp.lastIndexOf("/") + 1).replaceAll("%20", " ");
    String internalKeystoreFile = workingDir + "keystore";
    KeyStoreCertificateStore service = new KeyStoreCertificateStore(internalKeystoreFile, KEY_STORE_PASSWORD, PRIVATE_KEY_PASSWORD);
    RevocationManager crlManager = new CRLRevocationManager() {

        @Override
        protected String getNameString(String generalNameString) {
            String s = super.getNameString(generalNameString);
            return s.replace("http://JUNIT", "file://" + workingDir);
        }
    };
    assertEquals("Output does not match expected", false, crlManager.isRevoked(null));
    assertEquals("Output does not match expected", false, crlManager.isRevoked(service.getByAlias("valid")));
    assertEquals("Output does not match expected", true, crlManager.isRevoked(service.getByAlias("revoked")));
    assertEquals("Output does not match expected", false, crlManager.isRevoked(service.getByAlias("gm2552")));
    assertEquals("Output does not match expected", false, crlManager.isRevoked(service.getByAlias("missing")));
    // Hit cache
    assertEquals("Output does not match expected", false, crlManager.isRevoked(null));
    assertEquals("Output does not match expected", false, crlManager.isRevoked(service.getByAlias("valid")));
    assertEquals("Output does not match expected", true, crlManager.isRevoked(service.getByAlias("revoked")));
    assertEquals("Output does not match expected", false, crlManager.isRevoked(service.getByAlias("gm2552")));
    assertEquals("Output does not match expected", false, crlManager.isRevoked(service.getByAlias("missing")));
}
Also used : KeyStoreCertificateStore(org.nhindirect.stagent.cert.impl.KeyStoreCertificateStore) CRLRevocationManager(org.nhindirect.stagent.cert.impl.CRLRevocationManager) RevocationManager(org.nhindirect.stagent.cert.RevocationManager) CRLRevocationManager(org.nhindirect.stagent.cert.impl.CRLRevocationManager)

Aggregations

RevocationManager (org.nhindirect.stagent.cert.RevocationManager)1 CRLRevocationManager (org.nhindirect.stagent.cert.impl.CRLRevocationManager)1 KeyStoreCertificateStore (org.nhindirect.stagent.cert.impl.KeyStoreCertificateStore)1