Package org.agorava.api.oauth

Examples of org.agorava.api.oauth.Token


     */
    public Token extract(String response) {
        Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");
        String token = extract(response, TOKEN_REGEX);
        String secret = extract(response, SECRET_REGEX);
        return new Token(token, secret);
    }
View Full Code Here


        return AgoravaConstants.VERIFIER;
    }

    @Override
    public String getAuthorizationUrl() {
        Token token = getRequestToken();
        getSession().setRequestToken(token);
        return getAuthorizationUrl(token);
    }
View Full Code Here

import static org.junit.Assert.assertEquals;

public class TokenTest {
    @Test
    public void shouldTestEqualityBasedOnTokenAndSecret() throws Exception {
        Token expected = new Token("access", "secret");
        Token actual = new Token("access", "secret");

        assertEquals(expected, actual);
        assertEquals(actual, actual);
    }
View Full Code Here

        assertEquals(actual, actual);
    }

    @Test
    public void shouldNotDependOnRawString() throws Exception {
        Token expected = new Token("access", "secret");
        Token actual = new Token("access", "secret");

        assertEquals(expected, actual);
    }
View Full Code Here

        assertEquals(expected, actual);
    }

    @Test
    public void shouldReturnSameHashCodeForEqualObjects() throws Exception {
        Token expected = new Token("access", "secret");
        Token actual = new Token("access", "secret");

        assertEquals(expected.hashCode(), actual.hashCode());
    }
View Full Code Here

        assertEquals(expected.hashCode(), actual.hashCode());
    }

    @Test
    public void shouldNotBeEqualToNullOrOtherObjects() throws Exception {
        Token expected = new Token("access", "secret");

        assertNotSame(expected, null);
        assertNotSame(expected, new Object());
    }
View Full Code Here

    public Token extract(String response) {
        Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
        Matcher matcher = accessTokenPattern.matcher(response);
        if (matcher.find()) {
            return new Token(matcher.group(1), "");
        } else {
            throw new AgoravaException("Cannot extract an acces token. Response was: " + response);
        }
    }
View Full Code Here

        Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");

        Matcher matcher = Pattern.compile(TOKEN_REGEX).matcher(response);
        if (matcher.find()) {
            String token = OAuthEncoder.decode(matcher.group(1));
            return new Token(token, EMPTY_SECRET);
        } else {
            throw new AgoravaException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
        }
    }
View Full Code Here

    }

    @Override
    public void setAccessToken(String token, String secret) {
        OAuthSession session = getSession();
        session.setAccessToken(new Token(token, secret));

    }
View Full Code Here

        Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string");

        Matcher matcher = Pattern.compile(TOKEN_REGEX).matcher(response);
        if (matcher.find()) {
            String token = OAuthEncoder.decode(matcher.group(1));
            return new Token(token, EMPTY_SECRET);
        } else {
            throw new AgoravaException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null);
        }

    }
View Full Code Here

TOP

Related Classes of org.agorava.api.oauth.Token

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.