Package oauth.signpost.basic

Examples of oauth.signpost.basic.DefaultOAuthConsumer


     * @param token the token obtained from a previous call
     * @param secret your application secret
     * @return a Response object holding either the result in case of a success or the error
     */
    public Response retrieveAccessToken(String token, String secret) {
         OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
        consumer.setTokenWithSecret(token, secret);
        String verifier = Params.current().get("oauth_verifier");
        try {
            provider.retrieveAccessToken(consumer, verifier);
        } catch (OAuthException e) {
            return Response.error(new Error(e));
        }
        return Response.success(consumer.getToken(), consumer.getTokenSecret());
    }
View Full Code Here


    /**
     * Request the request token and secret.
     * @return a Response object holding either the result in case of a success or the error
     */
    public Response retrieveRequestToken() {
        OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
        String callbackURL = Request.current().getBase() + Request.current().url;
        try {
            provider.retrieveRequestToken(consumer, callbackURL);
        } catch (OAuthException e) {
            return Response.error(new Error(e));
        }
        return Response.success(consumer.getToken(), consumer.getTokenSecret());
    }
View Full Code Here

    public Response retrieveAccessToken(Response requestTokenResponse) {
        return retrieveAccessToken(requestTokenResponse.token, requestTokenResponse.secret);
    }

    public Response retrieveAccessToken(String token, String secret) {
         OAuthConsumer consumer = new DefaultOAuthConsumer(info.consumerKey, info.consumerSecret);
        consumer.setTokenWithSecret(token, secret);
        String verifier = Params.current().get("oauth_verifier");
        try {
            provider.retrieveAccessToken(consumer, verifier);
        } catch (OAuthException e) {
            return Response.error(new Error(e));
        }
        return Response.success(consumer.getToken(), consumer.getTokenSecret());
    }
View Full Code Here

                for (String key: this.headers.keySet()) {
                    connection.setRequestProperty(key, headers.get(key));
                }
                checkFileBody(connection);
                if (this.oauthToken != null && this.oauthSecret != null) {
                    OAuthConsumer consumer = new DefaultOAuthConsumer(oauthInfo.consumerKey, oauthInfo.consumerSecret);
                    consumer.setTokenWithSecret(oauthToken, oauthSecret);
                    consumer.sign(connection);
                }
                return connection;
            } catch(Exception e) {
                throw new RuntimeException(e);
            }
View Full Code Here

     */
    private static class OAuthWrapper {
        protected OAuthConsumer oauth;
        OAuthWrapper( Object consumerKey, Object consumerSecret,
            Object accessToken, Object accessSecret ) {
            oauth = new DefaultOAuthConsumer( consumerKey.toString(), consumerSecret.toString() );
            oauth.setTokenWithSecret( accessToken.toString(), accessSecret.toString() );
        }
View Full Code Here

        Mockito.when(this.adapter.getConsumerKey()).thenReturn(consumerKey);
        Mockito.when(this.adapter.getConsumerSecret()).thenReturn(consumerSecret);
        Mockito.when(this.adapter.getSigningStrategy()).thenReturn(signingStrategy);
        Mockito.when(this.adapter.getMessageSigner()).thenReturn(signer);

        DefaultOAuthConsumer consumer = (DefaultOAuthConsumer) this.manager.getConsumer(this.adapter);

        Assert.assertEquals(consumer.getConsumerKey(), consumerKey);
        Assert.assertEquals(consumer.getConsumerSecret(), consumerSecret);

        Mockito.verify(this.adapter).setConsumer(consumer);
    }
View Full Code Here

    {
        OAuthConsumer consumer = adapter.getConsumer();
       
        if (consumer == null)
        {
            consumer = new DefaultOAuthConsumer(adapter.getConsumerKey(), adapter.getConsumerSecret());
            consumer.setMessageSigner(adapter.getMessageSigner());
            consumer.setSigningStrategy(adapter.getSigningStrategy());
           
            adapter.setConsumer(consumer);
        }
View Full Code Here

    @Test(expected = OAuthExpectationFailedException.class)
    public void shouldThrowExpectationFailedIfConsumerKeyNotSet() throws Exception {
        provider = buildProvider(REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL,
            AUTHORIZE_WEBSITE_URL, true);
        provider.retrieveRequestToken(new DefaultOAuthConsumer(null, CONSUMER_SECRET),
            REQUEST_TOKEN_ENDPOINT_URL);
    }
View Full Code Here

    @Test(expected = OAuthExpectationFailedException.class)
    public void shouldThrowExpectationFailedIfConsumerSecretNotSet() throws Exception {
        provider = buildProvider(REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL,
            AUTHORIZE_WEBSITE_URL, true);
        provider.retrieveRequestToken(new DefaultOAuthConsumer(CONSUMER_KEY, null),
            REQUEST_TOKEN_ENDPOINT_URL);
    }
View Full Code Here

    }

    @Test
    public void shouldBeSerializable() throws Exception {
        // the mock consumer isn't serializable, thus set a normal one
        OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
        consumer.setTokenWithSecret(TOKEN, TOKEN_SECRET);

        provider = buildProvider(REQUEST_TOKEN_ENDPOINT_URL, ACCESS_TOKEN_ENDPOINT_URL,
            AUTHORIZE_WEBSITE_URL, false);
        provider.setOAuth10a(true);
View Full Code Here

TOP

Related Classes of oauth.signpost.basic.DefaultOAuthConsumer

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.