use of org.apache.jackrabbit.api.JackrabbitSession 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();
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class OakOSGiRepositoryFactoryTest method testCallback.
private void testCallback(Repository repository) throws RepositoryException {
JackrabbitSession session = (JackrabbitSession) repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
String testUserId = "footest";
User testUser = (User) session.getUserManager().getAuthorizable(testUserId);
if (testUser == null) {
testUser = session.getUserManager().createUser(testUserId, "password");
}
session.save();
testUser.changePassword("newPassword");
session.save();
assertEquals("newPassword", newPassword);
session.logout();
}
use of org.apache.jackrabbit.api.JackrabbitSession in project jackrabbit-oak by apache.
the class L4_EffectivePoliciesTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Node child = testRootNode.addNode(nodeName1);
childPath = child.getPath();
testUser = ExerciseUtility.createTestUser(((JackrabbitSession) superuser).getUserManager());
testPrincipal = testUser.getPrincipal();
superuser.save();
acMgr = (JackrabbitAccessControlManager) superuser.getAccessControlManager();
acl = AccessControlUtils.getAccessControlList(superuser, testRoot);
if (acl == null) {
throw new NotExecutableException();
}
testPrivileges = AccessControlUtils.privilegesFromNames(acMgr, Privilege.JCR_READ, Privilege.JCR_WRITE);
}
use of org.apache.jackrabbit.api.JackrabbitSession in project sling by apache.
the class TcclWrappingJackrabbitRepository method login.
@Override
public Session login(Credentials credentials, String workspaceName, Map<String, Object> attributes) throws LoginException, NoSuchWorkspaceException, RepositoryException {
Thread thread = Thread.currentThread();
ClassLoader oldClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader(Oak.class.getClassLoader());
try {
Session session = wrapped.login(credentials, workspaceName, attributes);
return new TcclWrappingJackrabbitSession((JackrabbitSession) session);
} finally {
thread.setContextClassLoader(oldClassLoader);
}
}
use of org.apache.jackrabbit.api.JackrabbitSession in project sling by apache.
the class TcclWrappingJackrabbitSession method impersonate.
// calls setting the TCCL
@Override
public Session impersonate(Credentials credentials) throws LoginException, RepositoryException {
Thread thread = Thread.currentThread();
ClassLoader oldClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader(Oak.class.getClassLoader());
try {
Session session = wrapped.impersonate(credentials);
return new TcclWrappingJackrabbitSession((JackrabbitSession) session);
} finally {
thread.setContextClassLoader(oldClassLoader);
}
}
Aggregations