jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angela Schreiber <anch...@day.com>
Subject Re: Help with JCR 2 access control
Date Fri, 01 Oct 2010 08:48:00 GMT
hi aimran

you have to reapply the modified policy. modifying the
policy doesn't modify the underlying items.

aimran wrote:
> Hi Justin,
> 
> I finally got a chance to try what you suggested. Unfortunately it doesn't
> work. I followed your steps exactly:
> Here are the extracts of the code:
> - AccessControlPolicy[] policies =
> session.getAccessControlManager().getPolicies(n.getPath());//root node
>  for (AccessControlPolicy policy : policies) {
>                 if (policy instanceof AccessControlList) {
> AccessControlList acl = AccessControlList.class.cast(policy);//OBTAINED THE
> ACL
> AccessControlEntry[] ent = acl.getAccessControlEntries();
>                    
>                     for (AccessControlEntry ace : ent) {
> acl.removeAccessControlEntry(ace);//REMOVED ALL ENTRIES
> }
once you are done with the modifications call
AccessControlManager.setPolicy(String path, AccessControlPolicy policy);

> }
> session.save();
> ...
> MyPrincipal admingroup_principal = new
> MyPrincipal("Administrators");//CREATED NEW GROUP
> admin_group = um.createGroup(admingroup_principal);
> acl.addAccessControlEntry(admingroup_principal,
> session.getAccessControlManager().getSupportedPrivileges(n.getPath()));
>                        
> session.getAccessControlManager().setPolicy(n.getPath(), policy);//ADDED THE
> ACL FOR THE NEW GROUP
>                         session.save();
> }
> 
> 
> Now if I login as guest and try to read the contents, the guest is still
> able to access and read the workspace.
> 
> What am doing wrong? I have been banging my head over setting a simple
> policy for hours. Went through the tests code, browsed forums, to no avail.


Mime
View raw message