[email protected] 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to