use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testSyncUpdate.
@Test
public void testSyncUpdate() throws Exception {
// create user upfront in order to test update mode
Authorizable user = userManager.createUser(USER_ID, null);
ExternalUser externalUser = idp.getUser(USER_ID);
user.setProperty("rep:externalId", new ValueFactoryImpl(root, NamePathMapper.DEFAULT).createValue(externalUser.getExternalId().getString()));
root.commit();
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertTrue(user.hasProperty(USER_PROP));
assertNull(userManager.getAuthorizable(GROUP_DN));
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class LdapLoginTestBase method concurrentLogin.
private void concurrentLogin(String[] users) throws Exception {
final List<Exception> exceptions = new ArrayList<Exception>();
List<Thread> workers = new ArrayList<Thread>();
for (String userId : users) {
final String uid = userId;
workers.add(new Thread(new Runnable() {
public void run() {
try {
login(new SimpleCredentials(uid, USER_PWD.toCharArray())).close();
} catch (Exception e) {
exceptions.add(e);
}
}
}));
}
for (Thread t : workers) {
t.start();
}
for (Thread t : workers) {
t.join();
}
for (Exception e : exceptions) {
e.printStackTrace();
}
if (!exceptions.isEmpty()) {
throw exceptions.get(0);
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testReLogin.
@Test
public void testReLogin() throws Exception {
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
Authorizable user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertFalse(root.getTree(user.getPath()).hasProperty(UserConstants.REP_PASSWORD));
cs.close();
// login again
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
assertEquals(USER_ID, cs.getAuthInfo().getUserID());
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testLoginSetsAuthInfo.
@Test
public void testLoginSetsAuthInfo() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = new SimpleCredentials(USER_ID, USER_PWD.toCharArray());
sc.setAttribute("attr", "val");
cs = login(sc);
AuthInfo ai = cs.getAuthInfo();
assertEquals(USER_ID, ai.getUserID());
assertEquals("val", ai.getAttribute("attr"));
} finally {
if (cs != null) {
cs.close();
}
}
}
use of javax.jcr.SimpleCredentials 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();
}
}
}
Aggregations