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,

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

public class ManageAccesscontrol{

public void test(){


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()) {
// 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;

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.