Re: Principal in a servlet

Woonsan Ko <[email protected]> Fri, 4 Jan 2013 07:09:24 -0800 (PST)
Newsgroups gmane.comp.jakarta.jetspeed.user
Message-ID <[email protected]>
Hi Michael,

I don't know why it works in Jetspeed 2.1.3, but basically if a request is made on a servlet in a *portlet* application directly, then I don't think you can get a user principal through request.
You will probably get a user principal from a servlet in the Jetspeed *portal* application if you're authenticated. That's because Jetspeed-2 uses the standard JAAS LoginModule in the Jetspeed *portal* application.
Or, if your servlet in the portlet application is dispatched by a portlet somehow, then it will be possible to get the user principal because the servlet request is a wrapper of the portlet request.
As the last option, if it is possible, you might want to set an application scope session attribute in a portlet before navigating the servlet.

Regards,

Woonsan




>________________________________
> From: Jetspeed Binette <[email protected]>
>To: Jetspeed Users List <[email protected]> 
>Sent: Wednesday, January 2, 2013 10:17 AM
>Subject: Principal in a servlet
> 
>In Jetspeed 2.1.3 I have a servlet that uses request.getUserPrincipal() to
>determine if their is someone logged into Jetspeed or not. It works
>perfectly.
>
>I am in the process of upgrading to Jetspeed 2.2.2 and this is no longer
>working. The request.getUserPrincipal() always returns null now. Is there
>some configuration setting I need to change to get the principal to
>populate in the standard servlet request? The servlet is running in the
>same application as my portlets and I can see my other session attributes.
>
>Is there some other way to determine if the user is logged in from a
>servlet?
>
>--
>Michael Binette
>
>
>