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 Fri, 07 Aug 2009 10:49:54 GMT
---------- Forwarded message ----------
From: arcassis@gmail.com <arcassis@gmail.com>
Date: Thu, Aug 6, 2009 at 9:29 PM
Subject: Problem with SimpleAccessControl.setPolicy
To: dev-info@jackrabbit.apache.org


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, it's called
the method from AbstractAccessControlManager.

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 node

So, how can I set an access control list on a node ?

I appreciate any help !


Damian Daniel


View raw message