hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rowe, David (CAG-CC MIS)" <David.Ro...@conagrafoods.com>
Subject NTLM Auth Code Snippet
Date Tue, 12 Aug 2003 21:00:58 GMT
public class Authentication
{
    public Authentication() { }

    public static void main(String[] args) throws Exception 
    {
	System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");

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

	System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"debug"); 
    	
      HttpClient client = new HttpClient();
		
	client.getHostConfiguration().setProxy("[our proxy]", 80);
        
      client.getState().setProxyCredentials(null,null,
      	new NTCredentials("[user name]", "[password]", "[our proxy]", "[domain]")
      );
             
      GetMethod get = new GetMethod("http://www.yahoo.com");

      get.setDoAuthentication( true );
      
	int status = client.executeMethod( get );
      
	System.out.println(status + "\n" + get.getResponseBodyAsString());
      
	get.releaseConnection();
    }
}


Supposedly this should Authenticate through the proxy, and output Yahoo!'s website.

If you can see anything that is needed please respond...

David Rowe
ConAgra Foods, Inc.
Web Application Development - Intern
7350 World Communications Drive
Omaha, NE  68122
Phone: (402) 998-2722
David.Rowe2@conagrafoods.com


Mime
View raw message