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

2 comments:

Michael Mikhailidi said...

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

Unknown 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