hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Confused about target host and proxy authentication
Date Fri, 09 Sep 2011 16:43:49 GMT
On Fri, 2011-09-09 at 07:32 -0700, Michael Remijan wrote:
> Unfortunately, the proxy connection is still not working.  I'm in the position where
I guess I have to use an NTLM proxy.  This proxy does not require authentication (for example,
I can configure my web browser to point to proxy.server.com:8080 and the web browser connects
fine)  However, whenever I try to do this from my Java app, I always get a "access denied"
page from the proxy.  Here is what I've tried for my HttpClient proxy configuration:
> 
>                 HttpHost proxy 
>                     = new HttpHost("proxy.server.com", 8080);
> 
>                 httpClient.getParams().setParameter(
>                     ConnRoutePNames.DEFAULT_PROXY, proxy
>                 );
> 
> 
>                 AuthScope authScope = new AuthScope("proxy.server.com", 8080, "[REALM]",
"ntlm");
>                 Credentials credentials = new NTCredentials("[MY_NT_USERNAME]", "[MY_NT_PASSWORD]",
"[WORKSTATION]", "[DOMAIN]");
>                 httpClient.getCredentialsProvider().setCredentials(
>                         proxyAuthScope, proxyCredentials
>                 );
> 
> 
> Now, I'm not exactly sure what the exact values are suppose to used for "[REALM]", "[MY_NT_USERNAME]",
"[MY_NT_PASSWORD]", "[WORKSTATION]", and "[DOMAIN]", but I have tried a number of different
combinations and have yet to hit a working solution.
> 

You'd better be sure because if any of those is wrong authentication
will fail.

> Any additional thoughts?
> 

Use wire / context logging to examine HTTP packets generated by
HttpClient and see whether the proxy requests the user to authenticate,
whether or not HttpClient attempts authentication and what kind of
response the proxy returns.

http://hc.apache.org/httpcomponents-client-ga/logging.html

Oleg


> 
> 
> ________________________________
> From: Oleg Kalnichevski <olegk@apache.org>
> To: Michael Remijan <mjremijan@yahoo.com>
> Cc: HttpClient User Discussion <httpclient-users@hc.apache.org>
> Sent: Thursday, September 8, 2011 4:57 PM
> Subject: Re: Confused about target host and proxy authentication
> 
> On Thu, 2011-09-08 at 12:36 -0700, Michael Remijan wrote:
> > Do you call
> > 
> > httpclient.getCredentialsProvider().setCredentials(..)
> > 
> > multiple times then for however many credentials you have?
> > 
> > 
> 
> Absolutely. HttpClient will make use of them as needed.
> 
> Oleg
> 
> > 
> > 
> > 
> > 
> > 
> > ________________________________
> > From: Oleg Kalnichevski <olegk@apache.org>
> > To: Michael Remijan <mjremijan@yahoo.com>
> > Cc: HttpClient User Discussion <httpclient-users@hc.apache.org>
> > Sent: Thursday, September 8, 2011 2:11 PM
> > Subject: Re: Confused about target host and proxy authentication
> > 
> > On Thu, 2011-09-08 at 11:30 -0700, Michael Remijan wrote:
> > > 
> > > I'm sorry, I forgot to include that information...
> > > 
> > >     <dependency>      
> > >       <groupId>org.apache.httpcomponents</groupId>
> > >       <artifactId>httpclient</artifactId>
> > >       <version>4.1.2</version>
> > >     </dependency>
> > > 
> > > 
> > 
> > Then, I am not sure I understand the problem. All you have to do is to
> > configure the auth credentials provider with two sets of credentials
> > (one or target server and another one for the proxy) as described here
> > [1] and HttpClient will take care of the rest. 
> > 
> > Oleg
> > 
> > [1]
> > http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d4e971

> > 
> > 
> > 
> > 
> > > 
> > > ________________________________
> > > From: Oleg Kalnichevski <olegk@apache.org>
> > > To: Michael Remijan <mjremijan@yahoo.com>
> > > Cc: HttpClient User Discussion <httpclient-users@hc.apache.org>
> > > Sent: Thursday, September 8, 2011 1:22 PM
> > > Subject: Re: Confused about target host and proxy authentication
> > > 
> > > On Thu, 2011-09-08 at 10:15 -0700, Michael Remijan wrote:
> > > > I am working in an environment where I need to specify a proxy as well
as login to the proxy.  After I have the connection to the proxy, I then need to also provide
BASIC authentication to target host I'm contacting. I'm confused how to do this configuration.
 I have followed the examples and I know how to get a non-authenticating proxy to work and
I have also followed the examples to provide BASIC authentication to my target host.  In my
case the usernames/passwords for both are different so I'm confused how to provide authenticating
information for the proxy as well.  Any help would be appreciated.
> > > 
> > > What version of HttpClient are you using?
> > > 
> > > Oleg
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message