Search in sources :

Example 11 with KeystoreLocation

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

the class TestKeystoreLocation method testNonExistentRemoteKeystore.

@Test
public void testNonExistentRemoteKeystore() {
    Assume.assumeTrue(Boolean.parseBoolean(cfg.getProperty(Config.REMOTE_TESTS_ENABLED, "false")));
    try {
        String url = cfg.getProperty(Config.KEYSTORE_REMOTE_ROOT) + "fred.ks?keystoreType=jks";
        KeystoreLocation k = KeystoreFactory.getDefault().create(url, cfg.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW).toCharArray());
        assertTrue("Keystore Location", !k.exists());
    } catch (Exception e) {
        logR.error("testNonExistentRemoteKeystore failed", e);
        fail(e.getMessage());
    }
}
Also used : KeystoreLocation(com.adaptris.security.keystore.KeystoreLocation) Test(org.junit.Test)

Example 12 with KeystoreLocation

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

the class Config method importPrivateKey.

public void importPrivateKey(String ksUrl, String filename, boolean overwrite) throws AdaptrisSecurityException, IOException {
    String commonName = config.getProperty(KEYSTORE_COMMON_PRIVKEY_ALIAS);
    KeystoreLocation ksc = KeystoreFactory.getDefault().create(ksUrl, config.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW).toCharArray());
    KeystoreProxy ksp = KeystoreFactory.getDefault().create(ksc);
    if (ksc.exists() && overwrite == false) {
        ksp.load();
    }
    ksp.importPrivateKey(commonName, config.getProperty(KEYSTORE_COMMON_PRIVKEY_PW).toCharArray(), filename, config.getProperty(KEYSTORE_COMMON_PRIVKEY_PW).toCharArray());
    ksp.commit();
}
Also used : KeystoreLocation(com.adaptris.security.keystore.KeystoreLocation) KeystoreProxy(com.adaptris.security.keystore.KeystoreProxy)

Aggregations

KeystoreLocation (com.adaptris.security.keystore.KeystoreLocation)12 Test (org.junit.Test)6 KeystoreProxy (com.adaptris.security.keystore.KeystoreProxy)3 HttpException (com.adaptris.http.HttpException)2 HttpsClient (com.adaptris.http.HttpsClient)2 CertificateBuilder (com.adaptris.security.certificate.CertificateBuilder)2 AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)2 KeystoreFactory (com.adaptris.security.keystore.KeystoreFactory)2 InputStream (java.io.InputStream)2 PrivateKey (java.security.PrivateKey)2 Certificate (java.security.cert.Certificate)2 URLString (com.adaptris.util.URLString)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1