Sorry, I forgot to paste the code:
Hashtable users = new Hashtable();
users.put("jashuan:fala", "allowed");
String auth = request.getHeader("Authorization");
System.out.println("auth string is "+auth);
if( auth != null) {
auth = auth.substring(6);
sun.misc.BASE64Decoder b64d = new sun.misc.BASE64Decoder();
auth = new String(b64d.decodeBuffer(auth));
if("allowed".equals((String)users.get(auth)))
out.println("welcome, "+users.get(auth));
else
out.println("this user "+auth+" not allowed to
access, sorry.");
}
else{
response.setStatus(response.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "BASIC
realm=\"users\"");
}
out is the PrintWriter object.
When I invoke this page, it does make the browser popup a small
authorization window, after I type in the username and password exactly like
I stored in the Hastable, the String auth still null. The authorization
window did not disappear. Any body has any ideas?
Thanks in advance.
Jashua Ni
-----Original Message-----
From: Jashua Ni [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 27, 2000 3:27 PM
To: [EMAIL PROTECTED]
Subject: Re: Basic authentication through bowsers.
Hi, All:
I tried the basic authentication like the following, when I invoke the page,
it does make the browser pop up a small authentication window, but after I
type in the name and password,
String auth = request.getHeader("Authorization"); always null.
Can any body please tell me what wrong? Thanks a lot!
Jashua Ni
email: [EMAIL PROTECTED]
tel: 212-883-6940 ext. 138
___________________________________________________________________________
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