User permissions API in CQ

拈花ヽ惹草 提交于 2019-12-23 06:31:11

问题


Consider creating a standalone java program for creating user/group with the access permission. So my question is, Is there any APIs available for setting user-permissions in CQ ?


回答1:


There is a JCR access control management api that can be used to read and assign access control policies. There is also a jackrabbit UserManager accessible from within CQ for creating users/groups.

There are some code examples on the User Management page of the JackRabbit wiki.

Essentially, you need to cast the JcrSession to a JackRabbitSession and call getUserManager() on that.

JackrabbitSession js = (JackrabbitSession) session;
final UserManager userManager = session.getUserManager();
final User user = userManager.createUser(userName, userName);
session.save();

There are a couple of ways of getting the session, one way is to get the resource resolver from the request and adaptTo a Session from there.

Session session = slingHttpServletRequest.getResourceResolver().adaptTo(Session.class);

Finally, there is a Sling HTTP api for managing users & groups.



来源:https://stackoverflow.com/questions/16580283/user-permissions-api-in-cq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!