jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Short <...@benshort.co.uk>
Subject Re: Using the AccessControlManager to set a policy
Date Fri, 04 Dec 2009 11:47:33 GMT
Hi,

I have a really simple test case as follows:

public class UserManagerTests {
private Repository repository;
    private Session superuser;
private Session anonymous;
Node testRootNode;


@Before
    public void before() throws Exception {
        repository = new TransientRepository();
        superuser = repository.login(new SimpleCredentials("admin",
"admin".toCharArray()));
anonymous = repository.login(new SimpleCredentials("anonymous",
"anonymous".toCharArray()));
testRootNode = superuser.getRootNode().addNode("test_" +
Long.toString(System.currentTimeMillis()));
superuser.save();
}

    @After
    public void after() throws Exception {
testRootNode.remove();
superuser.save();
superuser.logout();
        superuser = null;
        repository = null;
    }

@Test
public void testUserManager() throws Exception {

AccessControlManager adminAcm = getAccessControlManager(superuser);
AccessControlManager anonAcm = getAccessControlManager(anonymous);

Assert.assertFalse(anonAcm.hasPrivileges(testRootNode.getPath(),
privilegesFromName(Privilege.JCR_WRITE)));

// something here to allow anon user to write to our test node
adminAcm.setPolicy(testRootNode.getPath(), policy);


Assert.assertTrue(anonAcm.hasPrivileges(testRootNode.getPath(),
privilegesFromName(Privilege.JCR_WRITE)));
}
}

How do I get/create a policy for the anonymous user which will allow the
anonymous user to write to the test node? All the implementations of
AccessControlPolicy are not visible to to my code.

Regards

Ben



2009/11/27 Ben Short <ben@benshort.co.uk>

> Hi,
>
> I'm trying to use the AccessControlManager to allow a user to have write
> permissions to a node. But I can't see how to create  a policy.
>
> Can anyone give me any pointers?
>
> Regards
>
> Ben Short
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message