Hi,

You have to read the Authorization header like this:
String header=req.getHeader("Authorization");
String enc=header.substring(6);
String username=new String();
 String password=new String();
 sun.misc.BASE64Decoder b64d=new sun.misc.BASE64Decoder();
 String decodedstring=new String(b64d.decodeBuffer(enc));
 if(decodedstring==null) return 0;
 if(decodedstring.indexOf(":")==-1) return 0;
 username=decodedstring.substring(0,decodedstring.indexOf(":"));
 password=decodedstring.substring(decodedstring.indexOf(":")+1);

Hope it helps a little bit,

        Andras.


----- Original Message -----
From: Michael P. Newcomb <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 23, 2000 9:41 PM
Subject: www-authentication


> I'm trying to user WWW-Authentication with my servlet.  Basically, I can
get
> the client to pop up a user-password window, but I can't get that
> information from the HttpServletRequest object.  This is what I am using
to
> test...
>
>
> String remote_user = req.getRemoteUser();
> if(remote_user == null || remote_user.equals(""))
> {
>   resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
>   resp.setHeader("WWW-Authenticate", "Basic realm=\"Mike's World of Test
> Servlet"\"");
> }
>
> In the first iteration, I expect remote_user to be null or "".  I then set
> the authenticate header.  Then the client browser pops up the
user-password
> window.  I type something in and hit OK.  I now am expecting the
remote_user
> to be non-null and not "".  However, this doesn't happen and remote_user
is
> always null.  How do I get the information out of the request object.
>
> Michael
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to