hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shahbaz Khalid <shahbaz_khali...@yahoo.com>
Subject RE: NTLM Proxy Authentication
Date Tue, 18 Feb 2003 21:58:38 GMT
Hi Adrian,

Here is the code I am using at the moment... (I hope
you can put it in notepad and see if the tabs are ok)

   
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");

     
System.setProperty("org.apache.commons.logging.simplelog.showdatetime",
"true");

     
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"trace");

      Security.addProvider (new
cryptix.jce.provider.CryptixCrypto());

  
      HttpClient client = new HttpClient();
      NTCredentials cred = new
NTCredentials("logonid", "pass", "Machinename",
"Domain");
      HostConfiguration host = new
HostConfiguration();
      host.setProxy("proxyhost.com",80);
      host.setHost("www.google.com", 80, "http");
      client.setHostConfiguration(host);
      
      // for the realm parameter of the following
method, if I set it to the proxy realm/ip, it
      // still looks for the HOST (please look at the
Authenticator class method,
      // which will be www.google.com in my case...
why does it search 
      // against the host, and not against the proxy
realm that I pass in ? If I put www.google.com
      // as a parameter instead of null, it works fine
- Bizarre !!! Well, I now make it work
      // by putting in null, but I don't like it. 
      client.getState().setProxyCredentials(null,
cred);
      HttpMethod method = new GetMethod();
      
      client.executeMethod(method);
      System.out.println(method.getStatusCode() +
method.getResponseBodyAsString());

      // try to reuse method
      method.releaseConnection();
      method.recycle();
      
      // try another request on same connection... 
      // Hmm... getting authenticated again :o( and in
first try of the NTLM auth loop (authenticator),
      // I get an exception (connection reset by peer)
     
method.setPath("/advanced_search?q=HTTP+status+403&hl=en&lr=&ie=UTF-8&oe=UTF-8");
      ((HttpMethodBase)method).setHttp11(true);
      method.setRequestHeader("Connection",
"Keep-Alive");
      System.out.println("isHttp11 " +
((HttpMethodBase)method).isHttp11());
      client.executeMethod(method);
      System.out.println(method.getStatusCode() +
method.getResponseBodyAsString());

I had to leave early from work so I couldnt bring the
logs with me, will try to bring it tomorrow.

Hope you can give some advice with regards to the
above.

best regards, Shahbaz

 --- Adrian Sutton <adrian.sutton@ephox.com> wrote: >
Hi Shahbaz,
> The HttpClient codebase has changed a fair bit since
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Mime
View raw message