use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testCreateUser2.
@Test
public void testCreateUser2() throws Exception {
UserManager testUserMgr = getUserManager(testSession);
Privilege[] privs = privilegesFromNames(new String[] { PrivilegeConstants.REP_USER_MANAGEMENT, PrivilegeConstants.REP_WRITE });
allow("/", privs);
// creating user should succeed
testUserMgr.createUser(userId, "pw");
testSession.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testRemoveUser.
@Test
public void testRemoveUser() throws Exception {
createUser(userId);
// testSession has user-mgt permission -> removal should succeed.
modify("/", PrivilegeConstants.REP_USER_MANAGEMENT, true);
UserManager testUserMgr = getUserManager(testSession);
Authorizable a = testUserMgr.getAuthorizable(userId);
a.remove();
testSession.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testCreateWithoutReadAccess.
@Test
public void testCreateWithoutReadAccess() throws Exception {
UserManager testUserMgr = getUserManager(testSession);
deny("/", privilegesFromName(PrivilegeConstants.JCR_READ));
allow("/", privilegesFromName(PrivilegeConstants.REP_USER_MANAGEMENT));
try {
Group gr = testUserMgr.createGroup(groupId);
testSession.save();
fail("Creating group without read-access on the folder node should fail");
} catch (AccessDeniedException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method tearDown.
@Override
@Before
public void tearDown() throws Exception {
try {
testSession.refresh(false);
superuser.refresh(false);
UserManager userMgr = getUserManager(superuser);
for (String id : authorizablesToRemove) {
Authorizable a = userMgr.getAuthorizable(id);
if (a != null) {
a.remove();
}
}
superuser.save();
} finally {
super.tearDown();
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testGlobRestriction.
@Test
public void testGlobRestriction() throws Exception {
String groupHome = Text.getRelativeParent(UserConstants.DEFAULT_GROUP_PATH, 1);
Privilege[] privs = privilegesFromName(PrivilegeConstants.REP_USER_MANAGEMENT);
allow(groupHome, privs);
deny(groupHome, privs, createGlobRestriction("*/" + UserConstants.REP_MEMBERS));
UserManager testUserMgr = getUserManager(testSession);
// creating a new group must be allow
Group gr = testUserMgr.createGroup(groupId);
testSession.save();
// modifying group membership must be denied
try {
gr.addMember(testUserMgr.getAuthorizable(testSession.getUserID()));
testSession.save();
fail();
} catch (AccessDeniedException e) {
// success
} finally {
testSession.refresh(false);
}
}
Aggregations