Set<String> unreferencedRoles = metaData.getSecurityRoleNames();
if(roleRefs != null)
for(SecurityRoleRefMetaData roleRef : roleRefs)
{
String roleName = roleRef.getRoleLink();
WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef.getName());
pc.addToRole(roleName, wrrp);
/* A bit of a hack due to how tomcat calls out to its Realm.hasRole()
with a role name that has been mapped to the role-link value. We
may need to handle this with a custom request wrapper.
*/
wrrp = new WebRoleRefPermission(servletName, roleName);
pc.addToRole(roleRef.getName(), wrrp);
// Remove the role from the unreferencedRoles
unreferencedRoles.remove(roleName);
}
//Spec 3.1.3.2: For each servlet element in the deployment descriptor
//a WebRoleRefPermission must be added to each security-role of the
//application whose name does not appear as the rolename
//in a security-role-ref within the servlet element.
if(unreferencedRoles != null)
for(String unrefRole : unreferencedRoles)
{
WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName,unrefRole);
pc.addToRole(unrefRole, unrefP);
}
}
Set<String> unreferencedRoles = metaData.getSecurityRoleNames();
//JACC 1.1:Spec 3.1.3.2: For each security-role defined in the deployment descriptor, an
//additional WebRoleRefPermission must be added to the corresponding role by
//calling the addToRole method on the PolicyConfiguration object. The
//name of all such permissions must be the empty string, and the actions of each
//such permission must be the role-name of the corresponding role.
if(unreferencedRoles != null)
for(String unreferencedRole : unreferencedRoles)
{
WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole);
pc.addToRole(unreferencedRole, wrrep);
}
// Now build the cross product of the unreferencedRoles and servlets
Set<String> servletNames = servlets.keySet();
if(servletNames != null)
for(String servletName : servletNames)
{
if(unreferencedRoles != null)
for(String role : unreferencedRoles)
{
WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role);
pc.addToRole(role, wrrp);
}
}
/**
* The programmatic security checks are made from jsps.
* JBAS-3054:Use of isCallerInRole from jsp does not work for JACC
*/
if(unreferencedRoles != null)
for(String role : unreferencedRoles)
{
WebRoleRefPermission wrrp = new WebRoleRefPermission("", role);
pc.addToRole(role, wrrp);
}
}