use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class GetGroupPrincipalsTest method beforeSuite.
@Override
public void beforeSuite() throws Exception {
super.beforeSuite();
session = loginAdministrative();
UserManager userManager = ((JackrabbitSession) session).getUserManager();
Authorizable user = userManager.getAuthorizable(USER);
if (user == null) {
user = userManager.createUser(USER, USER);
principalName = user.getPrincipal().getName();
}
// make sure we have a least a single group the user is member of.
Group gr = userManager.createGroup(new PrincipalImpl(GROUP), "test");
gr.addMember(user);
for (int i = 1; i < numberOfGroups; i++) {
Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), "test");
if (!nestedGroups) {
g.addMember(user);
} else {
g.addMember(gr);
}
gr = g;
}
session.save();
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class AddMemberTest method createUsers.
@Override
protected void createUsers(@Nonnull UserManager userManager) throws Exception {
for (int i = 0; i <= numberOfMembers; i++) {
String id = USER + i;
User u = userManager.createUser(id, null, new PrincipalImpl(id), REL_TEST_PATH);
userPaths.add(u.getPath());
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class AddMembersTest method createUsers.
protected void createUsers(@Nonnull UserManager userManager) throws Exception {
if (!ImportBehavior.NAME_BESTEFFORT.equals(importBehavior)) {
for (int i = 0; i <= numberOfMembers; i++) {
String id = USER + i;
userManager.createUser(id, null, new PrincipalImpl(id), REL_TEST_PATH);
}
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class UserManagerImplTest method testEnforceAuthorizableFolderHierarchy.
@Test
public void testEnforceAuthorizableFolderHierarchy() throws RepositoryException, CommitFailedException {
User user = userMgr.createUser(testUserId, null);
root.commit();
NodeUtil userNode = new NodeUtil(root.getTree(user.getPath()));
NodeUtil folder = userNode.addChild("folder", UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
String path = folder.getTree().getPath();
// authNode - authFolder -> create User
try {
Principal p = new PrincipalImpl("test2");
userMgr.createUser(p.getName(), p.getName(), p, path);
root.commit();
fail("Users may not be nested.");
} catch (CommitFailedException e) {
// success
} finally {
Authorizable a = userMgr.getAuthorizable("test2");
if (a != null) {
a.remove();
root.commit();
}
}
NodeUtil someContent = userNode.addChild("mystuff", JcrConstants.NT_UNSTRUCTURED);
path = someContent.getTree().getPath();
try {
// authNode - anyNode -> create User
try {
Principal p = new PrincipalImpl("test3");
userMgr.createUser(p.getName(), p.getName(), p, path);
root.commit();
fail("Users may not be nested.");
} catch (CommitFailedException e) {
// success
} finally {
Authorizable a = userMgr.getAuthorizable("test3");
if (a != null) {
a.remove();
root.commit();
}
}
// authNode - anyNode - authFolder -> create User
folder = someContent.addChild("folder", UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
// this time save node structure
root.commit();
try {
Principal p = new PrincipalImpl("test4");
userMgr.createUser(p.getName(), p.getName(), p, folder.getTree().getPath());
root.commit();
fail("Users may not be nested.");
} catch (CommitFailedException e) {
// success
} finally {
root.refresh();
Authorizable a = userMgr.getAuthorizable("test4");
if (a != null) {
a.remove();
root.commit();
}
}
} finally {
root.refresh();
Tree t = root.getTree(path);
if (t.exists()) {
t.remove();
root.commit();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class L3_UserVsPrincipalTest method testAccessControlEntryWithId.
@Test
public void testAccessControlEntryWithId() throws RepositoryException {
AccessControlManager acMgr = getAccessControlManager(root);
// EXERCISE fix the test case
String[] ids = new String[] { testId, testGroupId };
for (String id : ids) {
AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/");
acl.addAccessControlEntry(new PrincipalImpl(id), AccessControlUtils.privilegesFromNames(acMgr, PrivilegeConstants.JCR_READ));
}
}
Aggregations