Pinned topic WebSphere Portal Explicit Login Filter - getUserprincipal returns null
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
I have written an explicit login filter in my project. I am trying to get the user principal from the http request object available as method parameter of the filter login method. Surprisingly the getUserPrincipal methods retuning null. However if we try to get the user principal from http request object available in portal theme it prints valid user principal value. What is the reaosn for that any idea? I need the user principal in my login filter code so that I can make a WCM call to get WCM workspace. Any solution from anybody would be appreciated.
Updated on 2012-11-09T04:42:27Z at 2012-11-09T04:42:27Z by dips82
SystemAdmin 110000D4XK30895 Posts
Re: WebSphere Portal Explicit Login Filter - getUserprincipal returns null2012-10-02T08:07:18ZThis is the accepted answer. This is the accepted answer.Hi Dips82,
instead of using the request user object it is recommended to use Puma API. You can call PumaProfile.getCurrentUser() on the way back of the chain. Because at the end of the chain the portal code is doing the login for the user and after that the user is retrievable.
In a web search you will find discussions and examples for PumaProfile usage/retrieval of that service in a non-portlet context.
BTW: I see you are working on filters a lot, you may be interested in this article and its samples:
The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Re: WebSphere Portal Explicit Login Filter - getUserprincipal returns null2012-11-09T04:42:27ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
I tried an alternative solution. I am using portal version 22.214.171.124. I found following syntax work inside login filter and I can get WCM workspace in filter.
WCM_API.getRepository().getWorkspace(User user) - I retrieved the User object inside my filter class using PUMA API. However unfortunately our target deployment server is portal 126.96.36.199 and in 188.8.131.52 libraries the getWorkspace(User user) method is not available. Therefore I am getting compilation error when I compile my ocde using 184.108.40.206 libraries. The only available method in 220.127.116.11 is getWorkspace(Principal principal). Now I don't know how do I get WCM workspace inside login filter class. Any help is much appreciated.