Examples of GoogleOAuthParameters


Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

    @Test
    public void testWriteRequest() throws Exception {
        exchange.getIn().setHeader("oauth_token", "token1");
        exchange.getIn().setHeader("oauth_verifier", "verifier1");
        exchange.getIn().setHeader("Cookie", COOKIE_NAME + "=secret1");
        GoogleOAuthParameters params = binding.writeRequest(endpoint, exchange, null);
        assertEquals("testConsumerKey", params.getOAuthConsumerKey());
        assertEquals("testConsumerSecret", params.getOAuthConsumerSecret());
        assertEquals("token1", params.getOAuthToken());
        assertEquals("secret1", params.getOAuthTokenSecret());
        assertEquals("verifier1", params.getOAuthVerifier());
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

        binding.writeRequest(endpoint, exchange, null);
    }
   
    @Test
    public void testReadResponse() throws Exception {
        GoogleOAuthParameters params = new GoogleOAuthParameters();
        params.setOAuthToken("token2");
        params.setOAuthTokenSecret("tokenSecret2");
        binding.readResponse(endpoint, exchange, params);
        assertEquals("token2", exchange.getOut().getHeader(GAUTH_ACCESS_TOKEN));
        assertEquals("tokenSecret2", exchange.getOut().getHeader(GAUTH_ACCESS_TOKEN_SECRET));
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

        assertEquals("tokenSecret2", exchange.getOut().getHeader(GAUTH_ACCESS_TOKEN_SECRET));
    }
   
    @Test
    public void testReadResponseNoToken() throws Exception {
        GoogleOAuthParameters params = new GoogleOAuthParameters();
        binding.readResponse(endpoint, exchange, params);
        assertNull(exchange.getOut().getHeader(GAUTH_ACCESS_TOKEN));
        assertNull(exchange.getOut().getHeader(GAUTH_ACCESS_TOKEN_SECRET));
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

        exchange = new DefaultExchange(component.getCamelContext());
    }
   
    @Test
    public void testWriteRequestDefault() {
        GoogleOAuthParameters params = binding.writeRequest(endpoint, exchange, null);
        assertEquals("testConsumerKey", params.getOAuthConsumerKey());
        assertEquals("testConsumerSecret", params.getOAuthConsumerSecret());
        assertEquals("http://test.example.org/handler", params.getOAuthCallback());
        assertEquals("http://scope.example.org", params.getScope());
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

   
    @Test
    public void testWriteRequestCustom() {
        exchange.getIn().setHeader(GAUTH_SCOPE, "http://scope.custom.org");
        exchange.getIn().setHeader(GAUTH_CALLBACK, "http://test.custom.org/handler");
        GoogleOAuthParameters params = binding.writeRequest(endpoint, exchange, null);
        assertEquals("http://test.custom.org/handler", params.getOAuthCallback());
        assertEquals("http://scope.custom.org", params.getScope());
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

        assertEquals("http://scope.custom.org", params.getScope());
    }
   
    @Test
    public void testReadResponse() throws Exception {
        GoogleOAuthParameters params = binding.writeRequest(endpoint, exchange, null);
        params.setOAuthToken("testToken");
        params.setOAuthTokenSecret("testTokenSecret");
        binding.readResponse(endpoint, exchange, params);
        String redirectUrl = "https://www.google.com/accounts/OAuthAuthorizeToken"
            + "?oauth_token=testToken"
            + "&oauth_callback=http%3A%2F%2Ftest.example.org%2Fhandler";
        String secretCookie = "gauth-token-secret=testTokenSecret";
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

        }
        String scope = exchange.getIn().getHeader(GAUTH_SCOPE, String.class);
        if (scope == null) {
            scope = endpoint.getScope();
        }
        request = new GoogleOAuthParameters();
        request.setOAuthConsumerKey(endpoint.getConsumerKey());
        request.setOAuthConsumerSecret(endpoint.getConsumerSecret());
        request.setOAuthCallback(callback);
        request.setScope(scope);
        return request;
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

     * @throws GAuthException if the {@link GAuthComponent} is configured to use the
     *             HMAC_SHA1 signature method but there's no cookie with the
     *             request token secret.
     */
    public GoogleOAuthParameters writeRequest(GAuthEndpoint endpoint, Exchange exchange, GoogleOAuthParameters request) throws Exception {
        request = new GoogleOAuthParameters();
        request.setOAuthConsumerKey(endpoint.getConsumerKey());
        request.setOAuthConsumerSecret(endpoint.getConsumerSecret());
        request.setOAuthToken(exchange.getIn().getHeader("oauth_token", String.class));
        request.setOAuthVerifier(exchange.getIn().getHeader("oauth_verifier", String.class));

View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

     * an unauthorized request token and creates a redirect response, or
     * upgrades an authorized request token to an access token.
     */
    public void process(Exchange exchange) throws Exception {
        if (getEndpoint().getName() == AUTHORIZE) {
            GoogleOAuthParameters params = getAuthorizeBinding().writeRequest(getEndpoint(), exchange, null);
            getEndpoint().getService().getUnauthorizedRequestToken(params);
            getAuthorizeBinding().readResponse(getEndpoint(), exchange, params);
        } else {
            GoogleOAuthParameters params = getUpgradeBinding().writeRequest(getEndpoint(), exchange, null);
            getEndpoint().getService().getAccessToken(params);
            getUpgradeBinding().readResponse(getEndpoint(), exchange, params);
        }
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.GoogleOAuthParameters

    ////////////////////////////////////////////////////////////////////////////

    // You first need to initialize a few OAuth-related objects.
    // GoogleOAuthParameters holds all the parameters related to OAuth.
    // OAuthSigner is responsible for signing the OAuth base string.
    GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();

    // Set your OAuth Consumer Key (which you can register at
    // https://www.google.com/accounts/ManageDomains).
    oauthParameters.setOAuthConsumerKey(variables.getConsumerKey());

    // Initialize the OAuth Signer.  If you are using RSA-SHA1, you must provide
    // your private key as a Base-64 string conforming to the PKCS #8 standard.
    // Visit http://code.google.com/apis/gdata/authsub.html#Registered to learn
    // more about creating a key/certificate pair.  If you are using HMAC-SHA1,
    // you must set your OAuth Consumer Secret, which can be obtained at
    // https://www.google.com/accounts/ManageDomains.
    OAuthSigner signer;
    switch (variables.getSignatureMethod()) {
      case RSA:
        signer = new OAuthRsaSha1Signer(variables.getSignatureKey());
        break;
      case HMAC:
        oauthParameters.setOAuthConsumerSecret(variables.getSignatureKey());
        signer = new OAuthHmacSha1Signer();
        break;
      default:
        throw new IllegalArgumentException("Invalid Signature Method");
    }

    // Finally create a new GoogleOAuthHelperObject.  This is the object you
    // will use for all OAuth-related interaction.
    GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);


    ////////////////////////////////////////////////////////////////////////////
    // STEP 3: Get the Authorization URL
    ////////////////////////////////////////////////////////////////////////////

    // Set the scope for this particular service.
    oauthParameters.setScope(variables.getScope());

    // This method also makes a request to get the unauthorized request token,
    // and adds it to the oauthParameters object, along with the token secret
    // (if it is present).
    oauthHelper.getUnauthorizedRequestToken(oauthParameters);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.