|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jets3t.service.utils.oauth.OAuthUtils
public class OAuthUtils
Utilties for obtaining OAuth authentication tokens.
Implementation is currently specific to the Google Storage OAuth 2.0 implementation, though hopefully generic enough it may be extensible in the future.
Nested Class Summary | |
---|---|
static class |
OAuthUtils.OAuthImplementation
Which OAuth implementation to target. |
Field Summary | |
---|---|
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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
Constructor Detail |
---|
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 applicationsMethod Detail |
---|
public 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 pairs
org.apache.http.client.ClientProtocolException
- No HTTP 200 response
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |