Search in sources :

Example 21 with TokenInfo

use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.

the class TokenProviderImplReadOnlyTest method generateToken.

private String generateToken() throws Exception {
    TokenInfo info = tokenProvider.createToken(getTestUser().getID(), ImmutableMap.<String, Object>of());
    String token = info.getToken();
    readOnlyRoot.refresh();
    return token;
}
Also used : TokenInfo(org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo)

Example 22 with TokenInfo

use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.

the class TokenProviderImplReadOnlyTest method testRemoveToken.

@Test
public void testRemoveToken() throws Exception {
    TokenInfo readOnlyInfo = readOnlyTp.getTokenInfo(generateToken());
    assertFalse(readOnlyInfo.remove());
}
Also used : TokenInfo(org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo) Test(org.junit.Test)

Example 23 with TokenInfo

use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.

the class TokenProviderImplReadOnlyTest method testGetTokenInfo.

@Test
public void testGetTokenInfo() throws Exception {
    TokenInfo readOnlyInfo = readOnlyTp.getTokenInfo(generateToken());
    assertNotNull(readOnlyInfo);
}
Also used : TokenInfo(org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo) Test(org.junit.Test)

Example 24 with TokenInfo

use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.

the class TokenProviderImplTest method testTokenNodeName.

@Test
public void testTokenNodeName() throws Exception {
    TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
    Tree tokenTree = getTokenTree(info);
    // creation which is not expected here.
    try {
        UUID.fromString(tokenTree.getName());
        fail("UUID-name should only be used in case of conflict");
    } catch (IllegalArgumentException e) {
    // success
    }
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) TokenInfo(org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo) Test(org.junit.Test)

Example 25 with TokenInfo

use of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo in project jackrabbit-oak by apache.

the class TokenAuthenticationTest method testGetTokenInfoAfterAuthenticate.

@Test
public void testGetTokenInfoAfterAuthenticate() throws Exception {
    TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
    authentication.authenticate(new TokenCredentials(info.getToken()));
    TokenInfo info2 = authentication.getTokenInfo();
    assertNotNull(info2);
    assertEquals(info.getUserId(), info2.getUserId());
}
Also used : TokenInfo(org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo) TokenCredentials(org.apache.jackrabbit.api.security.authentication.token.TokenCredentials) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

TokenInfo (org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo)51 Test (org.junit.Test)47 Tree (org.apache.jackrabbit.oak.api.Tree)15 TokenCredentials (org.apache.jackrabbit.api.security.authentication.token.TokenCredentials)14 NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)13 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)10 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)8 Date (java.util.Date)7 SimpleCredentials (javax.jcr.SimpleCredentials)5 Root (org.apache.jackrabbit.oak.api.Root)4 TokenProvider (org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider)4 HashMap (java.util.HashMap)3 Credentials (javax.jcr.Credentials)3 LoginException (javax.security.auth.login.LoginException)3 TokenConfiguration (org.apache.jackrabbit.oak.spi.security.authentication.token.TokenConfiguration)3 ArrayList (java.util.ArrayList)2 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)2 ImpersonationCredentials (org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1