SecurityRoleSet roles = webApp.getSecurityRoles();
Collection portlets = portletApp.getPortletDefinitions();
Iterator portletIterator = portlets.iterator();
while (portletIterator.hasNext())
{
PortletDefinition portlet = (PortletDefinition) portletIterator.next();
SecurityRoleRefSet securityRoleRefs = portlet.getInitSecurityRoleRefSet();
Iterator roleRefsIterator = securityRoleRefs.iterator();
while (roleRefsIterator.hasNext())
{
SecurityRoleRef roleRef = (SecurityRoleRef) roleRefsIterator.next();
String roleName = roleRef.getRoleLink();
if (roleName == null || roleName.length() == 0)
{
roleName = roleRef.getRoleName();
}
if (roles.get(roleName) == null)
{
String errorMsg = "Undefined security role " + roleName + " referenced from portlet "
+ portlet.getName();
throw new PortletApplicationException(errorMsg);
}
}
}
}