use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class L7_ImpersonationTest method testAdvancedImpersonationTest.
public void testAdvancedImpersonationTest() throws RepositoryException {
// EXERCISE: change the permission setup such that the test-user is allowed to make himself an impersonator of 'another' user.
Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID()));
sessionList.add(testSession);
UserManager uMgr = ((JackrabbitSession) testSession).getUserManager();
User another = uMgr.getAuthorizable(anotherUser.getID(), User.class);
assertNotNull(another);
Principal princ = uMgr.getAuthorizable(testUser.getID()).getPrincipal();
another.getImpersonation().grantImpersonation(princ);
testSession.save();
testSession.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0])).logout();
try {
Session s = testSession.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0]));
sessionList.add(s);
fail("Test user must no longer be able to edit the impersonation of the test user");
} catch (LoginException e) {
// success
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class L4_PrivilegesAndPermissionsTest method tearDown.
@Override
protected void tearDown() throws Exception {
try {
if (testSession != null && testSession.isLive()) {
testSession.logout();
}
UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();
if (testUser != null) {
testUser.remove();
}
Authorizable testGroup = uMgr.getAuthorizable(testGroupPrincipal);
if (testGroup != null) {
testGroup.remove();
}
superuser.save();
} finally {
super.tearDown();
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class L5_SpecialPermissionsTest method tearDown.
@Override
protected void tearDown() throws Exception {
try {
if (testSession != null && testSession.isLive()) {
testSession.logout();
}
UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();
if (testUser != null) {
testUser.remove();
}
if (testUser2 != null) {
testUser2.remove();
}
Authorizable testGroup = uMgr.getAuthorizable(testGroupPrincipal);
if (testGroup != null) {
testGroup.remove();
}
removePolicies(paths);
superuser.save();
} finally {
super.tearDown();
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class L5_SpecialPermissionsTest method testRepositoryLevelPrivileges.
public void testRepositoryLevelPrivileges() throws RepositoryException {
// EXERCISE : setup the permissions such that test-session can register a
// - new namespace|node type|privilege (note: workspace management not yet supported)
// EXERCISE: refactory the test to verify that granting these privs at 'childPath' doesn;t have the desired effect.
JackrabbitSession s = (JackrabbitSession) createTestSession();
NamespaceRegistry nsRegistry = s.getWorkspace().getNamespaceRegistry();
nsRegistry.registerNamespace("jr", "http://jackrabbit.apache.org");
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class L7_PrivilegeDiscoveryTest method tearDown.
@Override
protected void tearDown() throws Exception {
try {
userSession.logout();
superuser.getNode(testPath).remove();
UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();
Authorizable a = uMgr.getAuthorizable("u");
if (a != null) {
a.remove();
}
a = uMgr.getAuthorizable("g");
if (a != null) {
a.remove();
}
superuser.save();
} finally {
super.tearDown();
}
}
Aggregations