Search in sources :

Example 1 with ConfiguredUrl

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));
}
Also used : ConfiguredUrl(com.adaptris.security.keystore.ConfiguredUrl)

Example 2 with ConfiguredUrl

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());
}
Also used : ConfiguredUrl(com.adaptris.security.keystore.ConfiguredUrl) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 3 with ConfiguredUrl

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());
}
Also used : ConfiguredUrl(com.adaptris.security.keystore.ConfiguredUrl) ArrayList(java.util.ArrayList) ConfiguredKeystore(com.adaptris.security.keystore.ConfiguredKeystore) Test(org.junit.Test)

Example 4 with ConfiguredUrl

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);
    }
}
Also used : ConfiguredUrl(com.adaptris.security.keystore.ConfiguredUrl) Test(org.junit.Test)

Example 5 with ConfiguredUrl

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);
    }
}
Also used : ConfiguredUrl(com.adaptris.security.keystore.ConfiguredUrl) Test(org.junit.Test)

Aggregations

ConfiguredUrl (com.adaptris.security.keystore.ConfiguredUrl)11 Test (org.junit.Test)7 CoreException (com.adaptris.core.CoreException)2 Alias (com.adaptris.security.keystore.Alias)2 Before (org.junit.Before)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 ServiceException (com.adaptris.core.ServiceException)1 AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)1 ConfiguredKeystore (com.adaptris.security.keystore.ConfiguredKeystore)1 InlineKeystore (com.adaptris.security.keystore.InlineKeystore)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1