use of org.apache.jackrabbit.api.security.authentication.token.TokenCredentials in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testInvalidTokenCredentials.
@Test
public void testInvalidTokenCredentials() throws Exception {
ContentSession cs = null;
try {
cs = login(new TokenCredentials("invalid"));
fail("Invalid token credentials login should fail");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.api.security.authentication.token.TokenCredentials in project jackrabbit-oak by apache.
the class Jackrabbit2ConfigurationTest method testTokenLoginForDisabledUser.
@Test
public void testTokenLoginForDisabledUser() throws Exception {
ContentSession cs = null;
try {
User user = getTestUser();
SimpleCredentials sc = new SimpleCredentials(user.getID(), user.getID().toCharArray());
sc.setAttribute(".token", "");
cs = login(sc);
user.disable("disabled");
root.commit();
Object token = sc.getAttribute(".token").toString();
assertNotNull(token);
TokenCredentials tc = new TokenCredentials(token.toString());
cs.close();
cs = login(tc);
fail("token login for a disabled user must fail.");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.api.security.authentication.token.TokenCredentials in project jackrabbit-oak by apache.
the class TokenAuthenticationTest method testAuthenticateWithInvalidTokenCredentials.
@Test
public void testAuthenticateWithInvalidTokenCredentials() throws Exception {
try {
authentication.authenticate(new TokenCredentials(UUID.randomUUID().toString()));
fail("LoginException expected");
} catch (LoginException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.authentication.token.TokenCredentials in project jackrabbit-oak by apache.
the class TokenAuthenticationTest method testAuthenticateWithoutTokenProvider.
@Test
public void testAuthenticateWithoutTokenProvider() throws Exception {
Authentication authentication = new TokenAuthentication(null);
assertFalse(authentication.authenticate(new TokenCredentials("token")));
}
use of org.apache.jackrabbit.api.security.authentication.token.TokenCredentials 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