public class OAuthUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
OAuthUtils.OAuthImplementation
Which OAuth implementation to target.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
clientId |
protected java.lang.String |
clientSecret |
protected static java.lang.String |
HTTP_USER_AGENT |
protected org.apache.http.client.HttpClient |
httpClient |
protected OAuthUtils.OAuthImplementation |
implementation |
protected org.codehaus.jackson.map.ObjectMapper |
jsonMapper |
Constructor and Description |
---|
OAuthUtils(org.apache.http.client.HttpClient httpClient,
OAuthUtils.OAuthImplementation implementation,
java.lang.String clientId,
java.lang.String clientSecret)
Create utility class for a given OAuth implementation that will use the given
client ID and Secret.
|
OAuthUtils(OAuthUtils.OAuthImplementation implementation,
java.lang.String clientId,
java.lang.String clientSecret)
Create utility class for a given OAuth implementation that will use the given
client ID and Secret.
|
OAuthUtils(OAuthUtils.OAuthImplementation implementation,
java.lang.String clientId,
java.lang.String clientSecret,
Jets3tProperties jets3tProperties)
Create utility class for a given OAuth implementation that will use the given
client ID and Secret.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
generateBrowserUrlToAuthorizeNativeApplication(OAuthScope scope)
Generate the URL for an OAuth authorization end-point that a person can visit in a
web browser to authorize access to a storage resource, where access is limited to
the given scope.
|
java.lang.String |
getClientId() |
java.lang.String |
getClientSecret() |
protected java.util.Map<java.lang.String,java.lang.Object> |
performPostRequestAndParseJSONResponse(java.lang.String endpointUri,
java.util.List<org.apache.http.NameValuePair> postParams)
Performs an HTTP/S POST request to a given URL with the given POST parameters
and parses the response document, which must be JSON, into a Map of name/value objects.
|
OAuth2Tokens |
refreshOAuth2AccessToken(OAuth2Tokens tokens)
Retrieve and return a refreshed access token from an OAuth2 token end-point using the
refresh token in the provided tokens object.
|
OAuth2Tokens |
retrieveOAuth2TokensFromAuthorization(java.lang.String authorizationCode)
Swap the given authorization token for access/refresh tokens (and optional expiry time)
from an OAuth token endpoint.
|
protected static final java.lang.String HTTP_USER_AGENT
protected org.apache.http.client.HttpClient httpClient
protected org.codehaus.jackson.map.ObjectMapper jsonMapper
protected OAuthUtils.OAuthImplementation implementation
protected java.lang.String clientId
protected java.lang.String clientSecret
public OAuthUtils(OAuthUtils.OAuthImplementation implementation, java.lang.String clientId, java.lang.String clientSecret, Jets3tProperties jets3tProperties)
Jets3tProperties
object are
used to configure HTTP/S connections that may be performed by this class.implementation
- OAuth implementation versionclientId
- Client ID for installed applicationclientSecret
- Client secret for installed applicationsjets3tProperties
- Properties to configure HTTP/S connectionspublic OAuthUtils(org.apache.http.client.HttpClient httpClient, OAuthUtils.OAuthImplementation implementation, java.lang.String clientId, java.lang.String clientSecret)
Jets3tProperties
object are
used to configure HTTP/S connections that may be performed by this class.httpClient
- HTTP Clientimplementation
- OAuth implementation versionclientId
- Client ID for installed applicationclientSecret
- Client secret for installed applicationspublic OAuthUtils(OAuthUtils.OAuthImplementation implementation, java.lang.String clientId, java.lang.String clientSecret)
Jets3tProperties
object
are used to configure HTTP/S connections that may be performed by this class.implementation
- OAuth implementation versionclientId
- Client ID for installed applicationclientSecret
- Client secret for installed applicationspublic java.lang.String getClientId()
public java.lang.String getClientSecret()
public java.lang.String generateBrowserUrlToAuthorizeNativeApplication(OAuthScope scope)
scope
- URI representing the access scope a user will be prompted to authorize, for example
example OAuthConstants.GSOAuth2_10.Scopes.ReadOnly
public OAuth2Tokens retrieveOAuth2TokensFromAuthorization(java.lang.String authorizationCode) throws java.io.IOException
authorizationCode
- token representing a pre-approved authorization (e.g. as might be generated by a user who
visits the generateBrowserUrlToAuthorizeNativeApplication(OAuthScope)
URL)java.io.IOException
- Error receiving tokenspublic OAuth2Tokens refreshOAuth2AccessToken(OAuth2Tokens tokens) throws java.io.IOException
tokens
- OAuth token data that must include a valid refresh token.java.io.IOException
- Invalid response dataprotected java.util.Map<java.lang.String,java.lang.Object> performPostRequestAndParseJSONResponse(java.lang.String endpointUri, java.util.List<org.apache.http.NameValuePair> postParams) throws java.io.IOException
endpointUri
- Authorization or token endpointpostParams
- Name value pairsorg.apache.http.client.ClientProtocolException
- No HTTP 200 responsejava.io.IOException