use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetUserManagerFromCallback.
@Test
public void testGetUserManagerFromCallback() {
AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(Mockito.mock(UserManager.class)));
UserManager userManager = loginModule.getUserManager();
assertNotNull(userManager);
// usermanager is stored as field -> second access returns the same object
assertSame(userManager, loginModule.getUserManager());
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class QueryTest method xpathEscapeTest.
@SuppressWarnings("deprecation")
@Test
public void xpathEscapeTest() throws RepositoryException {
Session writer = createAdminSession();
Session reader = createAdminSession();
UserManager uMgr = ((JackrabbitSession) writer).getUserManager();
String uid = "testUser";
try {
User user = uMgr.createUser("testUser", "pw");
writer.getNode(user.getPath()).addNode(".tokens", "rep:Unstructured");
writer.save();
QueryManager qm = reader.getWorkspace().getQueryManager();
Query q = qm.createQuery("/jcr:root//*[_x002e_tokens/@jcr:primaryType]", Query.XPATH);
NodeIterator res = q.execute().getNodes();
assertEquals(1, res.getSize());
} finally {
Authorizable a = uMgr.getAuthorizable(uid);
if (a != null) {
a.remove();
writer.save();
}
if (reader != null) {
reader.logout();
}
if (writer != null) {
writer.logout();
}
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagerTest method testCleanup.
@Test
public void testCleanup() throws RepositoryException, NotExecutableException {
Session s = getHelper().getSuperuserSession();
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 org.apache.jackrabbit.api.security.user.UserManager 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 org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class AbstractPrincipalProviderTest method testFindUserPrincipal.
@Test
public void testFindUserPrincipal() throws Exception {
User testUser = null;
try {
UserManager userMgr = getUserManager(root);
testUser = userMgr.createUser("TestUser", "pw");
root.commit();
String principalName = testUser.getPrincipal().getName();
assertNotNull(principalProvider.getPrincipal(principalName));
List<String> nameHints = new ArrayList<String>();
nameHints.add("TestUser");
nameHints.add("Test");
nameHints.add("User");
nameHints.add("stUs");
assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_NOT_GROUP, true);
assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_ALL, true);
assertResult(principalProvider, nameHints, principalName, PrincipalManager.SEARCH_TYPE_GROUP, false);
} finally {
if (testUser != null) {
testUser.remove();
root.commit();
}
}
}
Aggregations