use of com.adaptris.security.keystore.ConfiguredKeystore in project interlok by adaptris.
the class SecurityServiceCase method testSetKeystoreUrls.
@Test
public void testSetKeystoreUrls() throws Exception {
CoreSecurityService input = create();
ConfiguredUrl url = new ConfiguredUrl(PROPERTIES.getProperty(KEYSTORE_URL), PROPERTIES.getProperty(SECURITY_PASSWORD));
input.addKeystoreUrl(url);
assertEquals(1, input.getKeystoreUrls().size());
assertTrue(input.getKeystoreUrls().contains(url));
try {
input.setKeystoreUrls(null);
fail();
} catch (IllegalArgumentException expected) {
}
ArrayList<ConfiguredKeystore> newList = new ArrayList<ConfiguredKeystore>();
input.setKeystoreUrls(newList);
assertEquals(0, input.getKeystoreUrls().size());
assertEquals(newList, input.getKeystoreUrls());
}
use of com.adaptris.security.keystore.ConfiguredKeystore in project interlok by adaptris.
the class CoreSecurityService method initService.
@Override
protected final void initService() throws CoreException {
try {
pkPassword = getPrivateKeyPasswordProvider().retrievePrivateKeyPassword();
} catch (PasswordException e) {
throw new CoreException("Could not get password using " + getPrivateKeyPasswordProvider().getClass().getCanonicalName(), e);
}
try {
if (isEmpty(localPartner)) {
throw new CoreException("No Local Partner configured");
}
localPartnerAlias = new Alias(localPartner, pkPassword);
if (isEmpty(remotePartner)) {
log.warn("Remote partner not configured, " + "must be set individually as message metadata");
} else {
remotePartnerAlias = new Alias(remotePartner);
}
SecurityServiceFactory factory = securityFactory;
if (factory == null) {
factory = SecurityServiceFactory.defaultInstance();
}
service = factory.createService();
for (Iterator i = keystoreUrls.iterator(); i.hasNext(); ) {
ConfiguredKeystore url = (ConfiguredKeystore) i.next();
service.registerKeystore(url);
}
service.setEncryptionAlgorithm(encryptionAlgorithm);
if (successId != null && failId != null) {
branchingEnabled = true;
} else {
log.debug("No Success Id or Fail Id, branching disabled");
}
} catch (AdaptrisSecurityException e) {
throw new CoreException(e);
}
}
use of com.adaptris.security.keystore.ConfiguredKeystore 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.ConfiguredKeystore 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.ConfiguredKeystore in project interlok by adaptris.
the class StdSecurityService method logKeystores.
private void logKeystores() {
if (logR.isDebugEnabled() && Constants.DEBUG) {
StringBuffer sb = new StringBuffer("Registered Keystores :");
for (ConfiguredKeystore ksi : keystores.keySet()) {
sb.append("[");
sb.append(ksi.toString());
sb.append("]");
}
}
}
Aggregations