How to develop Custom ACL to a node in CQ

Can any one help me how can i develop custom ACL to a node in CQ/AEM projects I refer these sites http://wiki.apache.org/jackrabbit/AccessControl, http://wemcode.wemblog.com/add-acl-to-node

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.security.*;
import javax.jcr.*;



public class ManageAccesscontrol{

public void test(){

Request.getSession(false);

JackrabbitSession js = (JackrabbitSession)session;

 AccessControlManager aMgr = jackrabbitSession.getAccessControlManager();

 // create a privilege set with jcr:all
 Privilege[] privileges = new Privilege[] 
 {    aMgr.privilegeFromName(Privilege.JCR_ALL) };
 AccessControlList acl;
 try {
// get first applicable policy (for nodes w/o a policy)
acl = aMgr.getApplicablePolicies(path).nextAccessControlPolicy();
} catch (NoSuchElementException e) {
// else node already has a policy, get that one
acl = aMgr.getPolicies(path)[0];
}
// remove all existing entries
 for (AccessControlEntry e : acl.getAccessControlEntries()) {
acl.removeAccessControlEntry(e);
}
// add a new one for the special "everyone" principal
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privileges);

 // the policy must be re-set
aMgr.setPolicy(path, acl);

// and the session must be saved for the changes to be applied
session.save();
}
}

still am unable to fix SESSION.
If any one know about this help me plz…


Source: jsp

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.