Search in sources :

Example 1 with SimpleHttpProducer

use of com.adaptris.http.legacy.SimpleHttpProducer in project interlok by adaptris.

the class HttpConsumerTest method createProducer.

protected SimpleHttpProducer createProducer() {
    SimpleHttpProducer p = new SimpleHttpProducer();
    p.registerConnection(new HttpProduceConnection());
    p.setContentTypeKey("content.type");
    p.setIgnoreServerResponseCode(true);
    return p;
}
Also used : HttpProduceConnection(com.adaptris.http.legacy.HttpProduceConnection) SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer)

Example 2 with SimpleHttpProducer

use of com.adaptris.http.legacy.SimpleHttpProducer in project interlok by adaptris.

the class HttpsConsumerTest method createProducer.

private SimpleHttpProducer createProducer(HttpsProduceConnection https) {
    SimpleHttpProducer p = new SimpleHttpProducer();
    https.setKeystore(PROPERTIES.getProperty(JunitSecurityHelper.KEYSTORE_URL));
    https.setAlwaysTrust(true);
    https.setPrivateKeyPasswordProvider(new ConfiguredPrivateKeyPasswordProvider(PROPERTIES.getProperty(JunitSecurityHelper.SECURITY_PASSWORD)));
    https.setKeystorePassword(PROPERTIES.getProperty(JunitSecurityHelper.SECURITY_PASSWORD));
    p.registerConnection(https);
    p.setContentTypeKey("content.type");
    p.setIgnoreServerResponseCode(true);
    return p;
}
Also used : SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer) ConfiguredPrivateKeyPasswordProvider(com.adaptris.core.security.ConfiguredPrivateKeyPasswordProvider)

Example 3 with SimpleHttpProducer

use of com.adaptris.http.legacy.SimpleHttpProducer in project interlok by adaptris.

the class HttpsConsumerTest method testTLS_ConsumeWorkflow.

@Test
public void testTLS_ConsumeWorkflow() throws Exception {
    String oldName = Thread.currentThread().getName();
    Thread.currentThread().setName(getName());
    HttpConnection connection = createConnection(null);
    ((HttpsConnection) connection).getSslProperties().add(new KeyValuePair(SslProperty.ExcludeProtocols.name(), "SSLv3,TLSv1.1,"));
    MockMessageProducer mockProducer = new MockMessageProducer();
    SimpleHttpProducer myHttpProducer = createProducer(new VersionedHttpsProduceConnection("TLSv1.2"));
    Channel channel = JettyHelper.createChannel(connection, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
    try {
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        myHttpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
        start(myHttpProducer);
        AdaptrisMessage reply = myHttpProducer.request(msg);
        assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
        doAssertions(mockProducer);
    } finally {
        stop(myHttpProducer);
        channel.requestClose();
        PortManager.release(connection.getPort());
        Thread.currentThread().setName(oldName);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer) Channel(com.adaptris.core.Channel) VersionedHttpsProduceConnection(com.adaptris.http.legacy.VersionedHttpsProduceConnection) Test(org.junit.Test)

Example 4 with SimpleHttpProducer

use of com.adaptris.http.legacy.SimpleHttpProducer in project interlok by adaptris.

the class HttpsConsumerTest method testTLS_ConsumeWorkflow_ClientUsesSSL.

@Test
public void testTLS_ConsumeWorkflow_ClientUsesSSL() throws Exception {
    String oldName = Thread.currentThread().getName();
    Thread.currentThread().setName(getName());
    HttpConnection connection = createConnection(null);
    ((HttpsConnection) connection).getSslProperties().add(new KeyValuePair(SslProperty.ExcludeProtocols.name(), "SSLv3"));
    MockMessageProducer mockProducer = new MockMessageProducer();
    SimpleHttpProducer myHttpProducer = createProducer(new VersionedHttpsProduceConnection("SSLv3"));
    Channel channel = JettyHelper.createChannel(connection, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
    try {
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        myHttpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
        start(myHttpProducer);
        AdaptrisMessage reply = myHttpProducer.request(msg);
        // SSLv3 context shouldn't be allowed to connect to TLSv1.2 only
        fail();
    } catch (CoreException expected) {
    } finally {
        stop(myHttpProducer);
        channel.requestClose();
        PortManager.release(connection.getPort());
        Thread.currentThread().setName(oldName);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer) Channel(com.adaptris.core.Channel) VersionedHttpsProduceConnection(com.adaptris.http.legacy.VersionedHttpsProduceConnection) Test(org.junit.Test)

Aggregations

SimpleHttpProducer (com.adaptris.http.legacy.SimpleHttpProducer)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 Channel (com.adaptris.core.Channel)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 VersionedHttpsProduceConnection (com.adaptris.http.legacy.VersionedHttpsProduceConnection)2 KeyValuePair (com.adaptris.util.KeyValuePair)2 Test (org.junit.Test)2 CoreException (com.adaptris.core.CoreException)1 ConfiguredPrivateKeyPasswordProvider (com.adaptris.core.security.ConfiguredPrivateKeyPasswordProvider)1 HttpProduceConnection (com.adaptris.http.legacy.HttpProduceConnection)1