Ok, I think you are right about dependency with portal container vendor, however it is not logical at all, while JSR-168 is trying to unify and standardize portlet development, why shouldn't such an important feature of portal be standardized?
any way let's say uPortal. How to do that in uPortal?
Thank you so much
Message was edited by:
den2Fly
There is a standard way to access users. It requires adding the user attributes you would like to access to the portlet.xml file and then accessing them with the following code:
Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO);
To learn more, go to http://www.manning.com/hepper/. Read the download instructions and download your free version of the book "Portlets and Apache Portals". There is a section of the book called "Accessing User Attributes" which has the info you need.
Let me know if you get it to work!!!
It is easier to access user info with the specific portal APIs, but it makes your code less portable.
Thanks,
Dean
Thank you for your reply, It is a great step forward, But what if I have my users in a table in database and what I need is authenticated username by portal. Then I can map that username to a user in my database.
Is there some method that returns authenticated username by portal ?
Thank you
The information I previously posted will give you exactly what you're looking for.
The code Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO);
will give you information about the current user.
The trick with creator is getting to the PortletRequest object. Check out the following blog to see how this is done: http://blogs.sun.com/roller/page/david?entry=java_studio_creator_portlets_under
Just remember to update the portlet.xml file as described in the book I referenced. Perhaps some members of the creator team will help identify what should go into the portlet.xml file (hint hint)?