org.codegist.crest.oauth
Class OAuthenticatorV10

java.lang.Object
  extended by org.codegist.crest.oauth.OAuthenticatorV10
All Implemented Interfaces:
OAuthenticator

public class OAuthenticatorV10
extends Object
implements OAuthenticator

OAuth v1.0 authentificator implementation TODO : tidy up, explode in different specilized classes: more cohesion and less coupling please!!

Author:
Laurent Gilles (laurent.gilles@codegist.org)

Field Summary
static String CONFIG_OAUTH_CALLBACK
           
static String CONFIG_OAUTH_PARAM_DEST
           
static String CONFIG_TOKEN_ACCESS_REFRESH_URL
           
static String CONFIG_TOKEN_ACCESS_REFRESH_URL_METHOD
           
static String CONFIG_TOKEN_ACCESS_URL
           
static String CONFIG_TOKEN_ACCESS_URL_METHOD
           
static String CONFIG_TOKEN_REQUEST_URL
           
static String CONFIG_TOKEN_REQUEST_URL_METHOD
           
 
Constructor Summary
OAuthenticatorV10(RestService restService, Token consumerToken)
           
OAuthenticatorV10(RestService restService, Token consumerToken, Map<String,Object> config)
           
OAuthenticatorV10(RestService restService, Token consumerToken, Map<String,Object> config, org.codegist.crest.oauth.OAuthenticatorV10.VariantProvider variant)
           
OAuthenticatorV10(RestService restService, Token consumerToken, org.codegist.crest.oauth.OAuthenticatorV10.VariantProvider variant)
           
 
Method Summary
 Token getAccessToken(Token requestToken, String verifier)
          Exchanges the given request token with a new access token using the given verifier
 Token getRequestToken()
          Fires a get request token to the preconfigured url
 Token refreshAccessToken(Token requestToken, String... includeExtras)
          Refreshs the given access token if it has expired.
 void sign(Token accessToken, HttpRequest.Builder request, Pair<String,String>... extraHeaders)
          Signs the given request using the given access token and the optional additional oauth headers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_TOKEN_ACCESS_REFRESH_URL

public static final String CONFIG_TOKEN_ACCESS_REFRESH_URL
See Also:
Constant Field Values

CONFIG_TOKEN_ACCESS_REFRESH_URL_METHOD

public static final String CONFIG_TOKEN_ACCESS_REFRESH_URL_METHOD
See Also:
Constant Field Values

CONFIG_OAUTH_PARAM_DEST

public static final String CONFIG_OAUTH_PARAM_DEST
See Also:
Constant Field Values

CONFIG_TOKEN_REQUEST_URL

public static final String CONFIG_TOKEN_REQUEST_URL
See Also:
Constant Field Values

CONFIG_TOKEN_REQUEST_URL_METHOD

public static final String CONFIG_TOKEN_REQUEST_URL_METHOD
See Also:
Constant Field Values

CONFIG_TOKEN_ACCESS_URL

public static final String CONFIG_TOKEN_ACCESS_URL
See Also:
Constant Field Values

CONFIG_TOKEN_ACCESS_URL_METHOD

public static final String CONFIG_TOKEN_ACCESS_URL_METHOD
See Also:
Constant Field Values

CONFIG_OAUTH_CALLBACK

public static final String CONFIG_OAUTH_CALLBACK
See Also:
Constant Field Values
Constructor Detail

OAuthenticatorV10

public OAuthenticatorV10(RestService restService,
                         Token consumerToken,
                         org.codegist.crest.oauth.OAuthenticatorV10.VariantProvider variant)

OAuthenticatorV10

public OAuthenticatorV10(RestService restService,
                         Token consumerToken,
                         Map<String,Object> config,
                         org.codegist.crest.oauth.OAuthenticatorV10.VariantProvider variant)

OAuthenticatorV10

public OAuthenticatorV10(RestService restService,
                         Token consumerToken,
                         Map<String,Object> config)

OAuthenticatorV10

public OAuthenticatorV10(RestService restService,
                         Token consumerToken)
Method Detail

getRequestToken

public Token getRequestToken()
Description copied from interface: OAuthenticator
Fires a get request token to the preconfigured url

Specified by:
getRequestToken in interface OAuthenticator
Returns:
A new request token

refreshAccessToken

public Token refreshAccessToken(Token requestToken,
                                String... includeExtras)
Description copied from interface: OAuthenticator
Refreshs the given access token if it has expired. Include optional extra oauth header from the extra field of the token.

Specified by:
refreshAccessToken in interface OAuthenticator
Parameters:
requestToken - expired access token
includeExtras - extras field name from the given token to include in the request
Returns:
a new access token
See Also:
Token.getExtras()

getAccessToken

public Token getAccessToken(Token requestToken,
                            String verifier)
Description copied from interface: OAuthenticator
Exchanges the given request token with a new access token using the given verifier

Specified by:
getAccessToken in interface OAuthenticator
Parameters:
requestToken - request token to exchange
verifier - verifier
Returns:
new access token

sign

public void sign(Token accessToken,
                 HttpRequest.Builder request,
                 Pair<String,String>... extraHeaders)
Description copied from interface: OAuthenticator
Signs the given request using the given access token and the optional additional oauth headers.

Specified by:
sign in interface OAuthenticator
Parameters:
accessToken - Access token to be used
request - request to be signed
extraHeaders - optional header to be added in the oauth authentification headers


Copyright © 2011. All Rights Reserved.