You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Huis in 't Veld, Peter" <Pe...@logicacmg.com> on 2003/04/17 10:20:12 UTC

FW: Problem with NTLM and ISA server - Microsoft proxy

> Hi There,
> 
> I've the following problem:
> 
> I'd like to scrape a htttps website through a ISA server. So I tried this
> by using HTTPClient (rel 2 alpha3). The problem is, I think, I can't get
> through the proxy. Can someone  give some suggestions on this one, see
> loggings below?
> 
> logging:
> 
> C:\EAN_SCRAPER\src>java BasicTest
> Proxy set
> GetMethod object
> 16-Apr-2003 17:30:48 org.apache.commons.httpclient.Authenticator ntlm
> INFO: No credentials for specific host, attempting to use default
> credentials.
> 16-Apr-2003 17:30:48 org.apache.commons.httpclient.HttpMethodBase
> processAuthen
> icationResponse
> WARNING: No credentials available for NTLM authentication.
> execute method
> Exception in thread "main" java.lang.NullPointerException
>         at BasicTest.main(BasicTest.java:37)
> 
> 
> source:
>    
> import java.security.Security;
> import org.apache.commons.httpclient.Credentials;
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.*;
> import org.apache.commons.httpclient.HttpMethod;
> import org.apache.commons.httpclient.NTCredentials;
> 
> public class BasicTest{
> 
> public static void main (String args[]) throws Exception{
>     Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
>  
> System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.
> www.protocol");
> 
>     HttpClient client = new HttpClient();
>       
>     client.setConnectionTimeout(60000);     
>     client.getState().setProxyCredentials(null, new NTCredentials("user",
> "password","proxy","domain"));
> 
>     client.getHostConfiguration().setProxy("proxy", 8080); 
>     System.out.println("Proxy set");
>     GetMethod httpget = new
> GetMethod("https://www.verisign.com/products/index.html");
>     System.out.println("GetMethod object");
>     httpget.setFollowRedirects(true);
>         httpget.setStrictMode(false); 
> 
>     httpget.setDoAuthentication(true); 
> 
>     client.executeMethod(httpget); 
>     System.out.println("execute method");
> 
>     // print the status 
>     System.out.println("Response: " + httpget.getStatusLine().toString());
> 
>     // release any connection resources used by the method
>     httpget.releaseConnection();
>     } 
> }

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.

Re: FW: Problem with NTLM and ISA server - Microsoft proxy

Posted by Adrian Sutton <ad...@intencha.com>.
Hi Peter,
It's very hard to see what's going wrong here because the logging isn't  
detailed enough.  Could you try running through the trouble shooting  
tips at  
http://jakarta.apache.org/commons/httpclient/troubleshooting.html and  
send through the output of each suggested step.  Most important is the  
wire trace and debug log - there are instructions at  
http://jakarta.apache.org/commons/httpclient/logging.html

You should also read through  
http://jakarta.apache.org/commons/httpclient/authentication.html if you  
haven't already as it outlines some of the gotchas of NTLM  
authentication.

Looking at the code though I think you're problem is that you are not  
actually setting the proxy (at least not in the right place anyway). :)  
  I could be wrong about this, but I would have thought that:
>>
>>     client.getHostConfiguration().setProxy("proxy", 8080);

would be ignored, since the HostConfiguration in use will be the one  
from the get method (since you specified a complete URL).  I would have  
either used client.getState().setProxyHost("proxy") if that method  
still exists or set the proxy on the host configuration from the  
method.  If that doesn't help the wire trace should show up what's  
going on.

Regards,

Adrian Sutton.

On Thursday, April 17, 2003, at 06:20  PM, Huis in 't Veld, Peter wrote:

>
>> Hi There,
>>
>> I've the following problem:
>>
>> I'd like to scrape a htttps website through a ISA server. So I tried  
>> this
>> by using HTTPClient (rel 2 alpha3). The problem is, I think, I can't  
>> get
>> through the proxy. Can someone  give some suggestions on this one, see
>> loggings below?
>>
>> logging:
>>
>> C:\EAN_SCRAPER\src>java BasicTest
>> Proxy set
>> GetMethod object
>> 16-Apr-2003 17:30:48 org.apache.commons.httpclient.Authenticator ntlm
>> INFO: No credentials for specific host, attempting to use default
>> credentials.
>> 16-Apr-2003 17:30:48 org.apache.commons.httpclient.HttpMethodBase
>> processAuthen
>> icationResponse
>> WARNING: No credentials available for NTLM authentication.
>> execute method
>> Exception in thread "main" java.lang.NullPointerException
>>         at BasicTest.main(BasicTest.java:37)
>>
>>
>> source:
>>
>> import java.security.Security;
>> import org.apache.commons.httpclient.Credentials;
>> import org.apache.commons.httpclient.HttpClient;
>> import org.apache.commons.httpclient.methods.GetMethod;
>> import org.apache.commons.httpclient.methods.*;
>> import org.apache.commons.httpclient.HttpMethod;
>> import org.apache.commons.httpclient.NTCredentials;
>>
>> public class BasicTest{
>>
>> public static void main (String args[]) throws Exception{
>>     Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
>>
>> System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.inter 
>> nal.
>> www.protocol");
>>
>>     HttpClient client = new HttpClient();
>>
>>     client.setConnectionTimeout(60000);
>>     client.getState().setProxyCredentials(null, new  
>> NTCredentials("user",
>> "password","proxy","domain"));
>>
>>     client.getHostConfiguration().setProxy("proxy", 8080);
>>     System.out.println("Proxy set");
>>     GetMethod httpget = new
>> GetMethod("https://www.verisign.com/products/index.html");
>>     System.out.println("GetMethod object");
>>     httpget.setFollowRedirects(true);
>>         httpget.setStrictMode(false);
>>
>>     httpget.setDoAuthentication(true);
>>
>>     client.executeMethod(httpget);
>>     System.out.println("execute method");
>>
>>     // print the status
>>     System.out.println("Response: " +  
>> httpget.getStatusLine().toString());
>>
>>     // release any connection resources used by the method
>>     httpget.releaseConnection();
>>     }
>> }
>