Search in sources :

Example 16 with KeystoreProxy

use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.

the class SingleEntryKeystoreBase method testContainsNonExistentAlias.

@Test
public void testContainsNonExistentAlias() throws Exception {
    KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
    ksp.load();
    String alias = String.valueOf(new Random().nextInt());
    if (ksp.containsAlias(alias)) {
        fail(alias + " exists in the specified keystore!");
    }
}
Also used : Random(java.util.Random) KeystoreProxy(com.adaptris.security.keystore.KeystoreProxy) Test(org.junit.Test)

Example 17 with KeystoreProxy

use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.

the class SingleEntryKeystoreBase method testImportCertificate.

@Test
public void testImportCertificate() throws Exception {
    KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
    ksp.load();
    try {
        ksp.setCertificate("", "");
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
    }
    try {
        ksp.setCertificate("", (Certificate) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
    }
    try {
        ksp.setCertificate("", (InputStream) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
    }
    try {
        ksp.setCertificate("", (File) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
    }
}
Also used : KeystoreProxy(com.adaptris.security.keystore.KeystoreProxy) KeystoreException(com.adaptris.security.exc.KeystoreException) KeystoreException(com.adaptris.security.exc.KeystoreException) Test(org.junit.Test)

Aggregations

KeystoreProxy (com.adaptris.security.keystore.KeystoreProxy)17 Test (org.junit.Test)11 KeystoreException (com.adaptris.security.exc.KeystoreException)7 Certificate (java.security.cert.Certificate)7 PrivateKey (java.security.PrivateKey)4 KeystoreLocation (com.adaptris.security.keystore.KeystoreLocation)3 CertificateBuilder (com.adaptris.security.certificate.CertificateBuilder)2 ConfiguredKeystore (com.adaptris.security.keystore.ConfiguredKeystore)2 Map (java.util.Map)2 AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)1 CertException (com.adaptris.security.exc.CertException)1 DecryptException (com.adaptris.security.exc.DecryptException)1 EncryptException (com.adaptris.security.exc.EncryptException)1 VerifyException (com.adaptris.security.exc.VerifyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 Random (java.util.Random)1