users@glassfish.java.net

Re: Doubt about Container managed authentication

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Tue, 29 Aug 2006 11:59:18 -0400

Can't you use HttpServletRequest.getRemoteUser(), getUserPrincipal()?

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html

    getRemoteUser()
          Returns the login of the user making this request, if the user
has been authenticated, or null if the user has not been authenticated.

java.security.Principal getUserPrincipal()
          Returns a java.security.Principal object containing the name
of the current authenticated user.

Cheng




Legolas Woodland wrote:

> Hi
> Thank you for reading my post
> I read in articles ant tutorial that we can use Realms + *form/basic
> *authentication to authenticate users with username/password.
> I also made a sample web application with all changes in web.xml and
> server configuration.
> Now the problem is : how can i understand which user is loged in now ?
> i mean how i can retrive current user' username ?
>
> before this i used my own authentication mechanism and i add the
> UserName to session , so i could understand the userName by looking at
> a variable in session.
> but for this container managed authentication, i do not know where to
> look at to understand the current userName.
>
> thanks