W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 1999

Re: Basic Authentication!

From: Yves Lafon <ylafon@w3.org>
Date: Thu, 28 Jan 1999 14:30:10 +0100 (MET)
To: Wolfgang Platzer <Wolfgang.Platzer@iaik.tu-graz.ac.at>
cc: Jigsaw Mailinglist <www-jigsaw@w3.org>
Message-ID: <Pine.GSO.4.05.9901281416310.22975-100000@tarantula.inria.fr>
On Thu, 28 Jan 1999, Wolfgang Platzer wrote:

> 
> I am using the Jigsaw client API like this:
> 
>  HttpManager     manager = HttpManager.getManager() ;
>  Request request = manager.createRequest() ;
>  request.setMethod(HTTP.GET) ;
>  request.setURL(new URL("http://www.w3.org/pub/WWW/"));
>  Reply    reply = manager.runRequest(request) ;
>  // Get the reply input stream that contains the actual data:
>  InputStream in = reply.getInputStream() ;
>  ...
> 
> Can anyone tell me how I can specify a username/password for accessing
> protected resources?

Here is a sample code to do that:

Base64Encoder encoder = new Base64Encoder(username+":"+password);
String        coded   = encoder.processString();

HttpCredential credential;
Base64Encoder  encoder;
	credential = HttpFactory.makeCredential("Basic");
	encoder = new Base64Encoder(username+":"+password);
	credential.setAuthParameter("cookie", encoder.processString());

        request.setAuthorization(credential);

Regards,

      /\          - Yves Lafon - World Wide Web Consortium - 
  /\ /  \        Architecture Domain - Jigsaw Activity Leader
 /  \    \/\    
/    \   /  \   http://www.w3.org/People/Lafon - ylafon@w3.org    
Received on Thursday, 28 January 1999 08:30:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:28 GMT