use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class TestSingleX509Keystore method testKeystoreGetCertificate.
@Test
public void testKeystoreGetCertificate() {
try {
KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
ksp.load();
String alias = config.getProperty(Config.KEYSTORE_SINGLE_X509_ALIAS);
if (ksp.containsAlias(alias)) {
Certificate thisCert = ksp.getCertificate(alias);
assertNotNull(thisCert);
} else {
fail(alias + " does not exist in the specified keystore");
}
} catch (Exception e) {
logR.error(e.getMessage(), e);
fail(e.getMessage());
}
}
use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class TestSingleX509Keystore method testKeystoreGetPrivateKey.
@Test
public void testKeystoreGetPrivateKey() {
try {
KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
ksp.load();
String alias = config.getProperty(Config.KEYSTORE_SINGLE_X509_ALIAS);
if (ksp.containsAlias(alias)) {
PrivateKey pk = ksp.getPrivateKey(alias, "".toCharArray());
assertNull(pk);
}
fail(alias + " exists in the specified keystore, and getPK didn't fail");
} catch (Exception e) {
// Expected bhaviour
;
}
}
use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class TestSingleX509Keystore method testKeystoreGetCertificateChain.
@Test
public void testKeystoreGetCertificateChain() {
try {
KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
ksp.load();
String alias = config.getProperty(Config.KEYSTORE_SINGLE_X509_ALIAS);
if (ksp.containsAlias(alias)) {
Certificate[] thisCert = ksp.getCertificateChain(alias);
assertEquals(1, thisCert.length);
} else {
fail(alias + " does not exist in the specified keystore");
}
} catch (Exception e) {
logR.error(e.getMessage(), e);
fail(e.getMessage());
}
}
use of com.adaptris.security.keystore.KeystoreProxy 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();
}
use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class SingleEntryKeystoreBase method testKeystoreGetKeyStore.
@Test
public void testKeystoreGetKeyStore() {
try {
KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
ksp.load();
assertNotNull("Keystore should not be null", ksp.getKeystore());
} catch (Exception e) {
logR.error(e.getMessage(), e);
fail(e.getMessage());
}
}
Aggregations