use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class PasswordForceInitialPasswordChangeTest method testAuthenticateMustChangePassword.
@Test
public void testAuthenticateMustChangePassword() throws Exception {
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
try {
a.authenticate(new SimpleCredentials(userId, userId.toCharArray()));
fail("Credentials should be expired");
} catch (CredentialExpiredException e) {
// success
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class PasswordExpiryTest method testAuthenticatePasswordExpired.
@Test
public void testAuthenticatePasswordExpired() throws Exception {
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
// set password last modified to beginning of epoch
root.getTree(getTestUser().getPath()).getChild(UserConstants.REP_PWD).setProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED, 0);
root.commit();
try {
a.authenticate(new SimpleCredentials(userId, userId.toCharArray()));
fail("Credentials should be expired");
} catch (CredentialExpiredException e) {
// success
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class ResetExpiredPasswordTest method authenticate.
private void authenticate(String expiredPw, Object newPw) throws LoginException {
SimpleCredentials creds = new SimpleCredentials(userId, expiredPw.toCharArray());
creds.setAttribute(UserConstants.CREDENTIALS_ATTRIBUTE_NEWPASSWORD, newPw);
Authentication a = new UserAuthentication(getUserConfiguration(), root, userId);
a.authenticate(creds);
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class RepositoryBootIT method repositoryLogin.
@Test
public void repositoryLogin() throws Exception {
//Simple sanity test to see if repository is working
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
session.logout();
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class ConcurrentAddNodesClusterIT method addNodes2.
@Test
public void addNodes2() throws Exception {
for (int i = 0; i < 3; i++) {
DocumentMK mk = new DocumentMK.Builder().setMongoDB(createConnection().getDB()).setAsyncDelay(0).setClusterId(i + 1).open();
mks.add(mk);
}
final DocumentMK mk1 = mks.get(0);
final DocumentMK mk2 = mks.get(1);
final DocumentMK mk3 = mks.get(2);
Repository r1 = new Jcr(mk1.getNodeStore()).createRepository();
repos.add(r1);
Repository r2 = new Jcr(mk2.getNodeStore()).createRepository();
repos.add(r2);
Repository r3 = new Jcr(mk3.getNodeStore()).createRepository();
repos.add(r3);
Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));
Session s3 = r3.login(new SimpleCredentials("admin", "admin".toCharArray()));
ensureIndex(s1.getRootNode(), PROP_NAME);
runBackgroundOps(mk1);
runBackgroundOps(mk2);
runBackgroundOps(mk3);
// begin test
Node root2 = s2.getRootNode().addNode("testroot-Worker-2", "nt:unstructured");
createNodes(root2, "testnode0");
s2.save();
createNodes(root2, "testnode1");
runBackgroundOps(mk1);
runBackgroundOps(mk3);
// publish 'testroot-Worker-2/testnode0'
runBackgroundOps(mk2);
Node root3 = s3.getRootNode().addNode("testroot-Worker-3", "nt:unstructured");
createNodes(root3, "testnode0");
s2.save();
createNodes(root2, "testnode2");
// sees 'testroot-Worker-2/testnode0'
runBackgroundOps(mk1);
// sees 'testroot-Worker-2/testnode0'
runBackgroundOps(mk3);
// publish 'testroot-Worker-2/testnode1'
runBackgroundOps(mk2);
// subsequent read on mk3 will read already published docs from mk2
s3.save();
createNodes(root3, "testnode1");
Node root1 = s1.getRootNode().addNode("testroot-Worker-1", "nt:unstructured");
createNodes(root1, "testnode0");
s2.save();
createNodes(root2, "testnode3");
runBackgroundOps(mk1);
runBackgroundOps(mk3);
runBackgroundOps(mk2);
s1.save();
createNodes(root1, "testnode1");
s3.save();
createNodes(root3, "testnode2");
runBackgroundOps(mk1);
s1.save();
s1.logout();
s2.logout();
s3.logout();
}
Aggregations