for (Iterator iterator = contextIdToPermissionsMap.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String contextID = (String) entry.getKey();
ComponentPermissions componentPermissions = (ComponentPermissions) entry.getValue();
PolicyConfiguration policyConfiguration = policyConfigurationFactory.getPolicyConfiguration(contextID, false);
contextIdToPolicyConfigurationMap.put(contextID, policyConfiguration);
policyConfiguration.addToExcludedPolicy(componentPermissions.getExcludedPermissions());
policyConfiguration.addToUncheckedPolicy(componentPermissions.getUncheckedPermissions());
for (Iterator roleIterator = componentPermissions.getRolePermissions().entrySet().iterator(); roleIterator.hasNext();) {
Map.Entry roleEntry = (Map.Entry) roleIterator.next();
String roleName = (String) roleEntry.getKey();
PermissionCollection rolePermissions = (PermissionCollection) roleEntry.getValue();
for (Enumeration permissions = rolePermissions.elements(); permissions.hasMoreElements();) {
Permission permission = (Permission) permissions.nextElement();
policyConfiguration.addToRole(roleName, permission);
}
}
}
if (principalRoleMapper != null) {
principalRoleMapper.install(contextIdToPermissionsMap.keySet());
}
//link everything together
for (Iterator iterator = contextIdToPolicyConfigurationMap.values().iterator(); iterator.hasNext();) {
PolicyConfiguration policyConfiguration = (PolicyConfiguration) iterator.next();
for (Iterator iterator2 = contextIdToPolicyConfigurationMap.values().iterator(); iterator2.hasNext();) {
PolicyConfiguration policyConfiguration2 = (PolicyConfiguration) iterator2.next();
if (policyConfiguration != policyConfiguration2) {
policyConfiguration.linkConfiguration(policyConfiguration2);
}
}
}
//commit
for (Iterator iterator = contextIdToPolicyConfigurationMap.values().iterator(); iterator.hasNext();) {
PolicyConfiguration policyConfiguration = (PolicyConfiguration) iterator.next();
policyConfiguration.commit();
}
//refresh policy
Policy policy = Policy.getPolicy();
policy.refresh();