Return-Path: Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 18936 invoked by uid 98); 16 Jan 2003 04:32:25 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 18917 invoked from network); 16 Jan 2003 04:32:23 -0000 Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142) by nagoya.betaversion.org with SMTP; 16 Jan 2003 04:32:23 -0000 Received: (qmail 15851 invoked by uid 500); 16 Jan 2003 04:30:53 -0000 Received: (qmail 15842 invoked from network); 16 Jan 2003 04:30:53 -0000 Received: from mxout1.cac.washington.edu (140.142.32.134) by daedalus.apache.org with SMTP; 16 Jan 2003 04:30:53 -0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.9]) by mxout1.cac.washington.edu (8.12.1+UW01.12/8.12.1+UW02.12) with ESMTP id h0G4V1pG021563 for ; Wed, 15 Jan 2003 20:31:01 -0800 Received: from u.washington.edu (pool-129-44-172-186.bos.east.verizon.net [129.44.172.186]) (authenticated bits=0) by smtp.washington.edu (8.12.1+UW01.12/8.12.1+UW02.12) with ESMTP id h0G4Uxuo009303 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=NOT) for ; Wed, 15 Jan 2003 20:31:00 -0800 Date: Wed, 15 Jan 2003 23:30:58 -0500 Subject: Re: SSL and BasicAuth Example Content-Type: multipart/mixed; boundary=Apple-Mail-2--40251390 Mime-Version: 1.0 (Apple Message framework v551) From: Michael Becke To: "Commons HttpClient Project" In-Reply-To: <3F993CDA6B58E744A2F37C8BE9B01FDDEE9059@LM-EXMSG-03.lm.lmig.com> Message-Id: <4F2910AA-290B-11D7-86E5-00306557E112@u.washington.edu> X-Mailer: Apple Mail (2.551) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --Apple-Mail-2--40251390 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed John, Attached is an example that uses basic authentication. Please let me know if you have any questions. Mike --Apple-Mail-2--40251390 Content-Disposition: attachment; filename=BasicAuthenticatonExample.java Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="BasicAuthenticatonExample.java" import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.methods.GetMethod; /** * A simple example that uses HttpClient to perform a GET using Basic * Authentication. */ public class BasicAuthenticatonExample { /** * Constructor for BasicAuthenticatonExample. */ public BasicAuthenticatonExample() { super(); } public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); // pass our credentials to HttpClient, they will only be used for // authenticating to servers with realm "realm" client.getState().setCredentials( "realm", new UsernamePasswordCredentials( "username", "password" ) ); // create a GET method that reads a file over HTTPS, we're assuming // that this file requires basic authentication using the realm above. GetMethod get = new GetMethod( "https://host/path/file.html" ); // Tell the GET method to automatically handle authentication. The // method will use any appropriate credentials to handle basic // authentication requests. Setting this value to false will cause // any request for authentication to return with a status of 401. // It will then be up to the client to handle the authentication. get.setDoAuthentication( true ); // execute the GET int status = client.executeMethod( get ); // print the status and response System.out.println( status + "\n" + get.getResponseBodyAsString() ); // release any connection resources used by the method get.releaseConnection(); } } --Apple-Mail-2--40251390 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Wednesday, January 15, 2003, at 06:00 PM, Alden, John wrote: > Basic Authorization --Apple-Mail-2--40251390--