Package org.pac4j.oauth.profile.creator
Class OAuth20ProfileCreator<U extends OAuth20Profile>
- java.lang.Object
-
- org.pac4j.oauth.profile.creator.OAuth20ProfileCreator<U>
-
- All Implemented Interfaces:
ProfileCreator<OAuth20Credentials>
- Direct Known Subclasses:
DropBoxProfileCreator,FacebookProfileCreator,FigShareProfileCreator,FoursquareProfileCreator,LinkedIn2ProfileCreator,QQProfileCreator,WechatProfileCreator
public class OAuth20ProfileCreator<U extends OAuth20Profile> extends Object
OAuth 2.0 profile creator.- Since:
- 2.0.0
- Author:
- Jerome Leleu
-
-
Field Summary
Fields Modifier and Type Field Description protected IndirectClientclientprotected Oconfigurationprotected org.slf4j.Loggerloggerprotected static com.fasterxml.jackson.databind.ObjectMappermapper
-
Constructor Summary
Constructors Constructor Description OAuth20ProfileCreator(OAuth20Configuration configuration, IndirectClient client)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAccessTokenToProfile(U profile, com.github.scribejava.core.model.OAuth2AccessToken accessToken)Add the access token to the profile (as an attribute).Optional<UserProfile>create(C credentials, WebContext context)protected com.github.scribejava.core.model.OAuthRequestcreateOAuthRequest(String url, com.github.scribejava.core.model.Verb verb)Create an OAuth request.protected com.github.scribejava.core.model.OAuth2AccessTokengetAccessToken(OAuth20Credentials credentials)Get the access token from OAuth credentials.protected Optional<UserProfile>retrieveUserProfileFromToken(WebContext context, T accessToken)Retrieve the user profile from the access token.protected StringsendRequestForData(S service, T accessToken, String dataUrl, com.github.scribejava.core.model.Verb verb)Make a request to get the data of the authenticated user for the provider.protected voidsignRequest(com.github.scribejava.core.oauth.OAuth20Service service, com.github.scribejava.core.model.OAuth2AccessToken accessToken, com.github.scribejava.core.model.OAuthRequest request)Sign the request.
-
-
-
Field Detail
-
logger
protected final org.slf4j.Logger logger
-
mapper
protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
configuration
protected O extends OAuthConfiguration<S,T> configuration
-
client
protected IndirectClient client
-
-
Constructor Detail
-
OAuth20ProfileCreator
public OAuth20ProfileCreator(OAuth20Configuration configuration, IndirectClient client)
-
-
Method Detail
-
getAccessToken
protected com.github.scribejava.core.model.OAuth2AccessToken getAccessToken(OAuth20Credentials credentials)
Get the access token from OAuth credentials.- Parameters:
credentials- credentials- Returns:
- the access token
-
addAccessTokenToProfile
protected void addAccessTokenToProfile(U profile, com.github.scribejava.core.model.OAuth2AccessToken accessToken)
Add the access token to the profile (as an attribute).- Parameters:
profile- the user profileaccessToken- the access token
-
signRequest
protected void signRequest(com.github.scribejava.core.oauth.OAuth20Service service, com.github.scribejava.core.model.OAuth2AccessToken accessToken, com.github.scribejava.core.model.OAuthRequest request)Sign the request.- Parameters:
service- the serviceaccessToken- the tokenrequest- the request
-
create
public Optional<UserProfile> create(C credentials, WebContext context)
- Specified by:
createin interfaceProfileCreator<C extends OAuthCredentials>
-
retrieveUserProfileFromToken
protected Optional<UserProfile> retrieveUserProfileFromToken(WebContext context, T accessToken)
Retrieve the user profile from the access token.- Parameters:
context- the web contextaccessToken- the access token- Returns:
- the user profile
-
sendRequestForData
protected String sendRequestForData(S service, T accessToken, String dataUrl, com.github.scribejava.core.model.Verb verb)
Make a request to get the data of the authenticated user for the provider.- Parameters:
service- the OAuth serviceaccessToken- the access tokendataUrl- url of the dataverb- method used to request data- Returns:
- the user data response
-
createOAuthRequest
protected com.github.scribejava.core.model.OAuthRequest createOAuthRequest(String url, com.github.scribejava.core.model.Verb verb)
Create an OAuth request.- Parameters:
url- the url to callverb- method used to create the request- Returns:
- the request
-
-