Search in sources :

Example 1 with HttpConfiguration

use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.

the class HttpProxyAuthNTLMTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() {
            // setup proxy details
            HttpConfiguration config = new HttpConfiguration();
            config.setProxyHost("myProxyHosy");
            config.setProxyPort(1234);
            config.setProxyAuthMethod("NTLM");
            config.setProxyAuthUsername("myUser");
            config.setProxyAuthPassword("myPassword");
            config.setProxyAuthDomain("myDomain");
            config.setProxyAuthHost("myHost");
            HttpComponent http = context.getComponent("http", HttpComponent.class);
            http.setHttpConfiguration(config);
            from("direct:start").to("http://www.google.com/search");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) HttpConfiguration(org.apache.camel.http.common.HttpConfiguration)

Example 2 with HttpConfiguration

use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.

the class HttpProxyTest method testHttpProxyComponentConfigured.

@Test
public void testHttpProxyComponentConfigured() throws Exception {
    HttpConfiguration config = new HttpConfiguration();
    config.setProxyHost("myotherproxy");
    config.setProxyPort(2345);
    HttpComponent comp = context.getComponent("http", HttpComponent.class);
    comp.setHttpConfiguration(config);
    HttpEndpoint http = context.getEndpoint("http://www.google.com", HttpEndpoint.class);
    context.getProperties().put("http.proxyHost", "myproxy");
    context.getProperties().put("http.proxyPort", "1234");
    try {
        HttpClient client = http.createHttpClient();
        assertEquals("myotherproxy", client.getHostConfiguration().getProxyHost());
        assertEquals(2345, client.getHostConfiguration().getProxyPort());
    } finally {
        context.getProperties().remove("http.proxyHost");
        context.getProperties().remove("http.proxyPort");
    }
}
Also used : HttpClient(org.apache.commons.httpclient.HttpClient) HttpConfiguration(org.apache.camel.http.common.HttpConfiguration) Test(org.junit.Test)

Example 3 with HttpConfiguration

use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.

the class HttpAuthMethodPriorityTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() {
            // setup proxy details
            HttpConfiguration config = new HttpConfiguration();
            config.setAuthMethod("Basic");
            config.setAuthUsername("myUser");
            config.setAuthPassword("myPassword");
            // to avoid NTLM
            config.setAuthMethodPriority("Basic,Digest");
            HttpComponent http = context.getComponent("http", HttpComponent.class);
            http.setHttpConfiguration(config);
            from("direct:start").to("http://www.google.com/search");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) HttpConfiguration(org.apache.camel.http.common.HttpConfiguration)

Example 4 with HttpConfiguration

use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.

the class HttpProxyAuthBasicTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() {
            // setup proxy details
            HttpConfiguration config = new HttpConfiguration();
            config.setProxyHost("myProxyHosy");
            config.setProxyPort(1234);
            // proxy requires auth as well
            config.setProxyAuthMethod("Basic");
            config.setProxyAuthUsername("myUser");
            config.setProxyAuthPassword("myPassword");
            HttpComponent http = context.getComponent("http", HttpComponent.class);
            http.setHttpConfiguration(config);
            from("direct:start").to("http://www.google.com/search");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) HttpConfiguration(org.apache.camel.http.common.HttpConfiguration)

Example 5 with HttpConfiguration

use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.

the class HttpProxyAuthDigestTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() {
            // setup proxy details
            HttpConfiguration config = new HttpConfiguration();
            config.setProxyAuthMethod("Digest");
            config.setProxyAuthUsername("myUser");
            config.setProxyAuthPassword("myPassword");
            HttpComponent http = context.getComponent("http", HttpComponent.class);
            http.setHttpConfiguration(config);
            from("direct:start").to("http://www.google.com/search");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) HttpConfiguration(org.apache.camel.http.common.HttpConfiguration)

Aggregations

HttpConfiguration (org.apache.camel.http.common.HttpConfiguration)7 RouteBuilder (org.apache.camel.builder.RouteBuilder)5 Test (org.junit.Test)2 Principal (java.security.Principal)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 HttpComponent (org.apache.camel.component.http.HttpComponent)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 Ignore (org.junit.Ignore)1