public abstract class BaseOAuthClient<U extends OAuth20Profile,S extends com.github.scribejava.core.oauth.OAuthService,T extends com.github.scribejava.core.model.Token> extends IndirectClient<OAuthCredentials,U>
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
logger |
protected S |
service |
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, callbackUrlResolver
Constructor and Description |
---|
BaseOAuthClient() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addAccessTokenToProfile(U profile,
T accessToken)
Add the access token to the profile (as an attribute).
|
protected com.github.scribejava.core.model.OAuthConfig |
buildOAuthConfig(WebContext context)
Build an OAuth configuration.
|
protected com.github.scribejava.core.model.OAuthRequest |
createOAuthRequest(String url)
Create an OAuth request.
|
protected abstract U |
extractUserProfile(String body)
Extract the user profile from the response (JSON, XML...) of the profile url.
|
protected abstract T |
getAccessToken(OAuthCredentials credentials)
Get the access token from OAuth credentials.
|
protected abstract com.github.scribejava.core.builder.api.BaseApi<S> |
getApi()
Define the OAuth API for this client.
|
int |
getConnectTimeout() |
String |
getKey() |
protected abstract OAuthCredentials |
getOAuthCredentials(WebContext context)
Get the OAuth credentials from the web context.
|
protected String |
getOAuthScope()
Define the OAuth scope for this client.
|
protected abstract String |
getProfileUrl(T accessToken)
Retrieve the url of the profile of the authenticated user for the provider.
|
int |
getReadTimeout() |
String |
getResponseType() |
String |
getSecret() |
protected boolean |
hasBeenCancelled(WebContext context)
Return if the authentication has been cancelled.
|
protected boolean |
hasOAuthGrantType()
Whether the grant type must be added.
|
protected void |
internalInit(WebContext context)
Internal initialization of the object.
|
boolean |
isTokenAsHeader() |
protected abstract String |
retrieveAuthorizationUrl(WebContext context)
Retrieve the authorization url to redirect to the OAuth provider.
|
protected OAuthCredentials |
retrieveCredentials(WebContext context)
Retrieve the credentials.
|
protected RedirectAction |
retrieveRedirectAction(WebContext context)
Retrieve the redirect action.
|
protected U |
retrieveUserProfile(OAuthCredentials credentials,
WebContext context)
Retrieve a user userprofile.
|
protected U |
retrieveUserProfileFromToken(T accessToken)
Retrieve the user profile from the access token.
|
protected String |
sendRequestForData(T 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 |
setReadTimeout(int readTimeout) |
void |
setResponseType(String responseType) |
void |
setSecret(String secret) |
void |
setTokenAsHeader(boolean tokenAsHeader) |
protected abstract void |
signRequest(T token,
com.github.scribejava.core.model.OAuthRequest request) |
computeFinalCallbackUrl, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCredentials, getRedirectAction, getStateParameter, isIncludeClientNameInCallbackUrl, redirect, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setIncludeClientNameInCallbackUrl
addAuthorizationGenerator, getAuthorizationGenerators, getName, getUserProfile, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setName, toString
init, reinit
protected static final org.slf4j.Logger logger
protected S extends com.github.scribejava.core.oauth.OAuthService service
protected void internalInit(WebContext context)
InitializableWebObject
internalInit
in class IndirectClient<OAuthCredentials,U extends OAuth20Profile>
context
- the web contextprotected com.github.scribejava.core.model.OAuthConfig buildOAuthConfig(WebContext context)
context
- the web contextprotected abstract com.github.scribejava.core.builder.api.BaseApi<S> getApi()
protected String getOAuthScope()
protected boolean hasOAuthGrantType()
protected RedirectAction retrieveRedirectAction(WebContext context) throws HttpAction
IndirectClient
retrieveRedirectAction
in class IndirectClient<OAuthCredentials,U extends OAuth20Profile>
context
- the web contextHttpAction
- requires a specific HTTP action if necessaryprotected abstract String retrieveAuthorizationUrl(WebContext context) throws HttpAction
context
- the web contextHttpAction
- whether an additional HTTP action is requiredprotected OAuthCredentials retrieveCredentials(WebContext context) throws HttpAction
IndirectClient
retrieveCredentials
in class IndirectClient<OAuthCredentials,U extends OAuth20Profile>
context
- the web contextHttpAction
- whether an additional HTTP action is requiredprotected boolean hasBeenCancelled(WebContext context)
context
- the web context.protected abstract OAuthCredentials getOAuthCredentials(WebContext context) throws HttpAction
context
- the web contextHttpAction
- whether an additional HTTP action is requiredprotected U retrieveUserProfile(OAuthCredentials credentials, WebContext context) throws HttpAction
BaseClient
retrieveUserProfile
in class BaseClient<OAuthCredentials,U extends OAuth20Profile>
credentials
- the credentialscontext
- the web contextHttpAction
- whether an additional HTTP action is requiredprotected abstract T getAccessToken(OAuthCredentials credentials) throws HttpAction
credentials
- credentialsHttpAction
- whether an additional HTTP action is requiredprotected U retrieveUserProfileFromToken(T accessToken) throws HttpAction
accessToken
- the access tokenHttpAction
- whether an additional HTTP action is requiredprotected abstract String getProfileUrl(T accessToken)
accessToken
- only used when constructing dynamic urls from data in the tokenprotected String sendRequestForData(T accessToken, String dataUrl)
accessToken
- the access tokendataUrl
- url of the dataprotected abstract void signRequest(T token, com.github.scribejava.core.model.OAuthRequest request)
protected com.github.scribejava.core.model.OAuthRequest createOAuthRequest(String url)
url
- the url to callprotected abstract U extractUserProfile(String body) throws HttpAction
body
- the response bodyHttpAction
- whether an additional HTTP action is requiredprotected abstract void addAccessTokenToProfile(U profile, T 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 boolean isTokenAsHeader()
public void setTokenAsHeader(boolean tokenAsHeader)
public String getResponseType()
public void setResponseType(String responseType)
Copyright © 2016. All rights reserved.