public abstract class AbstractRemoteConnector extends Object implements RemoteConnector
| Modifier and Type | Field and Description |
|---|---|
protected Token |
accessToken
The access token used to sign requests
|
protected OAuth |
auth
OAuth client that is used to authenticate the user
|
protected Token |
requestToken
The request token used to authorize the app
|
| Constructor and Description |
|---|
AbstractRemoteConnector(String consumerKey,
String consumerSecret,
String redirectUri)
Constructs a new connector
|
| Modifier and Type | Method and Description |
|---|---|
void |
authorize(String verificationCode)
Authorizes the app.
|
protected OAuth |
createOAuth(String consumerKey,
String consumerSecret,
String redirectUri)
Creates an OAuth object
|
String |
getAccessTokenSecret() |
String |
getAccessTokenValue() |
String |
getAuthorizationURL()
Gets a new authorization URL from the remote server.
|
protected abstract OAuth.Method |
getOAuthAccessTokenMethod() |
protected abstract String |
getOAuthAccessTokenURL() |
protected abstract String |
getOAuthAuthorizationURL() |
protected abstract String |
getOAuthRequestTokenURL() |
protected List<Object> |
parseResponseArray(Response response)
Parses the given response.
|
protected Map<String,Object> |
parseResponseObject(Response response)
Parses the given response.
|
protected Response |
performRequest(String url,
Map<String,String> additionalHeaders)
Performs a request
|
protected List<Object> |
performRequestArray(String url,
Map<String,String> additionalHeaders)
Performs a request
|
protected Map<String,Object> |
performRequestObject(String url,
Map<String,String> additionalHeaders)
Performs a request
|
void |
setAccessToken(String token,
String secret)
Authorizes the app.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetItem, getItemIDs, getItems, getMaxBulkItemsprotected final OAuth auth
protected Token requestToken
protected Token accessToken
public AbstractRemoteConnector(String consumerKey, String consumerSecret, String redirectUri)
consumerKey - the app's consumer keyconsumerSecret - the app's consumer secretredirectUri - the location users are redirected to after
they granted the app accessprotected abstract String getOAuthRequestTokenURL()
protected abstract String getOAuthAuthorizationURL()
protected abstract String getOAuthAccessTokenURL()
protected abstract OAuth.Method getOAuthAccessTokenMethod()
protected OAuth createOAuth(String consumerKey, String consumerSecret, String redirectUri)
consumerKey - the app's consumer keyconsumerSecret - the app's consumer secretredirectUri - the location users are redirected to after
they granted the app accesspublic String getAuthorizationURL() throws IOException
RemoteConnectorRemoteConnector.authorize(String)getAuthorizationURL in interface RemoteConnectorIOException - if the authorization URL could not be retrievedpublic void authorize(String verificationCode) throws IOException
RemoteConnectorRemoteConnector.getAuthorizationURL(), this method has to be
called to finish authorizationauthorize in interface RemoteConnectorverificationCode - the verification code the user received from
the authorization URLIOException - if authorization failedpublic void setAccessToken(String token, String secret)
RemoteConnectorAuthorizes the app. If you already know a valid OAuth access token
(for example if you cached it from previous sessions) you may call
this method instead of RemoteConnector.getAuthorizationURL() and
RemoteConnector.authorize(String).
This method just saves the provided access token. It does not act with the remote service in any way.
setAccessToken in interface RemoteConnectortoken - the access token valuesecret - the access token's secretRemoteConnector.getAccessTokenValue(),
RemoteConnector.getAccessTokenSecret()public String getAccessTokenValue()
getAccessTokenValue in interface RemoteConnectorRemoteConnector.setAccessToken(String, String)public String getAccessTokenSecret()
getAccessTokenSecret in interface RemoteConnectorRemoteConnector.setAccessToken(String, String)protected Map<String,Object> performRequestObject(String url, Map<String,String> additionalHeaders) throws IOException
url - the URL to queryadditionalHeaders - additional HTTP request headers (may be null)IOException - if the request was not successfulprotected List<Object> performRequestArray(String url, Map<String,String> additionalHeaders) throws IOException
url - the URL to queryadditionalHeaders - additional HTTP request headers (may be null)IOException - if the request was not successfulprotected Response performRequest(String url, Map<String,String> additionalHeaders) throws IOException
url - the URL to queryadditionalHeaders - additional HTTP request headers (may be null)IOException - if the request was not successfulprotected Map<String,Object> parseResponseObject(Response response) throws IOException
response - the HTTP response to parseIOException - if the response could not be readprotected List<Object> parseResponseArray(Response response) throws IOException
response - the HTTP response to parseIOException - if the response could not be read