Search in sources :

Example 46 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithCredentials.

@Test
public void testInitialiseWithCredentials() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    PasProducer producer = new PasProducer().withTopic(topicName);
    ;
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = activeMqBroker.getJndiPasConnection(jv, false, queueName, topicName);
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("UserName", RequiresCredentialsBroker.DEFAULT_USERNAME));
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("Password", RequiresCredentialsBroker.DEFAULT_PASSWORD));
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        LifecycleHelper.init(standaloneProducer);
    } finally {
        LifecycleHelper.close(standaloneProducer);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 47 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithEncryptedPasswordNotSupported.

@Test
public void testInitialiseWithEncryptedPasswordNotSupported() throws Exception {
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    PasProducer producer = new PasProducer().withTopic(queueName);
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = broker.getJndiPasConnection(jv, false, queueName, topicName);
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("UserName", RequiresCredentialsBroker.DEFAULT_USERNAME));
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("Password", Password.encode(RequiresCredentialsBroker.DEFAULT_PASSWORD, Password.PORTABLE_PASSWORD)));
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        broker.start();
        LifecycleHelper.init(standaloneProducer);
        fail("Encrypted password should not be supported, as not explicitly configured");
    } catch (Exception e) {
    // expected
    } finally {
        broker.destroy();
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) RequiresCredentialsBroker(com.adaptris.core.jms.activemq.RequiresCredentialsBroker) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 48 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithEncryptedPassword_viaEncodedPasswordKeys.

@Test
public void testInitialiseWithEncryptedPassword_viaEncodedPasswordKeys() throws Exception {
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    PasProducer producer = new PasProducer().withTopic(queueName);
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = broker.getJndiPasConnection(jv, false, queueName, topicName);
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("UserName", RequiresCredentialsBroker.DEFAULT_USERNAME));
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("Password", Password.encode(RequiresCredentialsBroker.DEFAULT_PASSWORD, Password.PORTABLE_PASSWORD)));
    jv.setEncodedPasswordKeys("Password");
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        broker.start();
        LifecycleHelper.init(standaloneProducer);
    } finally {
        LifecycleHelper.close(standaloneProducer);
        broker.destroy();
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) RequiresCredentialsBroker(com.adaptris.core.jms.activemq.RequiresCredentialsBroker) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 49 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class ConfiguredResponseHeaderProvider method addHeaders.

@Override
public HttpServletResponse addHeaders(AdaptrisMessage msg, HttpServletResponse target) {
    for (KeyValuePair k : getHeaders()) {
        log.trace("Adding Response Header [{}: {}]", k.getKey(), k.getValue());
        target.addHeader(k.getKey(), k.getValue());
    }
    return target;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair)

Example 50 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class HttpConnection method configure.

protected ServerConnector configure(ServerConnector connector) throws Exception {
    connector.setPort(getPort());
    for (KeyValuePair kvp : getServerConnectorProperties().getKeyValuePairs()) {
        boolean matched = false;
        for (ServerConnectorProperty sp : ServerConnectorProperty.values()) {
            if (kvp.getKey().equalsIgnoreCase(sp.toString())) {
                sp.applyProperty(connector, kvp.getValue());
                matched = true;
                break;
            }
        }
        if (!matched) {
            if (!SimpleBeanUtil.callSetter(connector, "set" + kvp.getKey(), kvp.getValue())) {
                log.trace("Ignoring unsupported Property {}", kvp.getKey());
            }
        }
    }
    return connector;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair)

Aggregations

KeyValuePair (com.adaptris.util.KeyValuePair)143 Test (org.junit.Test)79 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)55 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)26 KeyValuePairList (com.adaptris.util.KeyValuePairList)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 Channel (com.adaptris.core.Channel)9 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 TimeInterval (com.adaptris.util.TimeInterval)9 ServiceException (com.adaptris.core.ServiceException)7 JmsConnection (com.adaptris.core.jms.JmsConnection)6 ArrayList (java.util.ArrayList)6 CoreException (com.adaptris.core.CoreException)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 PasProducer (com.adaptris.core.jms.PasProducer)5 MetadataCollection (com.adaptris.core.MetadataCollection)4 MetadataElement (com.adaptris.core.MetadataElement)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3