use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class RepositoryGroupMemberUpgradeTest method createSourceContent.
@Override
protected void createSourceContent(Session session) throws Exception {
UserManager userMgr = ((JackrabbitSession) session).getUserManager();
userMgr.autoSave(false);
User[] users = new User[getNumUsers()];
for (int i = 0; i < users.length; i++) {
String userId = TEST_USER_PREFIX + i;
users[i] = userMgr.createUser(userId, userId);
}
for (int i = 0; i < getNumGroups(); i++) {
Group g = userMgr.createGroup(TEST_GROUP_PREFIX + i);
for (User user : users) {
g.addMember(user);
}
}
session.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class LoginModuleImplTest method createTestUser.
private User createTestUser() throws RepositoryException, CommitFailedException {
if (user == null) {
UserManager userManager = getUserManager(root);
user = userManager.createUser(USER_ID, USER_PW);
root.commit();
}
return user;
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testUserLoginIsCaseInsensitive.
@Test
public void testUserLoginIsCaseInsensitive() throws Exception {
ContentSession cs = null;
try {
createTestUser();
cs = login(new SimpleCredentials(USER_ID_CASED, USER_PW.toCharArray()));
AuthInfo authInfo = cs.getAuthInfo();
UserManager userMgr = getUserManager(root);
Authorizable auth = userMgr.getAuthorizable(authInfo.getUserID());
assertNotNull(auth);
assertTrue(auth.getID().equalsIgnoreCase(USER_ID_CASED));
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testAnonymousLogin.
@Test
public void testAnonymousLogin() throws Exception {
String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
UserManager userMgr = getUserManager(root);
// verify initial user-content looks like expected
Authorizable anonymous = userMgr.getAuthorizable(anonymousID);
assertNotNull(anonymous);
assertFalse(root.getTree(anonymous.getPath()).hasProperty(UserConstants.REP_PASSWORD));
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(anonymousID, new char[0]));
fail("Login with anonymousID should fail since the initial setup doesn't provide a password.");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class Jr2CompatibilityTest method testUserManagementPermissionWithJr2Flag.
@Test
public void testUserManagementPermissionWithJr2Flag() throws Exception {
Root testRoot = getTestRoot();
testRoot.refresh();
UserManager testUserMgr = getUserConfiguration().getUserManager(testRoot, NamePathMapper.DEFAULT);
try {
User u = testUserMgr.createUser("a", "b");
testRoot.commit();
u.changePassword("c");
testRoot.commit();
u.remove();
testRoot.commit();
} finally {
root.refresh();
Authorizable user = getUserManager(root).getAuthorizable("a");
if (user != null) {
user.remove();
root.commit();
}
}
}
Aggregations