use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenInfoTest method testIsExpired.
@Test
public void testIsExpired() {
long loginTime = new Date().getTime();
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
assertFalse(info.isExpired(loginTime));
loginTime = new Date().getTime() + 3600000;
assertFalse(info.isExpired(loginTime));
long expiredTime = new Date().getTime() + 7200001;
assertTrue(info.isExpired(expiredTime));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenInfoTest method testRemoveTokenRemovesNode.
@Test
public void testRemoveTokenRemovesNode() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath());
Tree tokens = userTree.getChild(TOKENS_NODE_NAME);
String tokenNodePath = tokens.getChildren().iterator().next().getPath();
info.remove();
assertFalse(root.getTree(tokenNodePath).exists());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenInfoTest method testRemoveToken2.
@Test
public void testRemoveToken2() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
assertTrue(info.remove());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenInfoTest method testResetTokenExpiration.
@Test
public void testResetTokenExpiration() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
assertFalse(info.resetExpiration(new Date().getTime()));
long loginTime = new Date().getTime() + 3600000;
assertFalse(info.isExpired(loginTime));
assertTrue(info.resetExpiration(loginTime));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenAuthenticationTest method testGetUserId.
@Test
public void testGetUserId() throws LoginException {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
assertTrue(authentication.authenticate(new TokenCredentials(info.getToken())));
assertEquals(userId, authentication.getUserId());
}
Aggregations