use of org.ow2.proactive.permissions.PrincipalPermission in project scheduling by ow2-proactive.
the class ClientsPolicy method getPermissions.
@Override
public PermissionCollection getPermissions(final ProtectionDomain domain) {
try {
readLock.lock();
PermissionCollection permissions = new Permissions();
// Look up permissions
Principal[] principals = domain.getPrincipals();
boolean identityPrincipal = false;
if (principals != null) {
for (Principal principal : principals) {
if (principal instanceof IdentityPrincipal) {
identityPrincipal = true;
PermissionCollection pc = original.getPermissions(domain);
if (pc != null) {
Permission permission = new PrincipalPermission((IdentityPrincipal) principal);
// always adding identity permission
permissions.add(permission);
if (debug) {
// WARNING cannot use log4j as it may lead to recursive permission check
System.out.println(principal + " has " + permission);
}
for (Enumeration<Permission> en = pc.elements(); en.hasMoreElements(); ) {
permission = en.nextElement();
// boot class path, so they were not correctly resolved at JVM start up time
if (permission instanceof UnresolvedPermission) {
permission = resolvePermission((UnresolvedPermission) permission);
if (permission == null)
continue;
}
// For IdentityPrincipal org.ow2.proactive.permissions.AllPermissions must be used
if (!permission.getClass().isAssignableFrom(AllPermission.class)) {
if (debug) {
// WARNING cannot use log4j as it may lead to recursive permission check
System.out.println(principal + " has " + permission);
}
permissions.add(permission);
}
}
}
}
}
}
if (!identityPrincipal) {
return original.getPermissions(domain);
}
return permissions;
} finally {
readLock.unlock();
}
}
Aggregations