获取AEM中页面组的权限列表

时间:2016-03-08 09:01:57

标签: cq5 aem jcr jackrabbit sling

我需要转到特定页面并以编程方式查找为该页面授予组的权限。这是我必须在AEm6.0中实现的。请提供一些代码片段,以帮助我实现这一目标。任何帮助都非常感谢。

1 个答案:

答案 0 :(得分:1)

您可以使用jcr api'

来实现这一目标
        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];