use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class AbstractRemoveMembersByIdTest method removeExistingMemberWithoutAccess.
Set<String> removeExistingMemberWithoutAccess() throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testGroup.getPath());
if (acl != null) {
if (acl.addEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ, PrivilegeConstants.REP_USER_MANAGEMENT), true)) {
acMgr.setPolicy(testGroup.getPath(), acl);
root.commit();
}
}
String userId = getTestUser().getID();
ContentSession testSession = null;
try {
testSession = login(new SimpleCredentials(userId, userId.toCharArray()));
Root testRoot = testSession.getLatestRoot();
assertFalse(testRoot.getTree(memberGroup.getPath()).exists());
Group gr = getUserManager(testRoot).getAuthorizable(testGroup.getID(), Group.class);
Set<String> failed = gr.removeMembers(memberGroup.getID());
testRoot.commit();
return failed;
} finally {
if (testSession != null) {
testSession.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class SystemUserImplTest method testImpersonateDisabledSystemUser.
@Test
public void testImpersonateDisabledSystemUser() throws Exception {
User user = createUser(null);
user.disable("disabled");
root.commit();
try {
ContentSession cs = login(new ImpersonationCredentials(new SimpleCredentials(uid, new char[0]), adminSession.getAuthInfo()));
cs.close();
fail();
} catch (LoginException e) {
// success
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class SystemUserImplTest method testImpersonateSystemUser.
@Test
public void testImpersonateSystemUser() throws Exception {
createUser(null);
ContentSession cs = login(new ImpersonationCredentials(new SimpleCredentials(uid, new char[0]), adminSession.getAuthInfo()));
cs.close();
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class L6_AdministratativeAccessTest method testAdministrativeConfiguration.
@Test
public void testAdministrativeConfiguration() throws Exception {
// EXERCISE once you have defined the right permission-eval configuration options
// EXERCISE the test principal should be treated as 'administrative' principal and the test should pass.
ContentSession testSession = createTestSession();
try {
Root testRoot = testSession.getLatestRoot();
Tree rootTree = testRoot.getTree("/");
// EXERCISE walk through the add + remove
NodeUtil child = new NodeUtil(rootTree).addChild("test", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
child.setString("prop", "val");
testRoot.commit();
child.getTree().remove();
testRoot.commit();
} finally {
testSession.close();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ContentRemoteRepository method login.
@Override
public RemoteSession login(RemoteCredentials remoteCredentials) throws RemoteLoginException {
ContentRemoteCredentials contentRemoteCredentials = null;
if (remoteCredentials instanceof ContentRemoteCredentials) {
contentRemoteCredentials = (ContentRemoteCredentials) remoteCredentials;
}
if (contentRemoteCredentials == null) {
throw new IllegalArgumentException("invalid credentials");
}
Thread thread = Thread.currentThread();
ClassLoader loader = thread.getContextClassLoader();
thread.setContextClassLoader(Oak.class.getClassLoader());
ContentSession session;
try {
session = contentRemoteCredentials.login(contentRepository);
} finally {
thread.setContextClassLoader(loader);
}
return new ContentRemoteSession(session, contentRemoteRevisions, contentRemoteBinaries);
}
Aggregations