use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class L11_PasswordTest method testCreateUserAndLogin.
public void testCreateUserAndLogin() throws RepositoryException {
testUser = userManager.createUser(testId, TEST_PW);
superuser.save();
// EXERCISE build the credentials
Credentials creds = null;
getHelper().getRepository().login(creds).logout();
}
use of javax.jcr.Credentials in project jackrabbit-oak by apache.
the class UserTest method testLoginWithGetCredentials.
@Test
public void testLoginWithGetCredentials() throws RepositoryException, NotExecutableException {
try {
Credentials creds = user.getCredentials();
Session s = getHelper().getRepository().login(creds);
s.logout();
fail("Login using credentials exposed on user must fail.");
} catch (UnsupportedRepositoryOperationException e) {
throw new NotExecutableException(e.getMessage());
} catch (LoginException e) {
// success
}
}
use of javax.jcr.Credentials in project jackrabbit by apache.
the class UserManagerImplTest method testNewUserCanLogin.
public void testNewUserCanLogin() throws RepositoryException, NotExecutableException {
String uid = getTestPrincipal().getName();
String pw = buildPassword(uid);
User u = null;
Session s = null;
try {
u = userMgr.createUser(uid, pw);
save(superuser);
Credentials creds = new SimpleCredentials(uid, pw.toCharArray());
s = superuser.getRepository().login(creds);
} finally {
if (u != null) {
u.remove();
save(superuser);
}
if (s != null) {
s.logout();
}
}
}
use of javax.jcr.Credentials in project jackrabbit by apache.
the class UserImplTest method testLoginWithCryptedCredentials.
public void testLoginWithCryptedCredentials() throws RepositoryException {
User u = (User) uMgr.getAuthorizable(uID);
Credentials creds = u.getCredentials();
assertTrue(creds instanceof CryptedSimpleCredentials);
try {
Session s = getHelper().getRepository().login(u.getCredentials());
s.logout();
fail("Login using CryptedSimpleCredentials must fail.");
} catch (LoginException e) {
// success
}
}
use of javax.jcr.Credentials in project jackrabbit by apache.
the class UserImplTest method testUserImplHasCryptedSimplCredentials.
public void testUserImplHasCryptedSimplCredentials() throws RepositoryException, NotExecutableException {
User user = getTestUser(superuser);
Credentials creds = user.getCredentials();
assertNotNull(creds);
assertTrue(creds instanceof CryptedSimpleCredentials);
assertEquals(((CryptedSimpleCredentials) creds).getUserID(), user.getID());
}
Aggregations