use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class GetPrincipalTest method runTest.
@Override
protected void runTest() throws Exception {
Session s = loginWriter();
PrincipalManager principalManager = ((JackrabbitSession) s).getPrincipalManager();
for (int i = 0; i < 1000; i++) {
Principal p = principalManager.getPrincipal(getUserId());
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class RemoveMembersTest method runTest.
@Override
public void runTest() throws Exception {
Session s = null;
try {
// use system session login to avoid measuring the login-performance here
s = systemLogin();
UserManager userManager = ((JackrabbitSession) s).getUserManager();
String groupPath = groupPaths.get(random.nextInt(GROUP_CNT));
Group g = (Group) userManager.getAuthorizableByPath(groupPath);
removeMembers(userManager, g, s);
} catch (RepositoryException e) {
if (s.hasPendingChanges()) {
s.refresh(false);
}
} finally {
if (s != null) {
s.logout();
}
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class RemoveMembersTest method afterSuite.
@Override
public void afterSuite() throws Exception {
Session s = loginAdministrative();
try {
Authorizable authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(GROUP + "0");
if (authorizable != null) {
Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
n.remove();
}
// remove test-users if they have been created
authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(USER + "0");
if (authorizable != null) {
Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1));
n.remove();
}
s.save();
} finally {
s.logout();
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit by apache.
the class NestedGroupTest method testInheritedMembership.
public void testInheritedMembership() throws NotExecutableException, RepositoryException {
Group gr1 = null;
Group gr2 = null;
Group gr3 = null;
if (!(superuser instanceof JackrabbitSession)) {
throw new NotExecutableException();
}
try {
gr1 = createGroup(getTestPrincipal());
gr2 = createGroup(getTestPrincipal());
gr3 = createGroup(getTestPrincipal());
assertTrue(addMember(gr1, gr2));
assertTrue(addMember(gr2, gr3));
// NOTE: don't test with Group.isMember for not required to detect
// inherited membership -> rather with PrincipalManager.
boolean isMember = false;
PrincipalManager pmgr = ((JackrabbitSession) superuser).getPrincipalManager();
for (PrincipalIterator it = pmgr.getGroupMembership(gr3.getPrincipal()); it.hasNext() && !isMember; ) {
isMember = it.nextPrincipal().equals(gr1.getPrincipal());
}
assertTrue(isMember);
} finally {
if (gr1 != null && gr1.isMember(gr2)) {
removeMember(gr1, gr2);
}
if (gr2 != null && gr2.isMember(gr3)) {
removeMember(gr2, gr3);
}
if (gr1 != null)
removeGroup(gr1);
if (gr2 != null)
removeGroup(gr2);
if (gr3 != null)
removeGroup(gr3);
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit by apache.
the class SessionImplTest method testSessionHasPermission.
/**
* @see <a href="https://issues.apache.org/jira/browse/JCR-3885">JCR-3885</a>
*/
public void testSessionHasPermission() throws Exception {
JackrabbitSession js = (JackrabbitSession) superuser;
assertEquals(superuser.hasPermission("/", Session.ACTION_READ), js.hasPermission("/", new String[] { Session.ACTION_READ }));
assertEquals(superuser.hasPermission("/", Session.ACTION_READ + "," + Session.ACTION_ADD_NODE), js.hasPermission("/", Session.ACTION_READ, Session.ACTION_ADD_NODE));
try {
js.hasPermission("/", new String[0]);
fail();
} catch (IllegalArgumentException e) {
// success
}
try {
js.hasPermission("/", new String[] { "" });
fail();
} catch (IllegalArgumentException e) {
// success
}
// note: that's a bit unexpected
assertEquals(superuser.hasPermission("/", ",,"), js.hasPermission("/", "", "", ""));
}
Aggregations