You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jguerra <jg...@gmail.com> on 2011/09/08 14:26:33 UTC
HTTP component + Authentication
Hi,
I just wanted to check Camel 2.7 HTTP component to route JMS message payload
to a HTTP service. The configuration below works fine, but the service
requires to be authenticated.
<route>
<from uri="activemq:my.queue"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http://server:8080/service"/>
</route>
So, I am using another configuration inside of the camelContext to invoque
the service with "basic" authentication, but... the requests fail. I got a
HTTP 401.
<properties>
<property key="http.authMethodPriority"
value="Basic"/>
<property key="http.authMethod" value="Basic"/>
<property key="http.authUsername" value="dummy"/>
<property key="http.authPassword" value="pass"/>
</properties>
<route>
<from uri="activemq:my.queue"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http://server:8080/authservice"/>
</route>
I'll be pleased, if anyone can help me out on this!
Pd: I checked this link out without any success!.
http://camel.465427.n5.nabble.com/http-component-with-authentication-td475994.html
Cheers
--
View this message in context: http://camel.465427.n5.nabble.com/HTTP-component-Authentication-tp4782223p4782223.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: HTTP component + Authentication
Posted by jguerra <jg...@gmail.com>.
Just to post part of the output!
2011-09-08 13:38:26,814 | INFO | Apache Camel 2.7.0 (CamelContext: camel)
started in 0.873 seconds | org.apache.camel.spring.SpringCamelContext | main
2011-09-08 13:38:44,997 | INFO | basic authentication scheme selected |
org.apache.commons.httpclient.auth.AuthChallengeProcessor | Camel (camel)
thread #1 - JmsConsumer[ntcs.powerservice.queue]
2011-09-08 13:38:44,998 | INFO | No credentials available for BASIC
'file'@server:8080 | org.apache.commons.httpclient.HttpMethodDirector |
Camel (camel) thread #1 - JmsConsumer[ntcs.powerservice.queue]
2011-09-08 13:38:45,002 | ERROR | Failed delivery for exchangeId:
ID:tcs-amq-dev-42862-1315485501425-2:5:1:1:1. Exhausted after delivery
attempt: 1 caught:
org.apache.camel.component.http.HttpOperationFailedException: HTTP operation
failed invoking http://server:8080/authservice with statusCode: 401 |
org.apache.camel.processor.DefaultErrorHandler | Camel (camel) thread #1 -
JmsConsumer[ntcs.powerservice.queue]
--
View this message in context: http://camel.465427.n5.nabble.com/HTTP-component-Authentication-tp4782223p4782268.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: HTTP component + Authentication
Posted by jguerra <jg...@gmail.com>.
Awesome!!
thanks for the clues. It works!
Final configuration is something like this:
<route>
<from uri="direct:ntcs.powerservice.queue"/>
<setHeader headerName="Content-Type">
<constant>application/xml</constant>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http://server:8080/authservice"/>
</route>
<bean id="httpAuth"
class="org.apache.camel.component.http.HttpConfiguration">
<property name="authMethod" value="Basic"/>
<property name="authUsername" value="user"/>
<property name="authPassword" value="password"/>
</bean>
<bean id="http" class="org.apache.camel.component.http.HttpComponent">
<property name="camelContext" ref="camel"/>
<property name="httpConfiguration" ref="httpAuth"/>
</bean>
Cheers
--
View this message in context: http://camel.465427.n5.nabble.com/HTTP-component-Authentication-tp4782223p4785932.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: HTTP component + Authentication
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You would need to set the authentication on the http component or
directly on the http endpoint using parameters.
On the former you would need to define a HttpConfiguration object
<bean id="httpAuth" class="org.apache.camel.componen.http.HttpConfiguration">
.. here goes spring bean properties to set the authentication settings
</bean>
And then use the httpAuth on the http component
<bean id="http" class="org.apache.camel.component.HttpComponent">
<property name="httpConfiguration" ref="httpAuth"/>
</bean>
On Thu, Sep 8, 2011 at 2:26 PM, jguerra <jg...@gmail.com> wrote:
> Hi,
> I just wanted to check Camel 2.7 HTTP component to route JMS message payload
> to a HTTP service. The configuration below works fine, but the service
> requires to be authenticated.
>
> <route>
> <from uri="activemq:my.queue"/>
> <setHeader headerName="CamelHttpMethod">
> <constant>POST</constant>
> </setHeader>
> <to uri="http://server:8080/service"/>
> </route>
>
> So, I am using another configuration inside of the camelContext to invoque
> the service with "basic" authentication, but... the requests fail. I got a
> HTTP 401.
>
> <properties>
> <property key="http.authMethodPriority"
> value="Basic"/>
> <property key="http.authMethod" value="Basic"/>
> <property key="http.authUsername" value="dummy"/>
> <property key="http.authPassword" value="pass"/>
> </properties>
>
> <route>
> <from uri="activemq:my.queue"/>
> <setHeader headerName="CamelHttpMethod">
> <constant>POST</constant>
> </setHeader>
> <to uri="http://server:8080/authservice"/>
> </route>
>
> I'll be pleased, if anyone can help me out on this!
>
> Pd: I checked this link out without any success!.
> http://camel.465427.n5.nabble.com/http-component-with-authentication-td475994.html
> Cheers
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HTTP-component-Authentication-tp4782223p4782223.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/