Package org.apache.jackrabbit.oak.spi.security.authentication.token

Examples of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo


        assertFalse(tokenProvider.resetTokenExpiration(info, expiredTime));
    }

    @Test
    public void testResetTokenExpiration() throws Exception {
        TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());

        assertFalse(tokenProvider.resetTokenExpiration(info, new Date().getTime()));

        long loginTime = new Date().getTime() + 3600000;
        assertFalse(info.isExpired(loginTime));
        assertTrue(tokenProvider.resetTokenExpiration(info, loginTime));
    }
View Full Code Here


    public void testValidTokenCredentials() throws Exception {
        Root root = adminSession.getLatestRoot();
        TokenProvider tp = getSecurityProvider().getAuthenticationConfiguration().getTokenProvider(root);

        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        TokenInfo info = tp.createToken(sc.getUserID(), Collections.<String, Object>emptyMap());

        ContentSession cs = login(new TokenCredentials(info.getToken()));
        try {
            assertEquals(sc.getUserID(), cs.getAuthInfo().getUserID());
        } finally {
            cs.close();
        }
View Full Code Here

    }

    @Override
    public TokenInfo createToken(Credentials credentials) {
        SimpleCredentials sc = extractSimpleCredentials(credentials);
        TokenInfo tokenInfo = null;
        if (sc != null) {
            String[] attrNames = sc.getAttributeNames();
            Map<String, String> attributes = new HashMap<String, String>(attrNames.length);
            for (String attrName : sc.getAttributeNames()) {
                attributes.put(attrName, sc.getAttribute(attrName).toString());
            }
            tokenInfo = createToken(sc.getUserID(), attributes);
            if (tokenInfo != null) {
                // also set the new token to the simple credentials.
                sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken());
            }
        }

        return tokenInfo;
    }
View Full Code Here

        }

        if (tokenProvider != null && sharedState.containsKey(SHARED_KEY_CREDENTIALS)) {
            Credentials shared = getSharedCredentials();
            if (shared != null && tokenProvider.doCreateToken(shared)) {
                TokenInfo ti = tokenProvider.createToken(shared);
                if (ti != null) {
                    TokenCredentials tc = new TokenCredentials(ti.getToken());
                    Map<String, String> attributes = ti.getPrivateAttributes();
                    for (String name : attributes.keySet()) {
                        tc.setAttribute(name, attributes.get(name));
                    }
                    attributes = ti.getPublicAttributes();
                    for (String name : attributes.keySet()) {
                        tc.setAttribute(name, attributes.get(name));
                    }
                    subject.getPublicCredentials().add(tc);
                }
View Full Code Here

        clearState();

        if (tokenProvider != null && sharedState.containsKey(SHARED_KEY_CREDENTIALS)) {
            Credentials shared = getSharedCredentials();
            if (shared != null && tokenProvider.doCreateToken(shared)) {
                TokenInfo ti = tokenProvider.createToken(shared);
                if (ti != null) {
                    TokenCredentials tc = new TokenCredentials(ti.getToken());
                    Map<String, String> attributes = ti.getPrivateAttributes();
                    for (String name : attributes.keySet()) {
                        tc.setAttribute(name, attributes.get(name));
                    }
                    attributes = ti.getPublicAttributes();
                    for (String name : attributes.keySet()) {
                        tc.setAttribute(name, attributes.get(name));
                    }
                    subject.getPublicCredentials().add(tc);
                }
View Full Code Here

    }

    @Override
    public TokenInfo createToken(Credentials credentials) {
        SimpleCredentials sc = extractSimpleCredentials(credentials);
        TokenInfo tokenInfo = null;
        if (sc != null) {
            String[] attrNames = sc.getAttributeNames();
            Map<String, String> attributes = new HashMap<String, String>(attrNames.length);
            for (String attrName : sc.getAttributeNames()) {
                attributes.put(attrName, sc.getAttribute(attrName).toString());
            }
            tokenInfo = createToken(sc.getUserID(), attributes);
            if (tokenInfo != null) {
                // also set the new token to the simple credentials.
                sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken());
            }
        }

        return tokenInfo;
    }
View Full Code Here

    public void testValidTokenCredentials() throws Exception {
        Root root = adminSession.getLatestRoot();
        TokenProvider tp = getSecurityProvider().getAuthenticationConfiguration().getTokenProvider(root);

        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        TokenInfo info = tp.createToken(sc.getUserID(), Collections.<String, Object>emptyMap());

        ContentSession cs = login(new TokenCredentials(info.getToken()));
        try {
            assertEquals(sc.getUserID(), cs.getAuthInfo().getUserID());
        } finally {
            cs.close();
        }
View Full Code Here

*/
public class TokenInfoTest extends AbstractTokenTest {

    @Test
    public void testGetUserId() {
        TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
        assertEquals(userId, info.getUserId());

        info = tokenProvider.getTokenInfo(info.getToken());
        assertEquals(userId, info.getUserId());
    }
View Full Code Here

        assertEquals(userId, info.getUserId());
    }

    @Test
    public void testGetToken() {
        TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
        assertNotNull(info.getToken());

        info = tokenProvider.getTokenInfo(info.getToken());
        assertNotNull(info.getToken());
    }
View Full Code Here

    @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));
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.