Here we'll breifly discuss abput creating roles in Glassfish-v2 and using those roles in a portlet. This portlet will be deployed on portlet container
Creating user and role in Glassfish-v2
=============================
1)Login to admin console at http://localhost:8080/portletdriver/dt
2)Goto Configuration->security->admin-realms->Manage users
3)Provide a user name and Group/role eg user name:ed group:role1 eg user name:mary group:role2
4)click save
Now we have sucessfully created an user and grouped him or given him a role.Out task now is to create a portlet that will use these roles . All portlets that make use of roles needs to supllied with a roles file. We'll now make the roles file
Create a roles.txt file with the following name value pair
role1=EMPLOYEE role2=MANAGER
Creating a portlet .xml and web.xml that has the role informations
Portlet.xml
<security-role-ref>
<role-link>EMPLOYEE</role-link>
<security-role-ref>
<role-link>MANAGER</role-link>
Web.xml
<security-role>
<security-role>
Create a portlet that uses the role info
1)You can create a simple portlet through netbeans and portal pack 2)In the doView() of the portlet created paste the following
writer.prinln("Employee"+req.isUserInRole(employee)); writer.println("Manager"+req.isUserInRole(manager));
Login in as mary or ed
1)Deploy the portlet.war in portlet container along with the roles.txt
You can either use the admin tab in portlet container to specify the war file and roles files or You can use the following CLI
ant deploy-portlet -Dportlet-war=
Sriram , thanks for this nice blog. I am using Sun Portal Sever 7.2 and I have to implement the portlet-role mapping.
I've created the roles in Access Manager 7.1
and used a role.properties while deploying the .war file.
The portlet.xml and the web.xml is modified as suggested by you.
My intention is to hide a portlet for a user who does not belong to a role.
Whatever you suggested will that hold good for this scenario also?
Posted by Deb on September 11, 2008 at 10:27 PM IST #