camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ben (JIRA)" <>
Subject [jira] Commented: (CAMEL-3779) HttpProducer drops authentification parameters.
Date Fri, 11 Mar 2011 11:08:59 GMT


ben commented on CAMEL-3779:

Hi Claus, 

thanks for the fast reply. 

Is username and password parameters you must send to the remote server?
Or part of authentication using eg BASIC on the http client?

The username and password parameters are needed for BASIC authentication via the http client.

Can you try with camel-http instead of camel-http4 component?
Yes, with the same result: no authentification scheme is provided with the request. 

Is there any way to provide this information into the http client? 
E.g. via addional header information in the Exchange, like:
Exchange.HTTP_AUTHTIFICATION_SCHEMA| Basic, Digest, Ntml|
Exchange.HTTP_USENAME | the username for the HTTP request |
Exchange.HTTP_PASSWORD| the password for the HTTP request|
Exchange.HTTP_Domain| for NTML authentication |
Exchange.HTTP_AUTH_HOST| Optional host for NTML authentication |
Exchange.HTTP_PROXY_HOST | the proxy to use |
Exchange.HTTP_PROXY_AUTH_METHOD | the auth. scheme for the proxy |
Exchange.HTTP_PROXY_USERNAME | the username for the proxy |
Exchange.HTTP_PROXY_PASSWORD |the password for the proxy |

If you like, I can implement such a solution. 


> HttpProducer drops authentification parameters.
> -----------------------------------------------
>                 Key: CAMEL-3779
>                 URL:
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-http
>    Affects Versions: 2.6.0
>            Reporter: ben
> Hi, 
> I run into the following problem with Camel 2.6.0:
> An HTML file contain an URI lists of files to be downloaded from a web server to the
local file system.
> The HTML file is parsed via a Java Bean Splitter. The Java Bean Splitter produces a Set
of URI strings.
> These files should be downloaded from a web server to the local file system. The files
are protected with BASIC authentification.
> The extraction and the splitting of the download URIs works quite well with the Java
Bean Splitter.
> The Java Bean Splitter produces URI like: 
> {code}http4://{code}
> Here's the setup:
> {code}
> <route>
>    <from uri="file:///tmp/files_to_retrieve/" />
>    <method bean="prepareDownLoadUri" method="parseIndexHtml" />
>    <setHeader headerName="CamelHttpMethod">
>      <constant>GET</constant>
>    </setHeader> 
>    <setHeader headerName="CamelHttpUri">
>      <simple>${body}</simple>
>    </setHeader>
>    <to uri="http4://" />
>    <to uri="bean:saveFileProcessor" />
> </route>
> <bean id="prepareDownLoadUri" class="com.acme.PrepareDownLoadUri" />
> <bean id="saveFileProcessor" class="com.acme.SaveFileProcessor" />
> {code}
> The injection of the URIs from the Splitter into the HttpProducer, works quite well.

> I debugged into the HttpProducer and it seems, that the HttpProducer does not provide
the unterlying http client (in this case Apache HttpClient 4) with  the authentification settings
from the URI.
> At first, the queryString is extracted from the Exchange-Header (if provided)
> {code:title=HttpProducer.createMethod(), line 273}
> String url = HttpHelper.createURL(exchange, getEndpoint());
> {code}
> The url string contains the URI produces by the splitter including the authentification
> {code}http4://{code}
> Then the HttpProducer assembles a new URI for the requests. The new URI is assembled
from parts of the string url (line 273)  
> and other parameters from the Exchange Header: 
> {code:title=HttpProducer.createMethod(), lines 285-300}
>         // is a query string provided in the endpoint URI or in a header (header overrules
>         String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
>         if (queryString == null) {
>             queryString = getEndpoint().getHttpUri().getRawQuery();
>         }
>         StringBuilder builder = new StringBuilder(uri.getScheme()).append("://").append(uri.getHost());
>         if (uri.getPort() != -1) {
>             builder.append(":").append(uri.getPort());
>         }
>         if (uri.getPath() != null) {
>             builder.append(uri.getRawPath());
>         }
>         if (queryString != null) {
>             builder.append('?');
>             builder.append(queryString);
>         }
>         HttpRequestBase httpRequest = methodToUse.createMethod(builder.toString());
> {code}
> The problem is, in the assembling of the new URI, the authentification parameters are
> One possible solution could be: 
> # check for authentification parameters in the url (line 273) and extract them.
> # build the credentials, AuthScheme and provide it to the underlying http client.
> thanks in advance,
> ben

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message