{
Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
{
public Object run()
{
FolderPermission perm1 = new FolderPermission("/files/subfolder1/test.xml", "view");
AccessController.checkPermission(perm1);
return null;
}
});
}
catch (AccessControlException ace)
{
fail("did not authorize view permission on the Folder.");
}
try
{
Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
{
public Object run()
{
FolderPermission perm1 = new FolderPermission("/files/subfolder1/foo", "view");
AccessController.checkPermission(perm1);
return null;
}
});
}
catch (AccessControlException ace)
{
fail("did not authorize view permission on the Folder.");
}
try
{
Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
{
public Object run()
{
FolderPermission perm1 = new FolderPermission("/files/subfolder1/foo/anotherdoc.xml", "view");
AccessController.checkPermission(perm1);
return null;
}
});
fail("Permission error - should not view the document ");
}
catch (AccessControlException ace)
{
// Correct behavior - not authorise to view the document
}
try
{
Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
{
public Object run()
{
FolderPermission perm1 = new FolderPermission("/files/subfolder2/test.xml", "view");
AccessController.checkPermission(perm1);
return null;
}
});
}
catch (AccessControlException ace)
{
fail("did not authorize view permission on the Folder.");
}
try
{
Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
{
public Object run()
{
FolderPermission perm1 = new FolderPermission("/files/subfolder2/foo", "view");
AccessController.checkPermission(perm1);
return null;
}
});
}
catch (AccessControlException ace)
{
fail("did not authorize view permission on the Folder.");
}
try
{
Subject.doAs(loginContext.getSubject(), new PrivilegedAction()
{
public Object run()
{
FolderPermission perm1 = new FolderPermission("/files/subfolder2/foo/anotherdoc.xml", "view");
AccessController.checkPermission(perm1);
return null;
}
});
}