You are here

Getting the username in a JSR 286 portlet in WebCenter PS3

There are some questions on the forums on OTN regarding *portlets* and getting the username from the portal.
It appears that since WebCenter PS3, you need to configure your container before the user principal is passed to your portlet. This is because WebCenter uses WSRP to consume portlets. WSRP allows us to configure security between the portlet and producer. By default WebCenter does not use this security and we need to tell the container that we want to pass the username over the SOAP call which is not secure.

Before WebCenter PS3 this was configured automicly because we used JSR 168 portlets. Now with JSR 286, our portlets are fully JSR 286 and WSRP compliant.

So, what do we need to do. It's very simple. Just add com.oracle.portlet.useWsrpUserContextForUserAuthenticationInfo to the Container Runtime Options in your portlet.xml. That's all you need to do. After this, you can use following code to retreive the username in your portlet.

In a managed bean:

  1. PortletRequest req = (PortletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
  2. String user = req.getRemoteUser();

Or from within a JSPX page (using EL)

  1. #{securityContext.userName}

That's it. I will also write a complete example that uses this technique in a portlet.

Category: 
WebCenter Tags: 
ADF Tags: 

Comments

Thanks for the post. I have a question on Webcenter/UCM integration. Portlet Security works fine after configuring the details from your post and now relevant user profile is retrieved without hard-coding user name.

As part of list of fields displayed from UCM Search, I have a field called "URL" (which provides the link to relevant document searched). When I try to open the document from the URL (from WebCenter portlet), it is promting for a logon screen to UCM. Is it something to do with SSO or is there anything else to configure from Webcenter/UCM to not to prompt for logon screen so that SSO takes care of everything once get on to the portal ? Have you have come across this similar issue?

Inorder to test this scenario, I have logged out from content server just to make sure content server credentials are not retrieved from the cache on the browser.

have you tested how to pass user's profile to JSR286 portlet?

This is tricky. It should be possible but than you need to configure WS security on your WSRP portlets.
What exactly do you want to know from the profile?
If it's very important, you can always create taskflows instead of portlets and consume that in your portal. Taskflows can access the profile very easy.

Hi Yannick,

I'd also like to create a portlet which shows currently logged in user's basic profile like name, phone and etc.

Is it possible and how can I show other users' profile snapshots?

Thanks a lot,

Will

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer