}
public void testAccessPermissionForAny() throws Exception
{
// At creation time
NodeImpl node = (NodeImpl)sessionWS1.getRootNode().addNode("testAccessPermissionAny");
node.addMixin("mix:versionable");
sessionWS1.save();
node.addMixin("exo:privilegeable");
node.getSession().save();
node.clearACL();
node.setPermission("admin", new String[]{"read", "add_node", "set_property", "remove"});
node.setPermission(SystemIdentity.ANY, new String[]{"read"});
NodeImpl subNode = (NodeImpl)node.addNode("subNode");
node.getSession().save();
Version version = node.checkin();
Credentials credentials = new CredentialsImpl("john", "exo".toCharArray());
SessionImpl sessionJohnWS1 = (SessionImpl)repositoryService.getRepository("db2").login(credentials, "ws1");
Credentials anonCredentials = new CredentialsImpl(SystemIdentity.ANONIM, "".toCharArray());
SessionImpl anonSession = (SessionImpl)repositoryService.getRepository("db2").login(anonCredentials, "ws1");
try
{
NodeImpl vNode = (NodeImpl)sessionJohnWS1.getRootNode().getNode("testAccessPermissionAny");
assertNotNull(vNode);
VersionHistoryImpl vHist = (VersionHistoryImpl)vNode.getVersionHistory();
assertEquals(vHist.getACL().getPermissions("admin").size(), 0);
assertEquals(vHist.getACL().getPermissions("any").size(), 1); // there is a workaround in ScratchWorkspaceInitializer
vNode = (NodeImpl)vHist.getVersion("1");
assertEquals(vNode.getACL().getPermissions("admin").size(), 4);
assertEquals(vNode.getACL().getPermissions("any").size(), 1);
assertNotNull(vNode);
vNode = (NodeImpl)vNode.getNode("jcr:frozenNode");
assertNotNull(vNode);
assertNotNull(vNode.getNode("subNode"));
assertEquals(vNode.getACL().getPermissions("admin").size(), 4);
assertEquals(vNode.getACL().getPermissions("any").size(), 1);
vNode = (NodeImpl)anonSession.getRootNode().getNode("testAccessPermissionAny");
assertNotNull(vNode);
vHist = (VersionHistoryImpl)vNode.getVersionHistory();
assertEquals(vHist.getACL().getPermissions("admin").size(), 0);
assertEquals(vHist.getACL().getPermissions("any").size(), 1); // there is a workaround in ScratchWorkspaceInitializer
vNode = (NodeImpl)vHist.getVersion("1");
assertEquals(vNode.getACL().getPermissions("admin").size(), 4);
assertEquals(vNode.getACL().getPermissions("any").size(), 1);
assertNotNull(vNode);
vNode = (NodeImpl)vNode.getNode("jcr:frozenNode");
assertNotNull(vNode);
assertNotNull(vNode.getNode("subNode"));
assertEquals(vNode.getACL().getPermissions("admin").size(), 4);
assertEquals(vNode.getACL().getPermissions("any").size(), 1);
vNode = (NodeImpl)anonSession.getNodeByUUID(vNode.getUUID());
assertNotNull(vNode);
assertNotNull(vNode.getNode("subNode"));
}
finally
{
if (anonSession != null)
{