use of javax.jcr.SimpleCredentials in project jackrabbit by apache.
the class CompatTokenProviderTest method testIsExpired.
public void testIsExpired() throws Exception {
TokenInfo info = tokenProvider.createToken(testuser, new SimpleCredentials(userId, userId.toCharArray()));
long loginTime = waitForSystemTimeIncrement(System.currentTimeMillis());
assertFalse(info.isExpired(loginTime));
assertTrue(info.isExpired(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION));
}
use of javax.jcr.SimpleCredentials in project jackrabbit by apache.
the class RemoveOrphanVersionHistoryTest method testWorkspaceRemoveOrphanVersionHistory.
/**
* Test orphan version history cleaning in multiple workspace.
* @throws RepositoryException if an error occurs.
*/
public void testWorkspaceRemoveOrphanVersionHistory() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1);
n.addMixin(mixVersionable);
testRootNode.save();
Session session = n.getSession();
VersionHistory vh = n.getVersionHistory();
String vhUuid = vh.getUUID();
assertExists(session, vhUuid);
// First version
Version v10 = n.checkin();
n.checkout();
Workspace defaultWorkspace = n.getSession().getWorkspace();
Session otherWsSession = n.getSession().getRepository().login(new SimpleCredentials("superuser", "".toCharArray()), workspaceName);
// Clone the node in another workspace
otherWsSession.getWorkspace().clone(defaultWorkspace.getName(), n.getPath(), n.getPath(), false);
Node otherWsRootNode = otherWsSession.getRootNode();
Node clonedNode = otherWsRootNode.getNode(n.getPath().substring(1));
// Ensure that version histories are the same
assertEquals(vhUuid, clonedNode.getVersionHistory().getUUID());
Version v11 = clonedNode.checkin();
clonedNode.checkout();
// Remove node
n.remove();
testRootNode.save();
assertExists(session, vhUuid);
assertExists(otherWsSession, vhUuid);
// Remove the first version
vh.removeVersion(v10.getName());
assertExists(session, vhUuid);
assertExists(otherWsSession, vhUuid);
// Remove cloned node
clonedNode.remove();
otherWsRootNode.save();
assertExists(session, vhUuid);
assertExists(otherWsSession, vhUuid);
// Remove the last version
vh.removeVersion(v11.getName());
try {
session.getNodeByUUID(vhUuid);
fail("Orphan version history must have been removed from the default workspace");
} catch (ItemNotFoundException e) {
// Expected
}
try {
otherWsSession.getNodeByUUID(vhUuid);
fail("Orphan version history must have been removed from the other workspace");
} catch (ItemNotFoundException e) {
// Expected
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit by apache.
the class AbstractRepositoryTest method testLoginWithCredentials.
/**
* Tests the {@link AbstractRepository#login(Credentials)} method.
*
* @throws RepositoryException if an error occurs
*/
public void testLoginWithCredentials() throws RepositoryException {
Credentials credentials = new SimpleCredentials("", "".toCharArray());
Repository repository = (Repository) record(AbstractRepository.class);
repository.login(credentials, null);
replay();
repository.login(credentials);
verify();
}
use of javax.jcr.SimpleCredentials in project jackrabbit by apache.
the class UserTest method testChangePassword.
public void testChangePassword() throws RepositoryException, NotExecutableException {
String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd");
if (oldPw == null) {
// missing property
throw new NotExecutableException();
}
User user = getTestUser(superuser);
try {
user.changePassword("pw");
save(superuser);
// make sure the user can login with the new pw
Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray()));
s.logout();
} finally {
user.changePassword(oldPw);
save(superuser);
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit by apache.
the class UserTest method testChangePasswordWithOldPassword2.
public void testChangePasswordWithOldPassword2() throws RepositoryException, NotExecutableException {
String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd");
if (oldPw == null) {
// missing property
throw new NotExecutableException();
}
User user = getTestUser(superuser);
try {
user.changePassword("pw", oldPw);
save(superuser);
Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), oldPw.toCharArray()));
s.logout();
fail("superuser pw has changed. login must fail.");
} catch (LoginException e) {
// success
} finally {
user.changePassword(oldPw);
save(superuser);
}
}
Aggregations