Monday, November 21, 2011

Oracle Portal and WSRP Producer

If you are developing WSRP portlet provider with JDeveloper/Weblogic, and going to implement some security, you may have some issue like we had.
Or you have not if you wouldn't  use Oracle Portal.
The simplest thing you should  get user name and make some decision or just greet the user. 
So the standard way is:
 .....
PortletRenderRequest portletRequest = (PortletRenderRequest)
                            request.getAttribute("oracle.portal.PortletRenderRequest");
String name = portletRequest.getRemoteUser();
......
Most likely that name will be null. We wasted some time, trying to find the solution. Thanks Google, The Wonderful and Manoj we find it. Here you are:
Add this option to your portlet.xml and you will get user name from Oracle Portal or Webcenter application.
...
<container-runtime-option>
     <name>com.oracle.portlet.useWsrpUserContextForUserAuthenticationInfo</name> 
     <value>true</value>
</container-runtime-option>
.....

P.S. It definitively works with Oracle Portal  11.1.1.4 and WebCenter 11.1.1.5

3 comments:

training said...

wonderful information, I had come to know about your blog from my friend nandu , hyderabad,i have read atleast 7 posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a ton once again, Regards, Oracle Portal online trainingamong the Oracle Portal in Hyderabad. Classroom Training in Hyderabad India

Mikhail Mikhailidi said...

Thank you for feedback. I really surprised if anyone read my scratches ;)

Dm Prog said...

Hi Mik!

What about user groups and roles?

ADFContext adfContext = ADFContext.getCurrent();
SecurityContext securCtx = adfContext.getSecurityContext();
String[] roles = securCtx.getUserRoles(); // return only [anonymous, anonymous-role]

The portletRequest.isUserInRole("myrealm_user_group");

always return false

The portletRequest.isUserInRole("myrealm_role");

also always return false