accessTestRoot.getSession().save();
}
public void testAnonim() throws RepositoryException
{
ExtendedNode testNode = (ExtendedNode)accessTestRoot.addNode("testAnonim");
// node.addMixin("exo:accessControllable");
testNode.addMixin("exo:owneable");
testNode.addMixin("exo:privilegeable");
session.save();
Session anonimSession = repository.login(new CredentialsImpl(SystemIdentity.ANONIM, "".toCharArray()));
// try {
// anonimSession.checkPermission(testNode.getPath(), PermissionType.READ);
// anonimSession.getRootNode().getNode("."+testNode.getPath());
// anonimSession.checkPermission(testNode.getPath(), PermissionType.REMOVE);
// fail();
// } catch (AccessControlException e) {
// //ok
// }
testNode.setPermission(testNode.getSession().getUserID(), PermissionType.ALL);
testNode.removePermission(SystemIdentity.ANY);
session.save();
try
{
anonimSession.checkPermission("." + testNode.getPath(), PermissionType.READ);
fail();
}
catch (AccessControlException e)
{
}
testNode.setPermission(SystemIdentity.ANY, new String[]{PermissionType.READ});
session.save();
try
{
anonimSession.checkPermission(testNode.getPath(), PermissionType.READ);
anonimSession.getRootNode().getNode("." + testNode.getPath());
anonimSession.checkPermission(testNode.getPath(), PermissionType.REMOVE);
fail();
}
catch (AccessControlException e)
{
}
testNode.removePermission(SystemIdentity.ANY);
session.save();
try
{
anonimSession.checkPermission("." + testNode.getPath(), PermissionType.READ);
fail();
}
catch (AccessControlException e)
{
}
testNode.setPermission(SystemIdentity.ANY, new String[]{PermissionType.READ, PermissionType.SET_PROPERTY,
PermissionType.REMOVE});
session.save();
try
{
anonimSession.checkPermission(testNode.getPath(), PermissionType.READ);
anonimSession.getRootNode().getNode("." + testNode.getPath());
anonimSession.checkPermission(testNode.getPath(), PermissionType.SET_PROPERTY);
anonimSession.checkPermission(testNode.getPath(), PermissionType.REMOVE);
anonimSession.checkPermission(testNode.getPath(), PermissionType.ADD_NODE);
fail();
}
catch (AccessControlException e)
{
}
try
{
anonimSession.checkPermission(testNode.getPath(), PermissionType.READ + "," + PermissionType.ADD_NODE);
fail();
}
catch (AccessControlException e)
{
}
try
{
anonimSession.checkPermission(testNode.getPath(), PermissionType.CHANGE_PERMISSION);
fail();
}
catch (AccessControlException e)
{