Creator 2 Portlet project and accessing portal authenticated user

Hello friends,I have started a portlet JSR-128 project with Creator 2.The question is how can I access the user that is authenticated thru portal single-signon feature?Thank you so much
[213 byte] By [den2Fly] at [2007-11-26 7:49:21]
# 1
I assume you mean JSR-168? I also assume you are using Sun Portal Server as your portal server of choice?I can't help, but would love to know the answer myself. So I'm giving you a bump
jbjonesjr at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 2
Yes I meant JSR-168, that was a typing mistake.I wonder why nobody could give some reply yet, while I think user recognition is a usual part of portlet development
den2Fly at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 3
I would agree. However, I will say that I think the interface requires knowledge of what sort of portal server you are using (different vendors I am sure expose their api/user interfaces in different methods). What portal server are you using?
jbjonesjr at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 4

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

den2Fly at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 5

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

Tosa_Developer at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 6

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

den2Fly at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 7

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

Tosa_Developer at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 8
Yes thank you very very much. Let me try it to see how it worksI will post again if some thing goes wrongI also hope some creator member join this conversation to clear tricky thingsThank you again
den2Fly at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 9
den2Fly,Could you post again if it works, too? I would like to see what you put in your portlet.xml file. I haven'd done this yet, but it is something I will need to do on a future project.Thanks!
Tosa_Developer at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...
# 10
Ok buddy,I'll post if I find anything useful.
den2Fly at 2007-7-6 20:05:56 > top of Java-index,Development Tools,Java Tools...