OK, I have the proxy working.
Now I think I have a redirect problem. I've read in the documentation HttpClient automatically handles redirects however I'm getting response which looks like this: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="https://www.server.com/path/">here</A>.<P> </BODY></HTML> ________________________________ From: Oleg Kalnichevski <[email protected]> To: Michael Remijan <[email protected]> Cc: HttpClient User Discussion <[email protected]> Sent: Friday, September 9, 2011 11:43 AM Subject: Re: Confused about target host and proxy authentication 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 <[email protected]> > To: Michael Remijan <[email protected]> > Cc: HttpClient User Discussion <[email protected]> > 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 <[email protected]> > > To: Michael Remijan <[email protected]> > > Cc: HttpClient User Discussion <[email protected]> > > 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 <[email protected]> > > > To: Michael Remijan <[email protected]> > > > Cc: HttpClient User Discussion <[email protected]> > > > 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: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
