Package io.meeds.oauth.facebook
Class GateInFacebookProcessorImpl
java.lang.Object
io.meeds.oauth.facebook.GateInFacebookProcessorImpl
- All Implemented Interfaces:
GateInFacebookProcessor,OAuthProviderProcessor<FacebookAccessTokenContext>
- Author:
- Marek Posolda
-
Constructor Summary
ConstructorsConstructorDescriptionGateInFacebookProcessorImpl(org.exoplatform.container.ExoContainerContext context, org.exoplatform.container.xml.InitParams params, org.exoplatform.web.security.security.SecureRandomService secureRandomService) -
Method Summary
Modifier and TypeMethodDescriptiongetAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile, OAuthCodec codec) Obtain needed data from given userProfile and create accessToken from them<C> CgetAuthorizedSocialApiObject(FacebookAccessTokenContext accessToken, Class<C> socialApiObjectType) Return object, which can be used to call some operations on this Social network.getAvatar(FacebookAccessTokenContext accessTokenContext) getPrincipal(FacebookAccessTokenContext accessTokenContext) Obtain informations about user from Facebook and wrap them into FacebookPrincipal objectprocessOAuthInteraction(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) Process OAuth workflow for this OAuth provider (social network).processOAuthInteraction(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.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<FacebookAccessTokenContext>processOAuthInteractionImpl(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse, FacebookProcessor facebookProcessor) voidremoveAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile) Remove data about access token from this user profilevoidrevokeToken(FacebookAccessTokenContext accessToken) Revoke given access token on OAuth provider side, so application is removed from list of supported applications for given uservoidsaveAccessTokenAttributesToUserProfile(org.exoplatform.services.organization.UserProfile userProfile, OAuthCodec codec, FacebookAccessTokenContext accessTokenContext) Save accessToken data to given userProfile.validateTokenAndUpdateScopes(FacebookAccessTokenContext accessToken) Send request to OAuth Provider to validate if given access token is valid and ask for scopes, which are available for given accessToken.
-
Constructor Details
-
GateInFacebookProcessorImpl
public GateInFacebookProcessorImpl(org.exoplatform.container.ExoContainerContext context, org.exoplatform.container.xml.InitParams params, org.exoplatform.web.security.security.SecureRandomService secureRandomService)
-
-
Method Details
-
processOAuthInteraction
public InteractionState<FacebookAccessTokenContext> processOAuthInteraction(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse, String scope) throws IOException Description copied from interface:OAuthProviderProcessorPossibility to create new OAuth interaction with custom scope (not just the scope which is provided in configuration of this OAuth processor)- Specified by:
processOAuthInteractionin interfaceOAuthProviderProcessor<FacebookAccessTokenContext>scope- custom scope, which contains all scopes in single String divided byAccessTokenContext.DELIMITER- Returns:
- Throws:
IOException- See Also:
-
processOAuthInteraction
public InteractionState<FacebookAccessTokenContext> processOAuthInteraction(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) throws IOException Description copied from interface:OAuthProviderProcessorProcess OAuth workflow for this OAuth provider (social network). Workflow is finished if returnedInteractionStateis in stateInteractionState.State.FINISHand in this case, InteractionState should also have accessToken filled. IfInteractionStateis in stateInteractionState.State.AUTH, then more redirections are needed. In this case, givenHttpServletResponseshould be already committed and prepared for redirection.- Specified by:
processOAuthInteractionin interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Returns:
- InteractionState with state of OAuth interaction
- Throws:
IOException- if IO error occured (for example if httpResponse.sendRedirect failed)
-
processOAuthInteractionImpl
protected InteractionState<FacebookAccessTokenContext> processOAuthInteractionImpl(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse, FacebookProcessor facebookProcessor) throws IOException - Throws:
IOException
-
getPrincipal
Description copied from interface:GateInFacebookProcessorObtain informations about user from Facebook and wrap them into FacebookPrincipal object- Specified by:
getPrincipalin interfaceGateInFacebookProcessor- Parameters:
accessTokenContext- Facebook access token- Returns:
- FacebookPrincipal
-
getAvatar
- Specified by:
getAvatarin interfaceGateInFacebookProcessor
-
saveAccessTokenAttributesToUserProfile
public void saveAccessTokenAttributesToUserProfile(org.exoplatform.services.organization.UserProfile userProfile, OAuthCodec codec, FacebookAccessTokenContext accessTokenContext) Description copied from interface:OAuthProviderProcessorSave accessToken data to given userProfile. Note that we are not calling any DB save operations, just filling data into given userProfile- Specified by:
saveAccessTokenAttributesToUserProfilein interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Parameters:
userProfile- where data about access token will be filledcodec- to encode some attributes (sensitive data) before save them to user profileaccessTokenContext- specific access token for this OAuth processor
-
getAccessTokenFromUserProfile
public FacebookAccessTokenContext getAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile, OAuthCodec codec) Description copied from interface:OAuthProviderProcessorObtain needed data from given userProfile and create accessToken from them- Specified by:
getAccessTokenFromUserProfilein interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Parameters:
userProfile- where data from access token will be obtainedcodec- to decode data from userProfile- Returns:
- accesstoken or null if accessToken is not found in persistent storage
-
removeAccessTokenFromUserProfile
public void removeAccessTokenFromUserProfile(org.exoplatform.services.organization.UserProfile userProfile) Description copied from interface:OAuthProviderProcessorRemove data about access token from this user profile- Specified by:
removeAccessTokenFromUserProfilein interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Parameters:
userProfile- from which data will be removed
-
revokeToken
Description copied from interface:OAuthProviderProcessorRevoke given access token on OAuth provider side, so application is removed from list of supported applications for given user- Specified by:
revokeTokenin interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Parameters:
accessToken- access token to revoke
-
validateTokenAndUpdateScopes
public FacebookAccessTokenContext validateTokenAndUpdateScopes(FacebookAccessTokenContext accessToken) throws OAuthException Description copied from interface:OAuthProviderProcessorSend request to OAuth Provider to validate if given access token is valid and ask for scopes, which are available for given accessToken. Returned access token should be always valid and prepared for invoke other operations- Specified by:
validateTokenAndUpdateScopesin interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Parameters:
accessToken- accessToken which will be used to ask OAuthProvider about validation and for available scopes- Returns:
- accessTokenContext, which will be quite same as the one from accessToken parameter. It could have some info updated (like scopes)
- Throws:
OAuthException- usually with codes: -OAuthExceptionCode.ACCESS_TOKEN_ERRORif invalid access is used as argument -OAuthExceptionCode.IO_ERRORif IO error occurs
-
getAuthorizedSocialApiObject
public <C> C getAuthorizedSocialApiObject(FacebookAccessTokenContext accessToken, Class<C> socialApiObjectType) Description copied from interface:OAuthProviderProcessorReturn object, which can be used to call some operations on this Social network. For example "Plus" object for Google+ network- Specified by:
getAuthorizedSocialApiObjectin interfaceOAuthProviderProcessor<FacebookAccessTokenContext>- Parameters:
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 processor- Returns:
- initialized object of required type or null if type wasn't found (supported) by this processor
-