public interface OAuthProvider
Modifier and Type | Field and Description |
---|---|
static String |
FACEBOOK
Key under which Facebook OAuth provider is registered
|
static String |
GOOGLE
Key under which Google+ OAuth provider is registered
|
static String |
TWITTER
Key under which Twitter OAuth provider is registered
|
Modifier and Type | Method and Description |
---|---|
<T> T |
getAuthorizedSocialApiObject(AccessToken accessToken,
Class<T> socialApiObjectType)
Return "accessor" object, which can be used to call some operations on Social network
|
String |
getFriendlyName()
Return friendly name of this OAuth provider.
|
String |
getKey()
Return key of this OAuth provider.
|
AccessToken |
loadAccessToken(String username)
Return access token for given user from portal identity storage (DB or LDAP).
|
void |
removeAccessToken(String username)
Remove access token of given user from portal identity storage (DB or LDAP)
|
void |
revokeToken(AccessToken accessToken)
Revoke current access token on OAuth provider side, so access token won't be valid anymore and portal application
can't be seen in list of available applications of OAuth provider (For example:
https://www.facebook.com/settings?tab=applications in case of Facebook)
|
void |
saveAccessToken(String username,
AccessToken accessToken)
Save access token for given user to portal identity storage (DB or LDAP)
|
void |
startOAuthWorkflow(String neededCustomScope)
Start OAuth or OAuth2 workflow, which means redirection to OAuth provider (Social network) login screen and authorization
screen and obtaining of access token for current portal user.
|
AccessToken |
validateTokenAndUpdateScopes(AccessToken accessToken)
Check if given access token is valid and possibly update some info (like scopes or access token itself if it was refreshed)
In case that access token has been refreshed (updated) you may call
saveAccessToken(String, AccessToken) to update
it in DB (it's not done by Portal itself during call of this method) |
static final String FACEBOOK
static final String GOOGLE
static final String TWITTER
String getKey()
FACEBOOK
String getFriendlyName()
AccessToken loadAccessToken(String username) throws OAuthApiException
username
- name of portal userOAuthApiException
- if error occured. Error code would be OAuthApiExceptionCode.PERSISTENCE_ERROR
if error
occured in communication between Portal and Identity storage (DB or LDAP)void saveAccessToken(String username, AccessToken accessToken) throws OAuthApiException
username
- name of portal useraccessToken
- access token to saveOAuthApiException
- if error occured. Error code would be OAuthApiExceptionCode.PERSISTENCE_ERROR
if error
occured in communication between Portal and Identity storage (DB or LDAP)void removeAccessToken(String username) throws OAuthApiException
username
- name of portal userOAuthApiException
- if error occured. Error code would be OAuthApiExceptionCode.PERSISTENCE_ERROR
if error
occured in communication between Portal and Identity storage (DB or LDAP)void startOAuthWorkflow(String neededCustomScope) throws OAuthApiException, IOException
After whole OAuth workflow is successfully finished, you can obtain access token of current user via
loadAccessToken(String)
neededCustomScope
- required OAuth scope. This parameter can be null and in this case, OAuth workflow will be started
just with scopes from Portal configurationOAuthApiException
- if this operation is not supported or some other OAuth error occuredIOException
- if some I/O error occured (For example when calling redirecting current Servlet response)AccessToken validateTokenAndUpdateScopes(AccessToken accessToken) throws OAuthApiException
saveAccessToken(String, AccessToken)
to update
it in DB (it's not done by Portal itself during call of this method)accessToken
- access token to validateOAuthApiException
- if error occured during validation. Error code could be OAuthApiExceptionCode.ACCESS_TOKEN_ERROR
if passed access token is invalid or revoked, or OAuthApiExceptionCode.IO_ERROR
if network error happened during
communication with OAuth providervoid revokeToken(AccessToken accessToken) throws OAuthApiException
accessToken
- access token to revokeOAuthApiException
- with code OAuthApiExceptionCode.TOKEN_REVOCATION_FAILED
if revocation failed
(For example network error or access token has been already revoked before)<T> T getAuthorizedSocialApiObject(AccessToken accessToken, Class<T> socialApiObjectType) throws OAuthApiException
accessToken
- access token used to initialize objectsocialApiObjectType
- Type of requested social API objectOAuthApiException
- with code OAuthApiExceptionCode.SOCIAL_API_OBJECT_NOT_FOUND
if object of requested type
is not supported by this OAuth providerCopyright © 2013 JBoss by Red Hat. All Rights Reserved.