Examples of CoreOAuthConsumerSupport


Examples of org.springframework.security.oauth.consumer.client.CoreOAuthConsumerSupport

  /**
   * tests getting a request token.
   */
  @Test
  public void testGetRequestToken() throws Exception {
    CoreOAuthConsumerSupport support = new CoreOAuthConsumerSupport();
    support.setStreamHandlerFactory(new DefaultOAuthURLStreamHandlerFactory());
    InMemoryProtectedResourceDetailsService service = new InMemoryProtectedResourceDetailsService();
    HashMap<String, ProtectedResourceDetails> detailsStore = new HashMap<String, ProtectedResourceDetails>();
    BaseProtectedResourceDetails googleDetails = new BaseProtectedResourceDetails();
    googleDetails.setRequestTokenURL("https://www.google.com/accounts/OAuthGetRequestToken");
    googleDetails.setAccessTokenURL("https://www.google.com/accounts/OAuthAuthorizeToken");
    googleDetails.setConsumerKey("anonymous");
    googleDetails.setSharedSecret(new SharedConsumerSecretImpl("anonymous"));
    googleDetails.setId("google");
    googleDetails.setUse10a(true);
    googleDetails.setSignatureMethod(HMAC_SHA1SignatureMethod.SIGNATURE_NAME);
    googleDetails.setRequestTokenHttpMethod("GET");
    HashMap<String, String> additional = new HashMap<String, String>();
    additional.put("scope", "http://picasaweb.google.com/data");
    googleDetails.setAdditionalParameters(additional);
    detailsStore.put(googleDetails.getId(), googleDetails);
    service.setResourceDetailsStore(detailsStore);
    support.setProtectedResourceDetailsService(service);
    // uncomment to see a request to google.
    // see http://code.google.com/apis/accounts/docs/OAuth_ref.html
    // and http://jira.codehaus.org/browse/OAUTHSS-37
    // OAuthConsumerToken token = support.getUnauthorizedRequestToken("google", "urn:mycallback");
    // System.out.println(token.getValue());
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.