users@glassfish.java.net

Re: Doubt about Container managed authentication

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Tue, 29 Aug 2006 08:55:17 -0700

Legolas Woodland wrote On 08/29/06 05:17,:

> 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 ?


The authenticated user may be retrieved using these
javax.servlet.http.HttpServletRequest methods:

    public String getRemoteUser();
    public java.security.Principal getUserPrincipal();

Hope this answers your question.

Jan

>
> 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