use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenAuthenticationTest method testAuthenticate.
@Test
public void testAuthenticate() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
assertTrue(authentication.authenticate(new TokenCredentials(info.getToken())));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenAuthenticationTest method testAuthenticateNotMatchingToken.
@Test
public void testAuthenticateNotMatchingToken() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, ImmutableMap.of(TokenConstants.TOKEN_ATTRIBUTE + "_mandatory", "val"));
try {
authentication.authenticate(new TokenCredentials(info.getToken()));
fail("LoginException expected");
} catch (LoginException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenNoRefreshTest method testNotReset.
@Test
public void testNotReset() {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
assertNotNull(info);
assertFalse(info.resetExpiration(new Date().getTime()));
long loginTime = new Date().getTime() + 3600000;
assertFalse(info.resetExpiration(loginTime));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenProviderImplTest method testCreateTokenFromCredentials.
@Test
public void testCreateTokenFromCredentials() throws Exception {
SimpleCredentials sc = new SimpleCredentials(userId, new char[0]);
List<Credentials> valid = new ArrayList<Credentials>();
valid.add(sc);
valid.add(new ImpersonationCredentials(sc, null));
for (Credentials creds : valid) {
TokenInfo info = tokenProvider.createToken(creds);
assertTokenInfo(info, userId);
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.
the class TokenProviderImplTest method testGetTokenInfoFromDisabledUser.
@Test
public void testGetTokenInfoFromDisabledUser() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
getTestUser().disable("disabled");
assertNull(tokenProvider.getTokenInfo(info.getToken()));
}
Aggregations