Package org.pac4j.oauth.profile.facebook
Class FacebookProfileDefinition
- java.lang.Object
-
- org.pac4j.core.profile.definition.ProfileDefinition<P>
-
- org.pac4j.core.profile.definition.CommonProfileDefinition<P>
-
- org.pac4j.oauth.profile.definition.OAuthProfileDefinition<P,com.github.scribejava.core.model.OAuth2AccessToken,C>
-
- org.pac4j.oauth.profile.definition.OAuth20ProfileDefinition<FacebookProfile,FacebookConfiguration>
-
- org.pac4j.oauth.profile.facebook.FacebookProfileDefinition
-
public class FacebookProfileDefinition extends OAuth20ProfileDefinition<FacebookProfile,FacebookConfiguration>
This class is the Facebook profile definition.- Since:
- 1.1.0
- Author:
- Jerome Leleu
-
-
Field Summary
Fields Modifier and Type Field Description static StringABOUTstatic StringALBUMSprotected static StringAPPSECRET_PARAMETERprotected static StringBASE_URLstatic StringBIRTHDAYstatic StringBOOKSstatic intDEFAULT_LIMITstatic StringEDUCATIONstatic StringEVENTSstatic StringFAVORITE_ATHLETESstatic StringFAVORITE_TEAMSstatic StringFRIENDSstatic StringGROUPSstatic StringHOMETOWNstatic StringINTERESTED_INstatic StringLANGUAGESstatic StringLAST_NAMEstatic StringLIKESstatic StringLINKstatic StringMIDDLE_NAMEstatic StringMOVIESstatic StringMUSICstatic StringMUSIC_LISTENSstatic StringNAMEstatic StringPICTUREstatic StringPOLITICALstatic StringQUOTESstatic StringRELATIONSHIP_STATUSstatic StringRELIGIONstatic StringSIGNIFICANT_OTHERstatic StringTHIRD_PARTY_IDstatic StringTIMEZONEstatic StringUPDATED_TIMEstatic StringVERIFIEDstatic StringWEBSITEstatic StringWORK-
Fields inherited from class org.pac4j.core.profile.definition.CommonProfileDefinition
DISPLAY_NAME, EMAIL, FAMILY_NAME, FIRST_NAME, GENDER, LOCALE, LOCATION, PICTURE_URL, PROFILE_URL
-
Fields inherited from class org.pac4j.core.profile.definition.ProfileDefinition
logger, newProfile
-
-
Constructor Summary
Constructors Constructor Description FacebookProfileDefinition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcomputeAppSecretProof(String url, com.github.scribejava.core.model.OAuth2AccessToken token, FacebookConfiguration configuration)The code in this method is based on this blog post: https://www.sammyk.me/the-single-most-important-way-to-make-your-facebook-app-more-secure and this answer: https://stackoverflow.com/questions/7124735/hmac-sha256-algorithm-for-signature-calculationprotected voidextractData(FacebookProfile profile, com.fasterxml.jackson.databind.JsonNode json, String name)FacebookProfileextractUserProfile(String body)Extract the user profile from the response (JSON, XML...) of the profile url.StringgetProfileUrl(com.github.scribejava.core.model.OAuth2AccessToken accessToken, FacebookConfiguration configuration)Retrieve the url of the profile of the authenticated user for the provider.-
Methods inherited from class org.pac4j.oauth.profile.definition.OAuthProfileDefinition
getProfileVerb, raiseProfileExtractionError, raiseProfileExtractionJsonError, raiseProfileExtractionJsonError
-
Methods inherited from class org.pac4j.core.profile.definition.CommonProfileDefinition
configurePrimaryAttributes
-
Methods inherited from class org.pac4j.core.profile.definition.ProfileDefinition
convertAndAdd, convertAndAdd, getConverters, getPrimaryAttributes, getProfileId, getSecondaryAttributes, newProfile, primary, secondary, setProfileFactory, setProfileId
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
MIDDLE_NAME
public static final String MIDDLE_NAME
- See Also:
- Constant Field Values
-
LAST_NAME
public static final String LAST_NAME
- See Also:
- Constant Field Values
-
LANGUAGES
public static final String LANGUAGES
- See Also:
- Constant Field Values
-
LINK
public static final String LINK
- See Also:
- Constant Field Values
-
THIRD_PARTY_ID
public static final String THIRD_PARTY_ID
- See Also:
- Constant Field Values
-
TIMEZONE
public static final String TIMEZONE
- See Also:
- Constant Field Values
-
UPDATED_TIME
public static final String UPDATED_TIME
- See Also:
- Constant Field Values
-
VERIFIED
public static final String VERIFIED
- See Also:
- Constant Field Values
-
ABOUT
public static final String ABOUT
- See Also:
- Constant Field Values
-
BIRTHDAY
public static final String BIRTHDAY
- See Also:
- Constant Field Values
-
EDUCATION
public static final String EDUCATION
- See Also:
- Constant Field Values
-
HOMETOWN
public static final String HOMETOWN
- See Also:
- Constant Field Values
-
INTERESTED_IN
public static final String INTERESTED_IN
- See Also:
- Constant Field Values
-
POLITICAL
public static final String POLITICAL
- See Also:
- Constant Field Values
-
FAVORITE_ATHLETES
public static final String FAVORITE_ATHLETES
- See Also:
- Constant Field Values
-
FAVORITE_TEAMS
public static final String FAVORITE_TEAMS
- See Also:
- Constant Field Values
-
QUOTES
public static final String QUOTES
- See Also:
- Constant Field Values
-
RELATIONSHIP_STATUS
public static final String RELATIONSHIP_STATUS
- See Also:
- Constant Field Values
-
RELIGION
public static final String RELIGION
- See Also:
- Constant Field Values
-
SIGNIFICANT_OTHER
public static final String SIGNIFICANT_OTHER
- See Also:
- Constant Field Values
-
WEBSITE
public static final String WEBSITE
- See Also:
- Constant Field Values
-
WORK
public static final String WORK
- See Also:
- Constant Field Values
-
FRIENDS
public static final String FRIENDS
- See Also:
- Constant Field Values
-
MOVIES
public static final String MOVIES
- See Also:
- Constant Field Values
-
MUSIC
public static final String MUSIC
- See Also:
- Constant Field Values
-
BOOKS
public static final String BOOKS
- See Also:
- Constant Field Values
-
LIKES
public static final String LIKES
- See Also:
- Constant Field Values
-
ALBUMS
public static final String ALBUMS
- See Also:
- Constant Field Values
-
EVENTS
public static final String EVENTS
- See Also:
- Constant Field Values
-
GROUPS
public static final String GROUPS
- See Also:
- Constant Field Values
-
MUSIC_LISTENS
public static final String MUSIC_LISTENS
- See Also:
- Constant Field Values
-
PICTURE
public static final String PICTURE
- See Also:
- Constant Field Values
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT
- See Also:
- Constant Field Values
-
BASE_URL
protected static final String BASE_URL
- See Also:
- Constant Field Values
-
APPSECRET_PARAMETER
protected static final String APPSECRET_PARAMETER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getProfileUrl
public String getProfileUrl(com.github.scribejava.core.model.OAuth2AccessToken accessToken, FacebookConfiguration configuration)
Description copied from class:OAuthProfileDefinitionRetrieve the url of the profile of the authenticated user for the provider.- Specified by:
getProfileUrlin classOAuthProfileDefinition<FacebookProfile,com.github.scribejava.core.model.OAuth2AccessToken,FacebookConfiguration>- Parameters:
accessToken- only used when constructing dynamic urls from data in the tokenconfiguration- the current configuration- Returns:
- the url of the user profile given by the provider
-
computeAppSecretProof
public String computeAppSecretProof(String url, com.github.scribejava.core.model.OAuth2AccessToken token, FacebookConfiguration configuration)
The code in this method is based on this blog post: https://www.sammyk.me/the-single-most-important-way-to-make-your-facebook-app-more-secure and this answer: https://stackoverflow.com/questions/7124735/hmac-sha256-algorithm-for-signature-calculation- Parameters:
url- the URL to which we're adding the prooftoken- the application token we pass back and forthconfiguration- the current configuration- Returns:
- URL with the appsecret_proof parameter added
-
extractUserProfile
public FacebookProfile extractUserProfile(String body)
Description copied from class:OAuthProfileDefinitionExtract the user profile from the response (JSON, XML...) of the profile url.- Specified by:
extractUserProfilein classOAuthProfileDefinition<FacebookProfile,com.github.scribejava.core.model.OAuth2AccessToken,FacebookConfiguration>- Parameters:
body- the response body- Returns:
- the returned profile
-
extractData
protected void extractData(FacebookProfile profile, com.fasterxml.jackson.databind.JsonNode json, String name)
-
-