users@glassfish.java.net

Re: encoding problem in Basic Authentication

From: <Ronald.Monzillo_at_Sun.COM>
Date: Mon, 25 Jan 2010 18:55:21 -0500

On 01/23/10 13:35, Felipe Gaścho wrote:
> I have a Basic Authentication working fine on a Linux machine, but
> doesn't in a windows machine... why ?
>
>
Hi Felipe,

Are you just using the Basic Authenticator of the Glassfish servlet
container, (i.e.,
just setting auth-method to BASIC in login-confiig) ..

or are you doing something more sophisticated
(perhaps such as defining and implementing your own Server Auth Module)?

What is your setup, as in what type of machine is your web container
running on,
and what type of machine is trying to access it?

what realm is configured for your web application?
> I suspect it is an encoding problem since the server working on
> windows should receive the authentication values in Cp1252 while the
> Linux one receive in UTF-8 ...
>
> where to start checking that ?
>
If you are using the BasicAuthenticator of the Glassfish Servlet
container, and you setup a debugger
with the Glassfish srcs, then the simplest thing to do, would probably
be to set breakpoints
in the org.apache.catalina.authenticator.BasicAuthenticator; and see
what values the server is receiving from
the client. The username and password will be Base64 encoded, but the
Authenticator, decodes the
base64 encoding so you should be able to see the values that come in
from the client.

In support of your character set concern, note that the Authenticator
use String.getBytes without specifying a target charset, to convert the
String
username and password values obtained from the Http Authorization header
into
a byte array for comparison to the values obtained from the realm.

Ron
>
>
>