jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "arcassis@gmail.com" <arcas...@gmail.com>
Subject Problem with SimpleAccessControl.setPolicy
Date Thu, 06 Aug 2009 18:38:18 GMT

I'm using Jackrabbit in one of my projects  and now I've came to implement
the security part.

After some readings I've found out that the documentation from jsr283 is the
best starting point in implementing security in a Jackrabbit based project.

I need to set pairs of Principal-Privilege[] on a node, so I tried the
SessionImpl s = rep.login(new SimpleCredentials("myUser",
AccessControlManager acm = s.getAccessControlManager();

Principal p_myUser = new PrincipalImpl("myUser");
Privilege[] privs = new Privilege[] {acm.privilegeFromName("jcr:write")};
MyAccessControlList acl = new MyAccessControlList();
acl.addAccessControlEntry(p_myUser, privs);
acm.setPolicy(absPath, acl);

The problem is that setPolicy method, innvoked on SimpleAccessControlManager
throws always an exception - AccessControlException.
So the method is not implemented in SimpleAccessControlManager, the one from
from AbstractAccessControlManager it's called.

After all mentioned above I've tried the folowing:

Node theNode = s.getNode(absPath);
Node policy = theNode.addNode("rep:policy", "rep:ACL");
Node accessControlEntry = policy.addNode("ace1", "rep:GrantACE");
accessControlEntry.setProperty("rep:principalName", "ionel");
accessControlEntry.setProperty("rep:privileges", new String[]
accessControlEntry.setProperty("rep:nodePath", theNode.getPath());

but I get the folowing  exception:
javax.jcr.nodetype.ConstraintViolationException: node
/category_X/rep:policy: cannot add a child to a protected node.

The node that I want to set a Policy on is a rep:AccessControllable mixin

So, how can I set an access control list on a node ?
Any further documentation regarding the Access Control in Jackrabbit would
be very useful.

I appreciate any help !


Damian Daniel

View raw message