Topic
  • 3 replies
  • Latest Post - ‏2012-11-09T04:42:27Z by dips82
dips82
dips82
92 Posts

Pinned topic WebSphere Portal Explicit Login Filter - getUserprincipal returns null

‏2012-10-02T02:06:47Z |
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
    SystemAdmin
    30895 Posts

    Re: WebSphere Portal Explicit Login Filter - getUserprincipal returns null

    ‏2012-10-02T08:07:18Z  
    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:
    http://www.ibm.com/developerworks/websphere/library/techarticles/0905_buchwald/0905_buchwald.html

    Sven

    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
  • dips82
    dips82
    92 Posts

    Re: WebSphere Portal Explicit Login Filter - getUserprincipal returns null

    ‏2012-10-02T23:14:04Z  
    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:
    http://www.ibm.com/developerworks/websphere/library/techarticles/0905_buchwald/0905_buchwald.html

    Sven

    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
    Excellent Sven. I will start working with PUMA API code.
  • dips82
    dips82
    92 Posts

    Re: WebSphere Portal Explicit Login Filter - getUserprincipal returns null

    ‏2012-11-09T04:42:27Z  
    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:
    http://www.ibm.com/developerworks/websphere/library/techarticles/0905_buchwald/0905_buchwald.html

    Sven

    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
    Hi Sven,

    I tried an alternative solution. I am using portal version 6.1.0.6. 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 6.1.0.5 and in 6.1.0.5 libraries the getWorkspace(User user) method is not available. Therefore I am getting compilation error when I compile my ocde using 6.1.0.5 libraries. The only available method in 6.1.0.5 is getWorkspace(Principal principal). Now I don't know how do I get WCM workspace inside login filter class. Any help is much appreciated.