Re: Basic Authentication!

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 UTC