Enumeration pEnum = uncheckedPermissions.elements();
if (pEnum.hasMoreElements()) {
GrantEntry grant = new GrantEntry();
while (pEnum.hasMoreElements()) {
Permission p = (Permission) pEnum.nextElement();
PermissionEntry entry =
new PermissionEntry(p.getClass().getName(),
p.getName(),p.getActions());
grant.add(entry);
}
parser.add(grant);
}
}
// load role based grants in parser
if (rolePermissionsTable != null) {
Iterator roleIt = rolePermissionsTable.keySet().iterator();
while (roleIt.hasNext()) {
boolean withPrincipals = false;
String roleName = (String) roleIt.next();
Permissions rolePerms = getRolePermissions(roleName);
Subject rolePrincipals = (Subject) roleToSubjectMap.get(roleName);
if (rolePrincipals != null) {
Iterator pit = rolePrincipals.getPrincipals().iterator();
while (pit.hasNext()){
Principal prin = (Principal) pit.next();
if (prin != null) {
withPrincipals = true;
PrincipalEntry prinEntry =
new PrincipalEntry(prin.getClass().getName(),
escapeName(prin.getName()));
GrantEntry grant = new GrantEntry();
grant.principals.add(prinEntry);
Enumeration pEnum = rolePerms.elements();
while (pEnum.hasMoreElements()) {
Permission perm = (Permission) pEnum.nextElement();
PermissionEntry permEntry =
new PermissionEntry(perm.getClass().getName(),
perm.getName(),
perm.getActions());
grant.add(permEntry);
}
parser.add(grant);
}
else {
String msg = localStrings.getLocalString("pc.non_principal_mapped_to_role",
"non principal mapped to role "+roleName,new Object[]{prin,roleName});
logger.log(Level.WARNING,msg);
}
}
}
/**
* JACC MR8 add grant for the any authenticated user role '**'
*/
if (!withPrincipals && ("**".equals(roleName))) {
withPrincipals = true;
PrincipalEntry prinEntry = new PrincipalEntry(
PrincipalEntry.WILDCARD_CLASS,PrincipalEntry.WILDCARD_NAME);
GrantEntry grant = new GrantEntry();
grant.principals.add(prinEntry);
Enumeration pEnum = rolePerms.elements();
while (pEnum.hasMoreElements()) {
Permission perm = (Permission) pEnum.nextElement();
PermissionEntry permEntry =
new PermissionEntry(perm.getClass().getName(),
perm.getName(),
perm.getActions());
grant.add(permEntry);
}
parser.add(grant);
if(logger.isLoggable (Level.FINE)){
logger.fine("JACC Policy Provider: added role grant for any authenticated user");
}
}
if (!withPrincipals) {
String msg = localStrings.getLocalString("pc.no_principals_mapped_to_role",
"no principals mapped to role "+roleName, new Object []{ roleName});
logger.log(Level.WARNING,msg);
}
}
}
writeOnCommit = createPolicyFile(true,parser,writeOnCommit);
// load excluded perms in excluded parser
if (excludedPermissions != null) {
PolicyParser excludedParser = new PolicyParser(false);
Enumeration pEnum = excludedPermissions.elements();
if (pEnum.hasMoreElements()) {
GrantEntry grant = new GrantEntry();
while (pEnum.hasMoreElements()) {
Permission p = (Permission) pEnum.nextElement();
PermissionEntry entry =
new PermissionEntry(p.getClass().getName(),
p.getName(),p.getActions());
grant.add(entry);
}
excludedParser.add(grant);
}