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

getting the basic auth-name

From: Anselm Baird_Smith <abaird@www43.inria.fr>
Date: Tue, 21 Jan 1997 11:14:49 +0100 (MET)
Message-Id: <199701211014.LAA06591@www43.inria.fr>
To: "S. Alexander Jacobson" <alex@interband.com>
Cc: www-jigsaw@www10.w3.org
S. Alexander Jacobson writes:
 > Hi,
 > 
 > I want to create a resource that simply prints the name of the auth-user
 > if it is behind a genericAuthFilter.
 > 
 > Ideally I would like a method like access to the complete AuthUser for the
 > current request.
 > 
 > I have looked through the documentation and found no elegant way to do
 > that other than uudecode the authorization mime header.  I have to assume
 > that someone has already implemented a better solution.

[I guess my mail arrived out of order]
Here is what you are looking for (mail quality code):

public AuthDisplay extends FilteredResource {

    public Reply get(Request request)
        throws HTTPException
    {
        Reply  reply = createDefaultReply(request, HTTP.OK);
        String u = null;
        u = request.getState(w3c.www.jigsaw.auth.AuthFilter.STATE_SUATHUSER);
        reply.setContent((u == null) ? "no user" : u);
        return reply;
    }

}

Pretty easy, isn't it :-)

Anselm.
Received on Tuesday, 21 January 1997 05:15:00 GMT

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