public abstract class BaseOAuthClient<U extends OAuth20Profile> extends IndirectClient<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, callbackUrlResolver, 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()
Clone the current client.
|
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.
|
ClientType |
getClientType()
Return the client type.
|
int |
getConnectTimeout() |
String |
getKey() |
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(WebContext context,
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(WebContext context)
Internal initialization of the object.
|
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) |
computeFinalCallbackUrl, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCredentials, getRedirectAction, getRedirectionUrl, getStateParameter, isDirectRedirection, isIncludeClientNameInCallbackUrl, redirect, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setIncludeClientNameInCallbackUrl
addAuthorizationGenerator, getAuthorizationGenerators, getName, getUserProfile, newClient, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setName, toString
init, reinit
protected 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(WebContext context)
InitializableWebObject
internalInit
in class InitializableWebObject
context
- the web contextpublic BaseOAuthClient<U> clone()
BaseClient
clone
in class BaseClient<OAuthCredentials,U extends OAuth20Profile>
protected RedirectAction retrieveRedirectAction(WebContext context)
retrieveRedirectAction
in class IndirectClient<OAuthCredentials,U extends OAuth20Profile>
protected abstract String retrieveAuthorizationUrl(WebContext context)
protected OAuthCredentials retrieveCredentials(WebContext context)
retrieveCredentials
in class IndirectClient<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(WebContext context, String accessToken)
context
- the web contextaccessToken
- 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 ClientType getClientType()
BaseClient
getClientType
in class BaseClient<OAuthCredentials,U extends OAuth20Profile>
Copyright © 2016. All rights reserved.