public class OAuthHelper extends Object
Modifier and Type | Field and Description |
---|---|
protected com.google.api.client.auth.oauth2.Credential.AccessMethod |
accessMethod |
protected ActionBeanContext |
actionBeanContext |
protected String |
authorizationServerUrl |
protected String |
authorizeMethod |
protected String |
clientId |
protected String |
clientSecret |
static String |
copyright |
protected com.google.api.client.auth.oauth2.CredentialStore |
credentialStore |
protected String |
error |
protected com.google.api.client.http.HttpTransport |
httpTransport |
protected static com.google.api.client.json.JsonFactory |
JSON_FACTORY |
static org.slf4j.Logger |
logger |
protected Collection<String> |
scopes |
protected String |
tokenServerUrl |
Constructor and Description |
---|
OAuthHelper(ActionBeanContext actionBeanContext,
String tokenServerUrl,
String authorizationServerUrl,
Collection<String> scopes,
String clientId,
String clientSecret) |
OAuthHelper(ActionBeanContext actionBeanContext,
String tokenServerUrl,
String authorizationServerUrl,
String scope,
String clientId,
String clientSecret) |
Modifier and Type | Method and Description |
---|---|
com.google.api.client.auth.oauth2.Credential |
authorize()
Handles the callback from the OAuth provider, returning a valid Credential if successful.
|
com.google.api.client.auth.oauth2.Credential |
authorize(HttpServletRequest request,
String userId)
Handles the callback from the OAuth provider, returning a valid Credential if successful.
|
com.google.api.client.auth.oauth2.Credential |
authorize(String code,
String userId)
Handles the callback from the OAuth provider, returning a valid Credential if successful.
|
String |
computeAuthorizationUrl()
Returns a URL where the user should be redirected in order to authorize access to the selected resources.
|
protected com.google.api.client.auth.oauth2.AuthorizationCodeFlow |
createCodeFlow() |
Resolution |
doWithCredential(Callable<Resolution> action)
Executes an action if the current logged in user's credential is known,
otherwise redirects to the authorization page.
|
Resolution |
doWithCredential(String userId,
Callable<Resolution> action)
Executes an action if the user's credential is known, otherwise redirects to the authorization page.
|
com.google.api.client.auth.oauth2.Credential.AccessMethod |
getAccessMethod() |
String |
getAuthorizeMethod() |
com.google.api.client.auth.oauth2.CredentialStore |
getCredentialStore() |
String |
getError() |
protected com.google.api.client.http.HttpExecuteInterceptor |
getHttpExecuteInterceptor() |
com.google.api.client.http.HttpTransport |
getHttpTransport() |
com.google.api.client.json.JsonFactory |
getJsonFactory() |
String |
getRedirectUrl() |
com.google.api.client.auth.oauth2.Credential |
loadCredential(String userId) |
void |
setAccessMethod(com.google.api.client.auth.oauth2.Credential.AccessMethod accessMethod) |
void |
setAuthorizeMethod(String authorizeMethod) |
void |
setCredentialStore(com.google.api.client.auth.oauth2.CredentialStore credentialStore) |
void |
setHttpTransport(com.google.api.client.http.HttpTransport httpTransport) |
public static final String copyright
public static final org.slf4j.Logger logger
protected com.google.api.client.auth.oauth2.CredentialStore credentialStore
protected String authorizeMethod
protected com.google.api.client.http.HttpTransport httpTransport
protected com.google.api.client.auth.oauth2.Credential.AccessMethod accessMethod
protected static final com.google.api.client.json.JsonFactory JSON_FACTORY
protected final ActionBeanContext actionBeanContext
protected final String tokenServerUrl
protected final String authorizationServerUrl
protected final Collection<String> scopes
protected final String clientId
protected final String clientSecret
protected String error
public OAuthHelper(ActionBeanContext actionBeanContext, String tokenServerUrl, String authorizationServerUrl, Collection<String> scopes, String clientId, String clientSecret)
public String computeAuthorizationUrl()
public String getRedirectUrl()
public com.google.api.client.auth.oauth2.Credential authorize(String code, @Nullable String userId) throws IOException
code
- userId
- IOException
public com.google.api.client.auth.oauth2.Credential authorize(HttpServletRequest request, String userId) throws IOException
request
- userId
- IOException
public com.google.api.client.auth.oauth2.Credential authorize() throws IOException
IOException
public Resolution doWithCredential(String userId, Callable<Resolution> action)
userId
- action
- public Resolution doWithCredential(Callable<Resolution> action)
action
- protected com.google.api.client.auth.oauth2.AuthorizationCodeFlow createCodeFlow()
protected com.google.api.client.http.HttpExecuteInterceptor getHttpExecuteInterceptor()
public com.google.api.client.auth.oauth2.Credential loadCredential(String userId)
public com.google.api.client.auth.oauth2.CredentialStore getCredentialStore()
public void setCredentialStore(com.google.api.client.auth.oauth2.CredentialStore credentialStore)
public String getAuthorizeMethod()
public void setAuthorizeMethod(String authorizeMethod)
public com.google.api.client.http.HttpTransport getHttpTransport()
public void setHttpTransport(com.google.api.client.http.HttpTransport httpTransport)
public com.google.api.client.auth.oauth2.Credential.AccessMethod getAccessMethod()
public void setAccessMethod(com.google.api.client.auth.oauth2.Credential.AccessMethod accessMethod)
public String getError()
public com.google.api.client.json.JsonFactory getJsonFactory()