use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class TestSingleX509Keystore method testContainsAlias.
@Test
public void testContainsAlias() {
try {
KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
ksp.load();
String alias = config.getProperty(Config.KEYSTORE_SINGLE_X509_ALIAS);
if (!ksp.containsAlias(alias)) {
fail(alias + " doesn't 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 StdSecurityService method getCertificate.
private Certificate getCertificate(String alias) throws AdaptrisSecurityException {
Certificate c = null;
for (Map.Entry<ConfiguredKeystore, KeystoreProxy> set : keystores.entrySet()) {
ConfiguredKeystore ksi = set.getKey();
KeystoreProxy ksm = set.getValue();
if (ksm.containsAlias(alias)) {
if (logR.isDebugEnabled()) {
logR.debug("Certificate Alias " + alias + " found in " + ksi);
}
c = ksm.getCertificate(alias);
break;
}
}
if (c == null) {
throw new KeystoreException("Alias " + alias + " not found in registered keystores");
}
return c;
}
use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class StdSecurityService method getPrivateKey.
private PrivateKey getPrivateKey(String alias, char[] password) throws AdaptrisSecurityException {
PrivateKey pk = null;
for (Map.Entry<ConfiguredKeystore, KeystoreProxy> set : keystores.entrySet()) {
ConfiguredKeystore ksi = set.getKey();
KeystoreProxy ksm = set.getValue();
if (ksm.containsAlias(alias)) {
pk = ksm.getPrivateKey(alias, password);
if (logR.isDebugEnabled()) {
logR.debug("Private key alias " + alias + " found in " + ksi);
}
break;
}
}
if (pk == null) {
throw new KeystoreException("Private Key Alias " + alias + " not found in registered keystores");
}
return pk;
}
use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class StdSecurityService method registerKeystore.
/**
* @see SecurityService#registerKeystore(ConfiguredKeystore)
*/
public void registerKeystore(ConfiguredKeystore keystore) throws AdaptrisSecurityException {
try {
KeystoreProxy ksh = keystore.asKeystoreProxy();
keystores.put(keystore, ksh);
logKeystores();
} catch (Exception e) {
throw new KeystoreException(e);
}
}
use of com.adaptris.security.keystore.KeystoreProxy in project interlok by adaptris.
the class TestKeyStoreInfoChange method testChangeKeyStoreInfo.
@Test
public void testChangeKeyStoreInfo() {
Certificate thisCert;
try {
ksm = KeystoreFactory.getDefault().create(ksi);
ksm.load();
String alias = config.getProperty(Config.KEYSTORE_COMMON_PRIVKEY_ALIAS);
ksm.setKeystoreLocation(newKsi);
ksm.commit();
KeystoreProxy tempKsm = KeystoreFactory.getDefault().create(newKsi);
tempKsm.load();
if (tempKsm.containsAlias(alias)) {
thisCert = tempKsm.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());
}
}
Aggregations