public class GoogleProcessorImpl extends Object implements GoogleProcessor
| Constructor and Description |
|---|
GoogleProcessorImpl(org.exoplatform.container.ExoContainerContext context,
org.exoplatform.container.xml.InitParams params,
SecureRandomService secureRandomService) |
| Modifier and Type | Method and Description |
|---|---|
GoogleAccessTokenContext |
getAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile,
OAuthCodec codec)
Obtain needed data from given userProfile and create accessToken from them
|
<C> C |
getAuthorizedSocialApiObject(GoogleAccessTokenContext accessToken,
Class<C> socialApiObjectType)
Return object, which can be used to call some operations on this Social network.
|
com.google.api.services.oauth2.Oauth2 |
getOAuth2Instance(GoogleAccessTokenContext accessTokenContext)
Obtain instance of Google
Oauth2 object, which can be used to call various operations in Google API (obtain user informations,
obtain informations about your access token etc) |
protected com.google.api.services.oauth2.Oauth2 |
getOAuth2InstanceImpl(com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse tokenData) |
com.google.api.services.plus.Plus |
getPlusService(GoogleAccessTokenContext accessTokenContext)
Obtain instance of Google (@link Plus} object, which can be used to call various operations in Google+ API (Obtain list of your friends,
obtain your statuses, comments, activities etc...)
|
protected InteractionState<GoogleAccessTokenContext> |
initialInteraction(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Set<String> scopes) |
protected com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse |
obtainAccessToken(javax.servlet.http.HttpServletRequest request) |
com.google.api.services.oauth2.model.Userinfo |
obtainUserInfo(GoogleAccessTokenContext accessTokenContext)
Obtain informations about user from Google+ .
|
InteractionState<GoogleAccessTokenContext> |
processOAuthInteraction(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse)
Process OAuth workflow for this OAuth provider (social network).
|
InteractionState<GoogleAccessTokenContext> |
processOAuthInteraction(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
String scope)
Possibility to create new OAuth interaction with custom scope (not just the scope which is provided in configuration of this OAuth processor)
|
protected InteractionState<GoogleAccessTokenContext> |
processOAuthInteractionImpl(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Set<String> scopes) |
void |
refreshToken(GoogleAccessTokenContext accessTokenContext)
Refresh Google+ token.
|
void |
removeAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile)
Remove data about access token from this user profile
|
void |
revokeToken(GoogleAccessTokenContext accessTokenContext)
Revoke given access token on OAuth provider side, so application is removed from list of supported applications for given user
|
void |
saveAccessTokenAttributesToUserProfile(org.exoplatform.services.organization.UserProfile userProfile,
OAuthCodec codec,
GoogleAccessTokenContext accessToken)
Save accessToken data to given userProfile.
|
GoogleAccessTokenContext |
validateTokenAndUpdateScopes(GoogleAccessTokenContext accessTokenContext)
Send request to OAuth Provider to validate if given access token is valid and ask for scopes, which are available for given accessToken.
|
public GoogleProcessorImpl(org.exoplatform.container.ExoContainerContext context,
org.exoplatform.container.xml.InitParams params,
SecureRandomService secureRandomService)
public InteractionState<GoogleAccessTokenContext> processOAuthInteraction(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse) throws IOException, OAuthException
OAuthProviderProcessorInteractionState
is in state InteractionState.State.FINISH and in this case, InteractionState should also have accessToken filled.
If InteractionState is in state InteractionState.State.AUTH, then more redirections are needed. In this case,
given HttpServletResponse should be already committed and prepared for redirection.processOAuthInteraction in interface OAuthProviderProcessor<GoogleAccessTokenContext>IOException - if IO error occured (for example if httpResponse.sendRedirect failed)OAuthException - in case of some other error, which may be specific for this OAuth processor (Details are available in error code)
Caller should be able to handle at least OAuthExceptionCode.USER_DENIED_SCOPE
which happens when user denied scope (authorization screen in web of given social network)public InteractionState<GoogleAccessTokenContext> processOAuthInteraction(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, String scope) throws IOException, OAuthException
OAuthProviderProcessorprocessOAuthInteraction in interface OAuthProviderProcessor<GoogleAccessTokenContext>scope - custom scope, which contains all scopes in single String divided by AccessTokenContext.DELIMITERIOExceptionOAuthExceptionOAuthProviderProcessor.processOAuthInteraction(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)protected InteractionState<GoogleAccessTokenContext> processOAuthInteractionImpl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Set<String> scopes) throws IOException
IOExceptionprotected InteractionState<GoogleAccessTokenContext> initialInteraction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Set<String> scopes) throws IOException
IOExceptionprotected com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse obtainAccessToken(javax.servlet.http.HttpServletRequest request)
throws IOException
IOExceptionpublic GoogleAccessTokenContext validateTokenAndUpdateScopes(GoogleAccessTokenContext accessTokenContext)
OAuthProviderProcessorvalidateTokenAndUpdateScopes in interface OAuthProviderProcessor<GoogleAccessTokenContext>accessTokenContext - accessToken which will be used to ask OAuthProvider about validation and for available scopespublic <C> C getAuthorizedSocialApiObject(GoogleAccessTokenContext accessToken, Class<C> socialApiObjectType)
OAuthProviderProcessorgetAuthorizedSocialApiObject in interface OAuthProviderProcessor<GoogleAccessTokenContext>accessToken - access token used to initialize objectsocialApiObjectType - Type of object, which we wanted to return. Method will return null if this type is not supported by this processorpublic com.google.api.services.oauth2.model.Userinfo obtainUserInfo(GoogleAccessTokenContext accessTokenContext)
GoogleProcessorobtainUserInfo in interface GoogleProcessoraccessTokenContext - google access tokenpublic com.google.api.services.oauth2.Oauth2 getOAuth2Instance(GoogleAccessTokenContext accessTokenContext)
GoogleProcessorOauth2 object, which can be used to call various operations in Google API (obtain user informations,
obtain informations about your access token etc)getOAuth2Instance in interface GoogleProcessorprotected com.google.api.services.oauth2.Oauth2 getOAuth2InstanceImpl(com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse tokenData)
public com.google.api.services.plus.Plus getPlusService(GoogleAccessTokenContext accessTokenContext)
GoogleProcessorgetPlusService in interface GoogleProcessorpublic void saveAccessTokenAttributesToUserProfile(org.exoplatform.services.organization.UserProfile userProfile,
OAuthCodec codec,
GoogleAccessTokenContext accessToken)
OAuthProviderProcessorsaveAccessTokenAttributesToUserProfile in interface OAuthProviderProcessor<GoogleAccessTokenContext>userProfile - where data about access token will be filledcodec - to encode some attributes (sensitive data) before save them to user profileaccessToken - specific access token for this OAuth processorpublic GoogleAccessTokenContext getAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile, OAuthCodec codec)
OAuthProviderProcessorgetAccessTokenFromUserProfile in interface OAuthProviderProcessor<GoogleAccessTokenContext>userProfile - where data from access token will be obtainedcodec - to decode data from userProfilepublic void removeAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile)
OAuthProviderProcessorremoveAccessTokenFromUserProfile in interface OAuthProviderProcessor<GoogleAccessTokenContext>userProfile - from which data will be removedpublic void revokeToken(GoogleAccessTokenContext accessTokenContext) throws OAuthException
OAuthProviderProcessorrevokeToken in interface OAuthProviderProcessor<GoogleAccessTokenContext>accessTokenContext - access token to revokeOAuthException - with code OAuthExceptionCode.TOKEN_REVOCATION_FAILED
if remote revocation of access token failed for some reasonpublic void refreshToken(GoogleAccessTokenContext accessTokenContext)
GoogleProcessorrefreshToken in interface GoogleProcessorCopyright © 2018 JBoss by Red Hat. All Rights Reserved.