use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class DecryptionServiceTest method applyConfigForTests.
protected void applyConfigForTests(CoreSecurityService service, String url) {
service.addKeystoreUrl(new ConfiguredUrl(url, PROPERTIES.getProperty(SECURITY_PASSWORD)));
ConfiguredPrivateKeyPasswordProvider configured = new ConfiguredPrivateKeyPasswordProvider(PROPERTIES.getProperty(SECURITY_PASSWORD));
service.setPrivateKeyPasswordProvider(configured);
service.setLocalPartner(PROPERTIES.getProperty(SECURITY_ALIAS));
service.setRemotePartner(PROPERTIES.getProperty(SECURITY_ALIAS));
}
use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class EncryptionServiceCase method testEncryptionDecryptionWithEncryptedPassword.
@Test
public void testEncryptionDecryptionWithEncryptedPassword() throws Exception {
String url = createKeystore();
CoreSecurityService input = create();
applyConfigForTests(input, new ConfiguredUrl(url, Password.encode(PROPERTIES.getProperty(SECURITY_PASSWORD), Password.PORTABLE_PASSWORD)));
DecryptionService output = new DecryptionService();
applyConfigForTests(output, new ConfiguredUrl(url, Password.encode(PROPERTIES.getProperty(SECURITY_PASSWORD), Password.PORTABLE_PASSWORD)));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(EXAMPLE_MSG);
execute(input, msg);
execute(output, msg);
assertEquals("Payload equality", EXAMPLE_MSG, msg.getContent());
}
use of com.adaptris.security.keystore.ConfiguredUrl 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.ConfiguredUrl in project interlok by adaptris.
the class SecurityServiceCase method testInit_NoRemotePartner.
@Test
public void testInit_NoRemotePartner() throws Exception {
CoreSecurityService input = create();
String url = createKeystore();
input.addKeystoreUrl(new ConfiguredUrl(url, PROPERTIES.getProperty(SECURITY_PASSWORD)));
input.setPrivateKeyPasswordProvider(new ConfiguredPrivateKeyPasswordProvider(PROPERTIES.getProperty(SECURITY_PASSWORD)));
input.setLocalPartner(PROPERTIES.getProperty(SECURITY_ALIAS));
try {
LifecycleHelper.init(input);
} finally {
LifecycleHelper.close(input);
}
}
use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class SecurityServiceCase method testInit_Branching.
@Test
public void testInit_Branching() throws Exception {
CoreSecurityService input = create();
String url = createKeystore();
input.addKeystoreUrl(new ConfiguredUrl(url, PROPERTIES.getProperty(SECURITY_PASSWORD)));
input.setPrivateKeyPasswordProvider(new ConfiguredPrivateKeyPasswordProvider(PROPERTIES.getProperty(SECURITY_PASSWORD)));
input.setLocalPartner(PROPERTIES.getProperty(SECURITY_ALIAS));
input.setRemotePartner(PROPERTIES.getProperty(SECURITY_ALIAS));
try {
// By default branching is false.
LifecycleHelper.init(input);
assertFalse(input.isBranching());
LifecycleHelper.close(input);
// If only one ID is set then it's false as well.
input.setFailId(FAIL);
LifecycleHelper.init(input);
assertFalse(input.isBranching());
LifecycleHelper.close(input);
input.setFailId(null);
input.setSuccessId(SUCCESS);
LifecycleHelper.init(input);
assertFalse(input.isBranching());
LifecycleHelper.close(input);
// Only if both are set is it branching.
input.setSuccessId(SUCCESS);
input.setFailId(FAIL);
LifecycleHelper.init(input);
assertTrue(input.isBranching());
} finally {
LifecycleHelper.close(input);
}
}
Aggregations