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());
}
}
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();
}
Aggregations