hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <nagamallika.gunt...@belgacom-ics.com>
Subject RE: using HttpClient4.0 to retrieve files from a website.
Date Mon, 26 Oct 2009 13:34:58 GMT
Hi Oleg,

Thanks again for the quick response.

Even after reading the two links you sent across, I don't see any difference in my sample
code and what is said there. However, I am not able to go beyond proxy.

I get the same error message "HTTP/1.1 407 Proxy Authentication Required ( The ISA Server
requires authorization to fulfill the request. Access to the Web Proxy filter is denied. 
)" in all the following cases:

a) When no user credentials are set for the proxy
b) When an incorrect user/password is set for proxy credentials
c) When proper user credentials are set

Hence, I deduce that somehow the credentials that I am setting on the proxy are not used.
This issue is now on the critical path of the project and your support is highly appreciated.

Thanks and Regards
Mallika

-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: 26 October 2009 14:00
To: HttpClient User Discussion
Subject: Re: using HttpClient4.0 to retrieve files from a website.

nagamallika.gunturu@belgacom-ics.com wrote:
> Thanks for the response.
> 
> I have changed my code as suggested in http://hc.apache.org/httpcomponents-client/ntlm.html
and now, I just have the following message:
> 
> 
> HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to
fulfill the request. Access to the Web Proxy filter is denied.  )
> 
> Here is my complete code:
> 
> DefaultHttpClienthttpclient = new DefaultHttpClient();
> HttpContext localContext = new BasicHttpContext();
> HttpGet httpget = new HttpGet("targetURL");
> 
> AuthScope proxyScope = new AuthScope(proxyHost, proxyPort);
> AuthScope targetScope = new AuthScope(targetHost, targetPort);
> 
> AuthState proxyAuthState = new AuthState();
> proxyAuthState.setAuthScope(proxyScope);
> proxyAuthState.setCredentials(new NTCredentials(proxyUser, proxypassword, localworkstation,
Domain) );localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState);
> 
> AuthState targetAuthState = new AuthState();
> targetAuthState.setAuthScope(targetScope);
> targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, webSitePassword)
);
> localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState);
> 
> HttpHost proxy = new HttpHost(proxyHost, proxyPort);
> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
> httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
> 
> HttpResponse response =  null;
> HttpHost targetHost = new HttpHost(targetHost, targetPort, "https");
> try {
> response  = httpclient.execute(targetHost, httpget);
>      System.out.println("----------------------------------------");
> System.out.println(response.getStatusLine());
> }
> catch(Exception e) {
> System.out.println("Exception " + e.toString());
> 
> }
> 
> Can you please help on this?
> 


http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
http://hc.apache.org/httpcomponents-client/tutorial/html/authentication.html

Oleg

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


**** DISCLAIMER****
http://www.belgacom-ics.com/maildisclaimer

---------------------------------------------------------------------
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