Search in sources :

Example 1 with CertificateHandler

use of com.adaptris.security.certificate.CertificateHandler in project interlok by adaptris.

the class TestCertificateHandler method testGoodCertificateRevocationCache.

@Test
public void testGoodCertificateRevocationCache() throws Exception {
    InputStream input = new FileInputStream(config.getProperties().getProperty(Config.CERTHANDLER_GOOD));
    CertificateHandler handler = CertificateHandlerFactory.getInstance().generateHandler(input);
    input.close();
    assertEquals("Revocation", handler.isRevoked(), false);
    Calendar lastGoodCheck = handler.getLastRevocationCheck();
    assertEquals("Calendar", handler.getLastRevocationCheck(), lastGoodCheck);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Calendar(java.util.Calendar) CertificateHandler(com.adaptris.security.certificate.CertificateHandler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with CertificateHandler

use of com.adaptris.security.certificate.CertificateHandler in project interlok by adaptris.

the class TestCertificateHandler method testExpiredCertificateExpiry.

@Test
public void testExpiredCertificateExpiry() throws Exception {
    InputStream input = new FileInputStream(config.getProperties().getProperty(Config.CERTHANDLER_EXPIRED));
    CertificateHandler handler = CertificateHandlerFactory.getInstance().generateHandler(input);
    input.close();
    assertTrue("Expiry on \n" + handler.getCertificate().toString(), handler.isExpired());
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) CertificateHandler(com.adaptris.security.certificate.CertificateHandler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 3 with CertificateHandler

use of com.adaptris.security.certificate.CertificateHandler in project interlok by adaptris.

the class TestCertificateHandler method testGoodCertificateExpiry.

@Test
public void testGoodCertificateExpiry() throws Exception {
    InputStream input = new FileInputStream(config.getProperties().getProperty(Config.CERTHANDLER_GOOD));
    CertificateHandler handler = CertificateHandlerFactory.getInstance().generateHandler(input);
    input.close();
    assertTrue("Expiry on \n" + handler.getCertificate().toString(), !handler.isExpired());
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) CertificateHandler(com.adaptris.security.certificate.CertificateHandler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 4 with CertificateHandler

use of com.adaptris.security.certificate.CertificateHandler in project interlok by adaptris.

the class TestCertificateHandler method testExpiredCertificateRevocationCache.

@Test
public void testExpiredCertificateRevocationCache() throws Exception {
    try {
        InputStream input = new FileInputStream(config.getProperties().getProperty(Config.CERTHANDLER_EXPIRED));
        CertificateHandler handler = CertificateHandlerFactory.getInstance().generateHandler(input);
        input.close();
        assertEquals("Revocation", handler.isRevoked(), false);
        Calendar lastExpiredCheck = handler.getLastRevocationCheck();
        assertEquals("Calendar", handler.getLastRevocationCheck(), lastExpiredCheck);
    } catch (CertException e) {
        if (!(e.getCause() != null && e.getCause() instanceof UnknownHostException)) {
            throw e;
        }
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Calendar(java.util.Calendar) CertException(com.adaptris.security.exc.CertException) CertificateHandler(com.adaptris.security.certificate.CertificateHandler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 5 with CertificateHandler

use of com.adaptris.security.certificate.CertificateHandler in project interlok by adaptris.

the class TestCertificateHandler method testExpiredCertificateRevocation.

@Test
public void testExpiredCertificateRevocation() throws Exception {
    try {
        InputStream input = new FileInputStream(config.getProperties().getProperty(Config.CERTHANDLER_EXPIRED));
        CertificateHandler handler = CertificateHandlerFactory.getInstance().generateHandler(input);
        input.close();
        assertEquals("Revocation", handler.isRevoked(), false);
        assertNotNull(handler.getLastRevocationCheck());
    } catch (CertException e) {
        if (!(e.getCause() != null && e.getCause() instanceof UnknownHostException)) {
            throw e;
        }
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) CertException(com.adaptris.security.exc.CertException) CertificateHandler(com.adaptris.security.certificate.CertificateHandler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

CertificateHandler (com.adaptris.security.certificate.CertificateHandler)10 Test (org.junit.Test)7 FileInputStream (java.io.FileInputStream)6 InputStream (java.io.InputStream)6 CertException (com.adaptris.security.exc.CertException)3 PrivateKey (java.security.PrivateKey)3 EncryptException (com.adaptris.security.exc.EncryptException)2 VerifyException (com.adaptris.security.exc.VerifyException)2 UnknownHostException (java.net.UnknownHostException)2 Calendar (java.util.Calendar)2 CertificateBuilder (com.adaptris.security.certificate.CertificateBuilder)1 AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)1 DecryptException (com.adaptris.security.exc.DecryptException)1 KeystoreException (com.adaptris.security.exc.KeystoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 Signature (java.security.Signature)1 Certificate (java.security.cert.Certificate)1