use of javax.jcr.Session in project jackrabbit-oak by apache.
the class UserManagerTest method testUserIDFromSession.
@Test
public void testUserIDFromSession() throws RepositoryException, NotExecutableException {
User u = null;
Session uSession = null;
try {
String uid = createUserId();
u = userMgr.createUser(uid, "pw");
superuser.save();
uSession = superuser.getRepository().login(new SimpleCredentials(uid, "pw".toCharArray()));
assertEquals(u.getID(), uSession.getUserID());
} finally {
if (uSession != null) {
uSession.logout();
}
if (u != null) {
u.remove();
superuser.save();
}
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class UserManagerTest method testCleanupForAllWorkspaces.
@Test
public void testCleanupForAllWorkspaces() throws RepositoryException, NotExecutableException {
String[] workspaceNames = superuser.getWorkspace().getAccessibleWorkspaceNames();
for (String workspaceName1 : workspaceNames) {
Session s = getHelper().getSuperuserSession(workspaceName1);
try {
UserManager umgr = getUserManager(s);
s.logout();
// any more -> accessing users must fail.
try {
umgr.getAuthorizable("any userid");
fail("After having logged out the original session, the user manager must not be live any more.");
} catch (RepositoryException e) {
// success
}
} finally {
if (s.isLive()) {
s.logout();
}
}
}
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class IsMemberTest method beforeSuite.
@Override
protected void beforeSuite() throws Exception {
super.beforeSuite();
Session s = loginAdministrative();
try {
UserManager userManager = ((JackrabbitSession) s).getUserManager();
Group gr = userManager.createGroup(new PrincipalImpl(GROUP + 0), REL_TEST_PATH);
gPaths.add(gr.getPath());
for (int i = 1; i < GROUP_CNT; i++) {
Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), REL_TEST_PATH);
if (nestedGroups) {
g.addMember(gr);
}
gr = g;
gPaths.add(gr.getPath());
}
int cnt = 0;
for (int i = 0; i <= numberOfUsers; i++) {
User u = userManager.createUser(USER + i, null, new PrincipalImpl(USER + i), REL_TEST_PATH);
uPaths.add(u.getPath());
getRandomGroup(userManager).addMember(u);
if (++cnt == 20000) {
s.save();
}
}
} finally {
s.save();
s.logout();
}
System.out.println("setup done");
}
use of javax.jcr.Session in project jackrabbit-oak by apache.
the class MemberBaseTest 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();
}
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 javax.jcr.Session in project jackrabbit-oak by apache.
the class ObservationTest method addRootListener.
private void addRootListener(Repository repository, List<Session> sessions, List<EventListener> listeners) throws RepositoryException {
Session s = createSession(repository);
sessions.add(s);
Listener listener = new Listener(new AtomicInteger());
ObservationManager obsMgr = s.getWorkspace().getObservationManager();
obsMgr.addEventListener(listener, EVENT_TYPES, "/", true, null, null, false);
listeners.add(listener);
}
Aggregations