问题
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