-1

I have a requirement to go to a particular page and find out the permissions granted to a group for that page programmatically. This I have to achieve in AEm6.0. Please give some code snippets which can help me in achieving this. Any help is highly appreciated.

Tushar
  • 151
  • 2
  • 18

1 Answers1

1

You can achieve this using jcr api's

        UserManager userMgr = ((org.apache.jackrabbit.api.JackrabbitSession) adminSession)
                .getUserManager();
        AccessControlManager accCtrlMgr = adminSession
                .getAccessControlManager();
        Authorizable denyAccess = userMgr.getAuthorizable("deny-access");
        AccessControlPolicyIterator policyIterator = accCtrlMgr
                .getApplicablePolicies("/content/geometrixx/fr");
        AccessControlList acl;

        try {
            acl = (JackrabbitAccessControlList) policyIterator
                    .nextAccessControlPolicy();
            LOG.debug("# Policy Iterator Acl" + acl.toString());
        } catch (NoSuchElementException e) {
            acl = (JackrabbitAccessControlList) accCtrlMgr
                    .getPolicies("/content/geometrixx/fr")[0];
SubSul
  • 2,523
  • 1
  • 17
  • 27
  • Thanks a lot, but if can this be used fro a group also, or to check permission for a group we need to try some different method – Tushar Mar 08 '16 at 10:03
  • 1
    `User` and `Group` both extend `Authorizable`. – awd Mar 08 '16 at 11:31