public abstract class BaseOAuthClient<U extends OAuth20Profile> extends BaseClient<OAuthCredentials,U>
| Modifier and Type | Field and Description |
|---|---|
protected int |
connectTimeout |
protected String |
key |
protected static org.slf4j.Logger |
logger |
protected String |
proxyHost |
protected int |
proxyPort |
protected int |
readTimeout |
protected String |
secret |
protected org.scribe.oauth.OAuthService |
service |
protected boolean |
tokenAsHeader |
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, NEEDS_CLIENT_REDIRECTION_PARAMETER| Constructor and Description |
|---|
BaseOAuthClient() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAccessTokenToProfile(U profile,
org.scribe.model.Token accessToken)
Add the access token to the profile (as an attribute).
|
BaseOAuthClient<U> |
clone() |
protected ProxyOAuthRequest |
createProxyRequest(String url)
Create a proxy request.
|
protected abstract U |
extractUserProfile(String body)
Extract the user profile from the response (JSON, XML...) of the profile url.
|
protected abstract org.scribe.model.Token |
getAccessToken(OAuthCredentials credentials)
Get the access token from OAuth credentials.
|
int |
getConnectTimeout() |
String |
getKey() |
Mechanism |
getMechanism() |
protected abstract OAuthCredentials |
getOAuthCredentials(WebContext context)
Get the OAuth credentials from the web context.
|
protected abstract String |
getProfileUrl(org.scribe.model.Token accessToken)
Retrieve the url of the profile of the authenticated user for the provider.
|
String |
getProxyHost() |
int |
getProxyPort() |
int |
getReadTimeout() |
String |
getSecret() |
U |
getUserProfile(String accessToken)
Get the user profile from the access token.
|
protected abstract boolean |
hasBeenCancelled(WebContext context)
Return if the authentication has been cancelled.
|
protected void |
internalInit() |
boolean |
isTokenAsHeader() |
protected abstract String |
retrieveAuthorizationUrl(WebContext context) |
protected OAuthCredentials |
retrieveCredentials(WebContext context) |
protected RedirectAction |
retrieveRedirectAction(WebContext context) |
protected U |
retrieveUserProfile(OAuthCredentials credentials,
WebContext context) |
protected U |
retrieveUserProfileFromToken(org.scribe.model.Token accessToken)
Retrieve the user profile from the access token.
|
String |
sendRequestForData(OAuth10Profile profile,
String dataUrl)
Make a request to the OAuth provider to access a protected resource.
|
protected String |
sendRequestForData(org.scribe.model.Token accessToken,
String dataUrl)
Make a request to get the data of the authenticated user for the provider.
|
void |
setConnectTimeout(int connectTimeout) |
void |
setKey(String key) |
void |
setProxyHost(String proxyHost) |
void |
setProxyPort(int proxyPort) |
void |
setReadTimeout(int readTimeout) |
void |
setSecret(String secret) |
void |
setTokenAsHeader(boolean tokenAsHeader) |
addAuthorizationGenerator, getAuthenticator, getAuthorizationGenerators, getCallbackUrl, getContextualCallbackUrl, getCredentials, getName, getProfileCreator, getRedirectAction, getRedirectionUrl, getStateParameter, getUserProfile, isDirectRedirection, isEnableContextualRedirects, newClient, prependHostToUrlIfNotPresent, redirect, setAuthenticator, setAuthorizationGenerator, setAuthorizationGenerators, setCallbackUrl, setEnableContextualRedirects, setName, setProfileCreator, toStringinit, reinitprotected static final org.slf4j.Logger logger
protected org.scribe.oauth.OAuthService service
protected String key
protected String secret
protected boolean tokenAsHeader
protected int connectTimeout
protected int readTimeout
protected String proxyHost
protected int proxyPort
protected void internalInit()
internalInit in class InitializableObjectpublic BaseOAuthClient<U> clone()
clone in class BaseClient<OAuthCredentials,U extends OAuth20Profile>protected RedirectAction retrieveRedirectAction(WebContext context)
retrieveRedirectAction in class BaseClient<OAuthCredentials,U extends OAuth20Profile>protected abstract String retrieveAuthorizationUrl(WebContext context)
protected OAuthCredentials retrieveCredentials(WebContext context)
retrieveCredentials in class BaseClient<OAuthCredentials,U extends OAuth20Profile>protected abstract boolean hasBeenCancelled(WebContext context)
context - the web context.protected abstract OAuthCredentials getOAuthCredentials(WebContext context)
context - the web contextprotected U retrieveUserProfile(OAuthCredentials credentials, WebContext context)
retrieveUserProfile in class BaseClient<OAuthCredentials,U extends OAuth20Profile>public U getUserProfile(String accessToken)
accessToken - the access tokenprotected abstract org.scribe.model.Token getAccessToken(OAuthCredentials credentials)
credentials - credentialsprotected U retrieveUserProfileFromToken(org.scribe.model.Token accessToken)
accessToken - the access tokenprotected abstract String getProfileUrl(org.scribe.model.Token accessToken)
accessToken - only used when constructing dynamic urls from data in the tokenprotected String sendRequestForData(org.scribe.model.Token accessToken, String dataUrl)
accessToken - the access tokendataUrl - url of the datapublic String sendRequestForData(OAuth10Profile profile, String dataUrl)
profile - user profiledataUrl - url of the dataprotected ProxyOAuthRequest createProxyRequest(String url)
url - url of the dataprotected abstract U extractUserProfile(String body)
body - the response bodyprotected void addAccessTokenToProfile(U profile, org.scribe.model.Token accessToken)
profile - the user profileaccessToken - the access tokenpublic void setKey(String key)
public void setSecret(String secret)
public void setConnectTimeout(int connectTimeout)
public void setReadTimeout(int readTimeout)
public String getKey()
public String getSecret()
public int getConnectTimeout()
public int getReadTimeout()
public String getProxyHost()
public void setProxyHost(String proxyHost)
public int getProxyPort()
public void setProxyPort(int proxyPort)
public boolean isTokenAsHeader()
public void setTokenAsHeader(boolean tokenAsHeader)
public Mechanism getMechanism()
getMechanism in class BaseClient<OAuthCredentials,U extends OAuth20Profile>Copyright © 2015. All Rights Reserved.