use of org.springframework.security.oauth.consumer.client.CoreOAuthConsumerSupport in project spring-security-oauth by spring-projects.
the class GoogleOAuthTests method testGetRequestToken.
/**
* 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());
// System.out.println(token.getSecret());
}
Aggregations