I can not find documentation on how to create and create a repository for multiple users.
I'm new to Jackrabbit, and I always used one main user credential to create a repository that only one main user accessed.
Now I need a repository that is used by thousands of users, and each user works with his own sites and does not have access rights to others.
SimpleAccessManager is pretty simple:
public boolean isGranted(ItemId id, int permissions) throws RepositoryException {
checkInitialized();
if (system) {
return true;
} else if (anonymous) {
if ((permissions & WRITE) == WRITE
|| (permissions & REMOVE) == REMOVE) {
return false;
}
}
return true;
}
It seems that you cannot create such a multi-user repository using SimpleLoginModule and SimpleAccessManager. Because it only distinguishes between ADMIN and anonymous users who can read everything but cannot write ...
So, you need to use the DefaultAccessManager and maybe do something like this:
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
UserManager um = ((JackrabbitSession) session).getUserManager();
User user = um.createUser("john", "doe");
AccessControlManager acm = session.getAccessControlManager();
AccessControlPolicyIterator it = acm.getApplicablePolicies(testRootNode.getPath());
while ( it.hasNext() ) {
AccessControlPolicy acp = it.nextAccessControlPolicy();
Privilege[] privileges = new Privilege[]{acm.privilegeFromName(Privilege.JCR_WRITE)};
((AccessControlList)acp).addAccessControlEntry(new PrincipalImpl(user.getUserID()), privileges);
acm.setPolicy(testRootNode.getPath(), acp);
}
OpenCMIS, .
EDIT: , AccessControl