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
 java.net.URL configureURLForProtectedAccess(java.net.URL url, OAuthConsumerToken accessToken, java.lang.String httpMethod)
          Create a configured URL.
 OAuthConsumerToken getAccessToken(OAuthConsumerToken requestToken)
          Get an access token for a protected resource.
 java.lang.String getAuthorizationHeader(ProtectedResourceDetails details, OAuthConsumerToken accessToken, java.net.URL url, java.lang.String httpMethod)
          Get the authorization header using the given access token that should be applied to the specified URL.
 java.lang.String getOAuthQueryString(ProtectedResourceDetails details, OAuthConsumerToken accessToken, java.net.URL url, java.lang.String httpMethod)
          Get the query string that is to be used in the given request.
 OAuthConsumerToken getUnauthorizedRequestToken(java.lang.String resourceId)
          Get an unauthorized request token for a protected resource.
 java.io.InputStream readProtectedResource(java.net.URL url, OAuthConsumerToken accessToken, java.lang.String httpMethod)
          Read a protected resource from the given URL using the specified access token and HTTP method.
 

Method Detail

getUnauthorizedRequestToken

OAuthConsumerToken getUnauthorizedRequestToken(java.lang.String resourceId)
                                               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.
Returns:
The unauthorized request token.
Throws:
OAuthRequestFailedException

getAccessToken

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

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

readProtectedResource

java.io.InputStream readProtectedResource(java.net.URL url,
                                          OAuthConsumerToken accessToken,
                                          java.lang.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

java.net.URL configureURLForProtectedAccess(java.net.URL url,
                                            OAuthConsumerToken accessToken,
                                            java.lang.String httpMethod)
                                            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.
Returns:
The configured URL.
Throws:
OAuthRequestFailedException

getAuthorizationHeader

java.lang.String getAuthorizationHeader(ProtectedResourceDetails details,
                                        OAuthConsumerToken accessToken,
                                        java.net.URL url,
                                        java.lang.String httpMethod)
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.
Returns:
The authorization header, or null if the authorization header isn't supported by the provider of this resource.

getOAuthQueryString

java.lang.String getOAuthQueryString(ProtectedResourceDetails details,
                                     OAuthConsumerToken accessToken,
                                     java.net.URL url,
                                     java.lang.String httpMethod)
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.

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.
Returns:
The query string.


Copyright © 2008. All Rights Reserved.