org.springframework.security.oauth.consumer
Interface OAuthConsumerSupport

All Known Implementing Classes:
CoreOAuthConsumerSupport

public interface OAuthConsumerSupport

Consumer-side support for OAuth.

Author:
Ryan Heaton

Method Summary
 URL configureURLForProtectedAccess(URL url, OAuthConsumerToken accessToken, String httpMethod, Map<String,String> additionalParameters)
          Create a configured URL.
 OAuthConsumerToken getAccessToken(OAuthConsumerToken requestToken, String verifier)
          Get an access token for a protected resource.
 OAuthConsumerToken getAccessToken(ProtectedResourceDetails resource, OAuthConsumerToken requestToken, String verifier)
          Get an access token for a protected resource.
 String getAuthorizationHeader(ProtectedResourceDetails details, OAuthConsumerToken accessToken, URL url, String httpMethod, Map<String,String> additionalParameters)
          Get the authorization header using the given access token that should be applied to the specified URL.
 String getOAuthQueryString(ProtectedResourceDetails details, OAuthConsumerToken accessToken, URL url, String httpMethod, Map<String,String> additionalParameters)
          Get the query string that is to be used in the given request.
 OAuthConsumerToken getUnauthorizedRequestToken(ProtectedResourceDetails resource, String callback)
          Get an unauthorized request token for a protected resource.
 OAuthConsumerToken getUnauthorizedRequestToken(String resourceId, String callback)
          Get an unauthorized request token for a protected resource.
 InputStream readProtectedResource(URL url, OAuthConsumerToken accessToken, String httpMethod)
          Read a protected resource from the given URL using the specified access token and HTTP method.
 

Method Detail

getUnauthorizedRequestToken

OAuthConsumerToken getUnauthorizedRequestToken(String resourceId,
                                               String callback)
                                               throws OAuthRequestFailedException
Get an unauthorized request token for a protected resource.

Parameters:
resourceId - The id of the protected resource for which to get a consumer token.
callback - The callback URL.
Returns:
The unauthorized request token.
Throws:
OAuthRequestFailedException

getUnauthorizedRequestToken

OAuthConsumerToken getUnauthorizedRequestToken(ProtectedResourceDetails resource,
                                               String callback)
                                               throws OAuthRequestFailedException
Get an unauthorized request token for a protected resource.

Parameters:
resource - The protected resource for which to get a consumer token.
callback - The callback URL.
Returns:
The unauthorized request token.
Throws:
OAuthRequestFailedException

getAccessToken

OAuthConsumerToken getAccessToken(OAuthConsumerToken requestToken,
                                  String verifier)
                                  throws OAuthRequestFailedException
Get an access token for a protected resource.

Parameters:
requestToken - The (presumably authorized) request token.
verifier - The token verifier.
Returns:
The access token.
Throws:
OAuthRequestFailedException

getAccessToken

OAuthConsumerToken getAccessToken(ProtectedResourceDetails resource,
                                  OAuthConsumerToken requestToken,
                                  String verifier)
Get an access token for a protected resource.

Parameters:
resource - The resource for which to get the access token.
requestToken - The (presumably authorized) request token.
verifier - The token verifier.
Returns:
The access token.

readProtectedResource

InputStream readProtectedResource(URL url,
                                  OAuthConsumerToken accessToken,
                                  String httpMethod)
                                  throws OAuthRequestFailedException
Read a protected resource from the given URL using the specified access token and HTTP method.

Parameters:
url - The URL.
accessToken - The access token.
httpMethod - The HTTP method.
Returns:
The protected resource.
Throws:
OAuthRequestFailedException

configureURLForProtectedAccess

URL configureURLForProtectedAccess(URL url,
                                   OAuthConsumerToken accessToken,
                                   String httpMethod,
                                   Map<String,String> additionalParameters)
                                   throws OAuthRequestFailedException
Create a configured URL. If the HTTP method to access the resource is "POST" or "PUT" and the "Authorization" header isn't supported, then the OAuth parameters will be expected to be sent in the body of the request. Otherwise, you can assume that the given URL is ready to be used without further work.

Parameters:
url - The base URL.
accessToken - The access token.
httpMethod - The HTTP method.
additionalParameters - Any additional request parameters.
Returns:
The configured URL.
Throws:
OAuthRequestFailedException

getAuthorizationHeader

String getAuthorizationHeader(ProtectedResourceDetails details,
                              OAuthConsumerToken accessToken,
                              URL url,
                              String httpMethod,
                              Map<String,String> additionalParameters)
Get the authorization header using the given access token that should be applied to the specified URL.

Parameters:
details - The details of the protected resource.
accessToken - The access token.
url - The URL of the request.
httpMethod - The http method for the protected resource.
additionalParameters - Any additional request parameters.
Returns:
The authorization header, or null if the authorization header isn't supported by the provider of this resource.

getOAuthQueryString

String getOAuthQueryString(ProtectedResourceDetails details,
                           OAuthConsumerToken accessToken,
                           URL url,
                           String httpMethod,
                           Map<String,String> additionalParameters)
Get the query string that is to be used in the given request. The query string will include any custom query parameters in the URL and any necessary OAuth parameters. Note, however, that an OAuth parameter is not considered "necessary" if the provider of the resource supports the authorization header.

Any OAuth parameters will be URL-encoded, but not oauth-encoded, per the OAuth spec.

The query string is to be used by either applying it to the URL (for HTTP GET) or putting it in the body of the request (for HTTP POST).

Parameters:
details - The resource details.
accessToken - The access token.
url - The URL
httpMethod - The http method.
additionalParameters - Any additional OAuth request parameters.
Returns:
The query string.


Copyright © 2012. All Rights Reserved.