use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class TestConfiguredUrl method setUp.
@Before
public void setUp() throws Exception {
Config config = Config.getInstance();
cfg = config.getProperties();
if (cfg == null) {
fail("No Configuration(!) available");
}
url = new ConfiguredUrl();
url.setUrl(cfg.getProperty(Config.KEYSTORE_TEST_URL) + "&" + Constants.KEYSTORE_PASSWORD + "=" + cfg.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW));
copy = new ConfiguredUrl(cfg.getProperty(Config.KEYSTORE_TEST_URL) + "&" + Constants.KEYSTORE_PASSWORD + "=" + cfg.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW));
config.buildKeystore(cfg.getProperty(Config.KEYSTORE_TEST_URL), null, true);
}
use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class TestDefaultSecurityService method testDefaultEncryptionWithMultipleKeystores.
@Test
public void testDefaultEncryptionWithMultipleKeystores() throws Exception {
ConfiguredUrl keystore = new ConfiguredUrl();
String filename = "" + Math.abs(new Random().nextInt()) + ".ks";
String newUrl = "file:///" + config.getProperty(Config.CFG_ROOT) + "/" + filename + "?keystoreType=JKS";
keystore.setUrl(newUrl + "&" + Constants.KEYSTORE_PASSWORD + "=" + config.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW));
String cn = "OtherUniqueAlias";
Config.getInstance().buildKeystore(newUrl, cn, false);
them = new Alias(cn, config.getProperty(Config.KEYSTORE_COMMON_PRIVKEY_PW));
service.registerKeystore(keystore);
Output output = service.encrypt(RAW_DATA, us, them);
output = service.sign(RAW_DATA, us, output);
String encrypted = output.getAsString();
output = service.verify(encrypted, them, us);
String payload = output.getAsString();
assertEquals("Data Verification", payload, RAW_DATA);
}
use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class EncryptionServiceCase method applyConfigForSamples.
protected static void applyConfigForSamples(CoreSecurityService service) {
try {
service.setLocalPartner("local partner alias in keystore");
service.setRemotePartner("remote partner alias in keystore");
service.addKeystoreUrl(new ConfiguredUrl("http://localhost/path/to/JKS/keystore?keystoreType=" + "JKS&keystorePassword=somePlainTextPassword"));
service.addKeystoreUrl(new ConfiguredUrl("file://localhost/path/to/a/X509/Certificate?keystoreType=" + "X509?keystoreAlias=CertificateAlias"));
service.addKeystoreUrl(new ConfiguredUrl("file://localhost/path/to/another/X509/Certificate?keystoreType=" + "X509?keystoreAlias=AnotherAlias"));
service.addKeystoreUrl(new ConfiguredUrl("http://host/path/to/a/PKCS12/Keystore?keystoreType=" + "PKCS12&keystoreAlias=PKCS12Alias", "PW:AAAAEF+zZCbvHeIXDx8HUslqiYwAAAAQ3wi4/BVycX+uzc5zF4F6EQAAABD0hhpr46IrKSu7XxFhEAYN"));
// service.addKeystoreUrl(new ConfiguredUrl("http://host/path/to/keystore?keystoreType=" + "PKCS12&keystoreAlias=myalias",
// PROPERTIES.getProperty(SECURITY_PASSWORD)));
service.addKeystoreUrl(new ConfiguredUrl("http://host/path/to/a/JCE/keystore?keystoreType=JCEKS", "ALTPW:AAAAEF+zZCbvHeIXDx8HUslqiYwAAAAQ3wi4/BVycX+uzc5zF4F6EQAAABD0hhpr46IrKSu7XxFhEAYN"));
// service.addKeystoreUrl(new ConfiguredUrl("http://host/path/to/keystore?keystoreType=" + "JCEKS&keystoreAlias=myalias",
// Password.encode(PROPERTIES.getProperty(SECURITY_PASSWORD), Password.NON_PORTABLE_PASSWORD)));
service.addKeystoreUrl(new ConfiguredUrl("file://local/path/to/anoter/JKS/keystore?keystoreType=" + "JKS&keystoreAlias=myalias", "somePlainTextPassword"));
InlineKeystore inline = new InlineKeystore();
inline.setCertificate(EXAMPLE_KEYINFO);
inline.setType(Constants.KEYSTORE_XMLKEYINFO);
inline.setAlias("myAlias");
service.addKeystoreUrl(inline);
addEncryptionAlgsForFactoryType(service);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class SecurityServiceCase method testInit_InvalidUrl.
@Test
public void testInit_InvalidUrl() throws Exception {
CoreSecurityService input = create();
input.addKeystoreUrl(new ConfiguredUrl(createDummyKeystoreUrl(), 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 {
LifecycleHelper.init(input);
fail();
} catch (CoreException expected) {
} finally {
LifecycleHelper.close(input);
}
}
use of com.adaptris.security.keystore.ConfiguredUrl in project interlok by adaptris.
the class SecurityServiceCase method testInit_FailedToGetPrivateKey.
@Test
public void testInit_FailedToGetPrivateKey() throws Exception {
CoreSecurityService input = create();
input.setPrivateKeyPasswordProvider(new FailingPrivateKeyPasswordProvider());
input.addKeystoreUrl(new ConfiguredUrl(PROPERTIES.getProperty(KEYSTORE_URL), PROPERTIES.getProperty(SECURITY_PASSWORD)));
input.setLocalPartner(PROPERTIES.getProperty(SECURITY_ALIAS));
input.setRemotePartner(PROPERTIES.getProperty(SECURITY_ALIAS));
try {
LifecycleHelper.init(input);
fail();
} catch (CoreException expected) {
}
}
Aggregations