use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class L4_AuthorizableIdTest method testGetByID.
@Test
public void testGetByID() throws RepositoryException {
// EXERCISE fix the test-case
UserManager uMgr = getUserManager(root);
Group g = uMgr.getAuthorizable(testUser.getID(), Group.class);
assertEquals(g, uMgr.getAuthorizable(testGroup.getID()));
assertEquals(g, uMgr.getAuthorizable(testGroup.getPrincipal().getName()));
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class L7_PrivilegeDiscoveryTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
SimpleCredentials creds = new SimpleCredentials("u", "u".toCharArray());
UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();
User u = uMgr.createUser(creds.getUserID(), creds.getUserID());
Group g = uMgr.createGroup("g");
g.addMember(u);
uPrincipal = u.getPrincipal();
gPrincipal = g.getPrincipal();
Node n = superuser.getNode(testRoot).addNode(nodeName1);
testPath = n.getPath();
Property p = n.setProperty(propertyName1, "value");
propPath = p.getPath();
Privilege[] privs = AccessControlUtils.privilegesFromNames(superuser, Privilege.JCR_VERSION_MANAGEMENT, Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_MODIFY_PROPERTIES);
AccessControlUtils.addAccessControlEntry(superuser, n.getPath(), gPrincipal, privs, true);
AccessControlUtils.addAccessControlEntry(superuser, n.getPath(), uPrincipal, new String[] { Privilege.JCR_VERSION_MANAGEMENT }, false);
Node child = n.addNode(nodeName2);
childPath = child.getPath();
superuser.save();
userSession = getHelper().getRepository().login(creds);
// NOTE the following precondition defined by the test-setup!
assertTrue(userSession.nodeExists(testPath));
assertTrue(userSession.nodeExists(childPath));
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class L3_UserVsPrincipalTest method before.
@Override
public void before() throws Exception {
super.before();
UserManager userMgr = getUserManager(root);
testUser = ExerciseUtility.createTestUser(userMgr);
testGroup = userMgr.createGroup(testGroupId, testGroupPrincipal, null);
testGroup.addMember(testUser);
root.commit();
principalManager = getPrincipalManager(root);
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class ObservationQueueTest method prepareTestData.
@Override
protected void prepareTestData(Session s) throws RepositoryException {
UserManager uMgr = ((JackrabbitSession) s).getUserManager();
User user = uMgr.createUser(USER, PASSWORD);
s.save();
AccessControlManager acMgr = s.getAccessControlManager();
JackrabbitAccessControlList tmpl = AccessControlUtils.getAccessControlList(acMgr, "/");
tmpl.addEntry(user.getPrincipal(), new Privilege[] { acMgr.privilegeFromName(Privilege.JCR_ALL) }, true, Collections.<String, Value>emptyMap());
acMgr.setPolicy(tmpl.getPath(), tmpl);
s.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AbstractRandomizedTest method setupAuthorizables.
protected void setupAuthorizables() throws RepositoryException {
for (JackrabbitSession s : writeSessions) {
UserManager userManager = s.getUserManager();
User user = userManager.createUser(userId, userId);
Group group = userManager.createGroup("group1");
group.addMember(user);
Group group2 = userManager.createGroup("group2");
group2.addMember(user);
s.save();
}
}
Aggregations