You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Eric V." <er...@mail.ru> on 2009/11/18 00:49:34 UTC

http component with basic authentication when use HTTP_URI

When I use basic authentication with http(s) component I can't set
user/password in HTTP_URI header. Authentication work only if credentials
set in endpoint URI, e.g.:
         ...
        .setHeader("CamelHttpMethod", constant("GET"))
        .setHeader("CamelHttpUri", body().convertTo(String.class))
	.to(ExchangePattern.InOut,
"https://localhost:8443?username=guest&password=guest")

It's code will work. Here uri get from previous message and user/password
from endpoint URI. If I remove user/password from endpoint URI it's dont
work (credentials from HTTP_URI dont send to http server):
         ...
        .setHeader("CamelHttpMethod", constant("GET"))
        .setHeader("CamelHttpUri", body().convertTo(String.class))
	.to(ExchangePattern.InOut, "https://localhost:8443")

Log:
...
[read 4: seda://processelements] HttpMethodBase                 DEBUG Adding
Host request header
[read 4: seda://processelements] header                         DEBUG >>
"User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
[read 4: seda://processelements] header                         DEBUG >>
"Host: localhost[\r][\n]"
[read 4: seda://processelements] header                         DEBUG >>
"[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"HTTP/1.1 401 Unauthorized[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"HTTP/1.1 401 Unauthorized[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Server: Apache-Coyote/1.1[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Pragma: No-cache[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Cache-Control: no-cache[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Expires: Thu, 01 Jan 1970 03:00:00 MSK[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"WWW-Authenticate: Basic realm="localhost:443"[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Content-Type: text/html;charset=utf-8[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Content-Length: 954[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"Date: Tue, 17 Nov 2009 23:45:22 GMT[\r][\n]"
[read 4: seda://processelements] header                         DEBUG <<
"[\r][\n]"
[read 4: seda://processelements] HttpMethodDirector             DEBUG
Authorization required
[read 4: seda://processelements] AuthChallengeProcessor         DEBUG
Supported authentication schemes in the order of preference: [ntlm, digest,
basic]
[read 4: seda://processelements] AuthChallengeProcessor         DEBUG
Challenge for ntlm authentication scheme not available
[read 4: seda://processelements] AuthChallengeProcessor         DEBUG
Challenge for digest authentication scheme not available
[read 4: seda://processelements] AuthChallengeProcessor         INFO  basic
authentication scheme selected
[read 4: seda://processelements] AuthChallengeProcessor         DEBUG Using
authentication scheme: basic
[read 4: seda://processelements] AuthChallengeProcessor         DEBUG
Authorization challenge processed
[read 4: seda://processelements] HttpMethodDirector             DEBUG
Authentication scope: BASIC 'localhost:443'@localhost:8443
[read 4: seda://processelements] HttpMethodDirector             DEBUG
Credentials required
[read 4: seda://processelements] HttpMethodDirector             DEBUG
Credentials provider not available
[read 4: seda://processelements] HttpMethodDirector             INFO  No
credentials available for BASIC 'localhost:443'@localhost:8443
[read 4: seda://processelements] HttpProducer                   DEBUG Http
responseCode: 401
...


This is normal? May be any workaround, when I dont need to set user/password
in code?

camel-version: 2.0-M3

Regards,
Ernold Vasiliev



-- 
View this message in context: http://old.nabble.com/http-component-with-basic-authentication-when-use-HTTP_URI-tp26399992p26399992.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: http component with basic authentication when use HTTP_URI

Posted by "Eric V." <er...@mail.ru>.
Thank you, Claus!

Realy using of .recipientList instead  .to() whith HTTP_URI header is that I
need in this case!
        ...
        .setHeader("CamelHttpUri", body().convertTo(String.class))
        .recipientList(header("CamelHttpUri"))

Credentials in uri from message body are send to http server.

Regards,
Ernold Vasiliev


Claus Ibsen-2 wrote:
> 
> Hi
> 
> What is your problem?
> username and password must be supplied on the endpoint for HTTP Basic
> Auth.
> 
> If you need dynamic behavior use the dynamic recipient list EIP pattern
> http://camel.apache.org/recipient-list.html
> 
> On Wed, Nov 18, 2009 at 12:49 AM, Eric V. <er...@mail.ru> wrote:
>>
>> When I use basic authentication with http(s) component I can't set
>> user/password in HTTP_URI header. Authentication work only if credentials
>> set in endpoint URI, e.g.:
>>         ...
>>        .setHeader("CamelHttpMethod", constant("GET"))
>>        .setHeader("CamelHttpUri", body().convertTo(String.class))
>>        .to(ExchangePattern.InOut,
>> "https://localhost:8443?username=guest&password=guest")
>>
>> It's code will work. Here uri get from previous message and user/password
>> from endpoint URI. If I remove user/password from endpoint URI it's dont
>> work (credentials from HTTP_URI dont send to http server):
>>         ...
>>        .setHeader("CamelHttpMethod", constant("GET"))
>>        .setHeader("CamelHttpUri", body().convertTo(String.class))
>>        .to(ExchangePattern.InOut, "https://localhost:8443")
>>
>> Log:
>> ...
>> [read 4: seda://processelements] HttpMethodBase                 DEBUG
>> Adding
>> Host request header
>> [read 4: seda://processelements] header                         DEBUG >>
>> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG >>
>> "Host: localhost[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG >>
>> "[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "HTTP/1.1 401 Unauthorized[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "HTTP/1.1 401 Unauthorized[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Server: Apache-Coyote/1.1[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Pragma: No-cache[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Cache-Control: no-cache[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Expires: Thu, 01 Jan 1970 03:00:00 MSK[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "WWW-Authenticate: Basic realm="localhost:443"[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Content-Type: text/html;charset=utf-8[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Content-Length: 954[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "Date: Tue, 17 Nov 2009 23:45:22 GMT[\r][\n]"
>> [read 4: seda://processelements] header                         DEBUG <<
>> "[\r][\n]"
>> [read 4: seda://processelements] HttpMethodDirector             DEBUG
>> Authorization required
>> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
>> Supported authentication schemes in the order of preference: [ntlm,
>> digest,
>> basic]
>> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
>> Challenge for ntlm authentication scheme not available
>> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
>> Challenge for digest authentication scheme not available
>> [read 4: seda://processelements] AuthChallengeProcessor         INFO
>>  basic
>> authentication scheme selected
>> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
>> Using
>> authentication scheme: basic
>> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
>> Authorization challenge processed
>> [read 4: seda://processelements] HttpMethodDirector             DEBUG
>> Authentication scope: BASIC 'localhost:443'@localhost:8443
>> [read 4: seda://processelements] HttpMethodDirector             DEBUG
>> Credentials required
>> [read 4: seda://processelements] HttpMethodDirector             DEBUG
>> Credentials provider not available
>> [read 4: seda://processelements] HttpMethodDirector             INFO  No
>> credentials available for BASIC 'localhost:443'@localhost:8443
>> [read 4: seda://processelements] HttpProducer                   DEBUG
>> Http
>> responseCode: 401
>> ...
>>
>>
>> This is normal? May be any workaround, when I dont need to set
>> user/password
>> in code?
>>
>> camel-version: 2.0-M3
>>
>> Regards,
>> Ernold Vasiliev
>>
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/http-component-with-basic-authentication-when-use-HTTP_URI-tp26399992p26399992.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/http-component-with-basic-authentication-when-use-HTTP_URI-tp26399992p26412528.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: http component with basic authentication when use HTTP_URI

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What is your problem?
username and password must be supplied on the endpoint for HTTP Basic Auth.

If you need dynamic behavior use the dynamic recipient list EIP pattern
http://camel.apache.org/recipient-list.html

On Wed, Nov 18, 2009 at 12:49 AM, Eric V. <er...@mail.ru> wrote:
>
> When I use basic authentication with http(s) component I can't set
> user/password in HTTP_URI header. Authentication work only if credentials
> set in endpoint URI, e.g.:
>         ...
>        .setHeader("CamelHttpMethod", constant("GET"))
>        .setHeader("CamelHttpUri", body().convertTo(String.class))
>        .to(ExchangePattern.InOut,
> "https://localhost:8443?username=guest&password=guest")
>
> It's code will work. Here uri get from previous message and user/password
> from endpoint URI. If I remove user/password from endpoint URI it's dont
> work (credentials from HTTP_URI dont send to http server):
>         ...
>        .setHeader("CamelHttpMethod", constant("GET"))
>        .setHeader("CamelHttpUri", body().convertTo(String.class))
>        .to(ExchangePattern.InOut, "https://localhost:8443")
>
> Log:
> ...
> [read 4: seda://processelements] HttpMethodBase                 DEBUG Adding
> Host request header
> [read 4: seda://processelements] header                         DEBUG >>
> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG >>
> "Host: localhost[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG >>
> "[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "HTTP/1.1 401 Unauthorized[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "HTTP/1.1 401 Unauthorized[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Server: Apache-Coyote/1.1[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Pragma: No-cache[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Cache-Control: no-cache[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Expires: Thu, 01 Jan 1970 03:00:00 MSK[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "WWW-Authenticate: Basic realm="localhost:443"[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Content-Type: text/html;charset=utf-8[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Content-Length: 954[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "Date: Tue, 17 Nov 2009 23:45:22 GMT[\r][\n]"
> [read 4: seda://processelements] header                         DEBUG <<
> "[\r][\n]"
> [read 4: seda://processelements] HttpMethodDirector             DEBUG
> Authorization required
> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
> Supported authentication schemes in the order of preference: [ntlm, digest,
> basic]
> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
> Challenge for ntlm authentication scheme not available
> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
> Challenge for digest authentication scheme not available
> [read 4: seda://processelements] AuthChallengeProcessor         INFO  basic
> authentication scheme selected
> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG Using
> authentication scheme: basic
> [read 4: seda://processelements] AuthChallengeProcessor         DEBUG
> Authorization challenge processed
> [read 4: seda://processelements] HttpMethodDirector             DEBUG
> Authentication scope: BASIC 'localhost:443'@localhost:8443
> [read 4: seda://processelements] HttpMethodDirector             DEBUG
> Credentials required
> [read 4: seda://processelements] HttpMethodDirector             DEBUG
> Credentials provider not available
> [read 4: seda://processelements] HttpMethodDirector             INFO  No
> credentials available for BASIC 'localhost:443'@localhost:8443
> [read 4: seda://processelements] HttpProducer                   DEBUG Http
> responseCode: 401
> ...
>
>
> This is normal? May be any workaround, when I dont need to set user/password
> in code?
>
> camel-version: 2.0-M3
>
> Regards,
> Ernold Vasiliev
>
>
>
> --
> View this message in context: http://old.nabble.com/http-component-with-basic-authentication-when-use-HTTP_URI-tp26399992p26399992.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus