use of java.security.Permission in project system-rules by stefanbirkner.
the class NoExitSecurityManagerTest method checkPermission_without_context_is_delegated_to_original_security_manager.
@Test
public void checkPermission_without_context_is_delegated_to_original_security_manager() {
Permission permission = mock(Permission.class);
managerWithOriginal.checkPermission(permission);
verify(originalSecurityManager).checkPermission(permission);
}
use of java.security.Permission in project system-rules by stefanbirkner.
the class NoExitSecurityManagerTest method checkPermission_with_context_may_be_called_without_original_security_manager.
@Test
public void checkPermission_with_context_may_be_called_without_original_security_manager() {
Permission permission = mock(Permission.class);
Object context = new Object();
managerWithoutOriginal.checkPermission(permission, context);
}
use of java.security.Permission in project system-rules by stefanbirkner.
the class NoExitSecurityManagerTest method checkPermission_with_context_is_delegated_to_original_security_manager.
@Test
public void checkPermission_with_context_is_delegated_to_original_security_manager() {
Permission permission = mock(Permission.class);
Object context = new Object();
managerWithOriginal.checkPermission(permission, context);
verify(originalSecurityManager).checkPermission(permission, context);
}
use of java.security.Permission in project scout.rt by eclipse.
the class LenientPermissionsWrapper method writeObject.
/**
* @serialData Default fields.
*/
private void writeObject(ObjectOutputStream out) throws IOException {
// no call to defaultWriteObject
ObjectOutputStream.PutField pfields = out.putFields();
ArrayList<LenientPermissionWrapper> list = null;
if (m_permissions != null) {
list = new ArrayList<LenientPermissionWrapper>();
for (Enumeration<Permission> en = m_permissions.elements(); en.hasMoreElements(); ) {
Permission perm = en.nextElement();
if (perm != null) {
list.add(new LenientPermissionWrapper(perm));
}
}
}
pfields.put("m_permissions", list);
out.writeFields();
}
use of java.security.Permission in project scout.rt by eclipse.
the class AbstractAccessControlService method getPermissionLevel.
@Override
public int getPermissionLevel(Permission p) {
if (p == null) {
return BasicHierarchyPermission.LEVEL_NONE;
}
if (!(p instanceof BasicHierarchyPermission)) {
if (checkPermission(p)) {
return BasicHierarchyPermission.LEVEL_ALL;
} else {
return BasicHierarchyPermission.LEVEL_NONE;
}
}
BasicHierarchyPermission hp = (BasicHierarchyPermission) p;
PermissionCollection c = getPermissions();
if (c == null) {
List<Integer> levels = hp.getValidLevels();
return levels.get(levels.size() - 1);
} else {
int maxLevel = BasicHierarchyPermission.LEVEL_UNDEFINED;
Enumeration<Permission> en = c.elements();
while (en.hasMoreElements()) {
Permission grantedPermission = en.nextElement();
// catch AllPermission
if (grantedPermission instanceof AllPermission) {
return BasicHierarchyPermission.LEVEL_ALL;
}
// process basic hierarchy permissions
if (grantedPermission instanceof BasicHierarchyPermission) {
BasicHierarchyPermission hgrantedPermission = (BasicHierarchyPermission) grantedPermission;
if (hgrantedPermission.getClass().isAssignableFrom(hp.getClass())) {
maxLevel = Math.max(maxLevel, hgrantedPermission.getLevel());
if (maxLevel >= BasicHierarchyPermission.LEVEL_ALL) {
break;
}
}
}
}
return maxLevel;
}
}
Aggregations