Package org.pac4j.oauth.profile.facebook
Class FacebookProfileDefinition
java.lang.Object
org.pac4j.core.profile.definition.ProfileDefinition
org.pac4j.core.profile.definition.CommonProfileDefinition
org.pac4j.oauth.profile.definition.OAuthProfileDefinition
org.pac4j.oauth.profile.facebook.FacebookProfileDefinition
This class is the Facebook profile definition.
- Since:
- 1.1.0
- Author:
- Jerome Leleu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstantABOUT="about"static final StringConstantALBUMS="albums"protected static final StringConstantAPPSECRET_PARAMETER="appsecret_proof"protected static final StringConstantBASE_URL="https://graph.facebook.com/v2.8/me"static final StringConstantBIRTHDAY="birthday"static final StringConstantBOOKS="books"static final intConstantDEFAULT_LIMIT=0static final StringConstantEDUCATION="education"static final StringConstantEVENTS="events"static final StringConstantFAVORITE_ATHLETES="favorite_athletes"static final StringConstantFAVORITE_TEAMS="favorite_teams"static final StringConstantFRIENDS="friends"static final StringConstantGROUPS="groups"static final StringConstantHOMETOWN="hometown"static final StringConstantINTERESTED_IN="interested_in"static final StringConstantLANGUAGES="languages"static final StringConstantLAST_NAME="last_name"static final StringConstantLIKES="likes"static final StringConstantLINK="link"static final StringConstantMIDDLE_NAME="middle_name"static final StringConstantMOVIES="movies"static final StringConstantMUSIC="music"static final StringConstantMUSIC_LISTENS="music.listens"static final StringConstantNAME="name"static final StringConstantPICTURE="picture"static final StringConstantPOLITICAL="political"static final StringConstantQUOTES="quotes"static final StringConstantRELATIONSHIP_STATUS="relationship_status"static final StringConstantRELIGION="religion"static final StringConstantSIGNIFICANT_OTHER="significant_other"static final StringConstantTHIRD_PARTY_ID="third_party_id"static final StringConstantTIMEZONE="timezone"static final StringConstantUPDATED_TIME="updated_time"static final StringConstantVERIFIED="verified"static final StringConstantWEBSITE="website"static final StringConstantWORK="work"Fields inherited from class org.pac4j.core.profile.definition.CommonProfileDefinition
DISPLAY_NAME, EMAIL, FAMILY_NAME, FIRST_NAME, GENDER, LOCALE, LOCATION, PICTURE_URL, PROFILE_URLFields inherited from class org.pac4j.core.profile.definition.ProfileDefinition
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeAppSecretProof(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(org.pac4j.core.profile.UserProfile profile, com.fasterxml.jackson.databind.JsonNode json, String name) extractData.extractUserProfile(String body) Extract the user profile from the response (JSON, XML...) of the profile url.getProfileUrl(com.github.scribejava.core.model.Token accessToken, OAuthConfiguration 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, raiseProfileExtractionJsonErrorMethods inherited from class org.pac4j.core.profile.definition.CommonProfileDefinition
configurePrimaryAttributesMethods inherited from class org.pac4j.core.profile.definition.ProfileDefinition
convertAndAdd, convertAndAdd, getConverters, getLogger, getParameter, getPrimaryAttributes, getProfileFactory, getProfileId, getSecondaryAttributes, isRestoreProfileFromTypedId, newProfile, primary, secondary, setProfileFactory, setProfileId, setRestoreProfileFromTypedId
-
Field Details
-
NAME
ConstantNAME="name"- See Also:
-
MIDDLE_NAME
ConstantMIDDLE_NAME="middle_name"- See Also:
-
LAST_NAME
ConstantLAST_NAME="last_name"- See Also:
-
LANGUAGES
ConstantLANGUAGES="languages"- See Also:
-
LINK
ConstantLINK="link"- See Also:
-
THIRD_PARTY_ID
ConstantTHIRD_PARTY_ID="third_party_id"- See Also:
-
TIMEZONE
ConstantTIMEZONE="timezone"- See Also:
-
UPDATED_TIME
ConstantUPDATED_TIME="updated_time"- See Also:
-
VERIFIED
ConstantVERIFIED="verified"- See Also:
-
ABOUT
ConstantABOUT="about"- See Also:
-
BIRTHDAY
ConstantBIRTHDAY="birthday"- See Also:
-
EDUCATION
ConstantEDUCATION="education"- See Also:
-
HOMETOWN
ConstantHOMETOWN="hometown"- See Also:
-
INTERESTED_IN
ConstantINTERESTED_IN="interested_in"- See Also:
-
POLITICAL
ConstantPOLITICAL="political"- See Also:
-
FAVORITE_ATHLETES
ConstantFAVORITE_ATHLETES="favorite_athletes"- See Also:
-
FAVORITE_TEAMS
ConstantFAVORITE_TEAMS="favorite_teams"- See Also:
-
QUOTES
ConstantQUOTES="quotes"- See Also:
-
RELATIONSHIP_STATUS
ConstantRELATIONSHIP_STATUS="relationship_status"- See Also:
-
RELIGION
ConstantRELIGION="religion"- See Also:
-
SIGNIFICANT_OTHER
ConstantSIGNIFICANT_OTHER="significant_other"- See Also:
-
WEBSITE
ConstantWEBSITE="website"- See Also:
-
WORK
ConstantWORK="work"- See Also:
-
FRIENDS
ConstantFRIENDS="friends"- See Also:
-
MOVIES
ConstantMOVIES="movies"- See Also:
-
MUSIC
ConstantMUSIC="music"- See Also:
-
BOOKS
ConstantBOOKS="books"- See Also:
-
LIKES
ConstantLIKES="likes"- See Also:
-
ALBUMS
ConstantALBUMS="albums"- See Also:
-
EVENTS
ConstantEVENTS="events"- See Also:
-
GROUPS
ConstantGROUPS="groups"- See Also:
-
MUSIC_LISTENS
ConstantMUSIC_LISTENS="music.listens"- See Also:
-
PICTURE
ConstantPICTURE="picture"- See Also:
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMITConstantDEFAULT_LIMIT=0- See Also:
-
BASE_URL
ConstantBASE_URL="https://graph.facebook.com/v2.8/me"- See Also:
-
APPSECRET_PARAMETER
ConstantAPPSECRET_PARAMETER="appsecret_proof"- See Also:
-
-
Constructor Details
-
FacebookProfileDefinition
public FacebookProfileDefinition()Constructor for FacebookProfileDefinition.
-
-
Method Details
-
getProfileUrl
public String getProfileUrl(com.github.scribejava.core.model.Token accessToken, OAuthConfiguration configuration) Retrieve the url of the profile of the authenticated user for the provider.- Specified by:
getProfileUrlin classOAuthProfileDefinition- 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
Extract the user profile from the response (JSON, XML...) of the profile url.- Specified by:
extractUserProfilein classOAuthProfileDefinition- Parameters:
body- the response body- Returns:
- the returned profile
-
extractData
protected void extractData(org.pac4j.core.profile.UserProfile profile, com.fasterxml.jackson.databind.JsonNode json, String name) extractData.
- Parameters:
profile- aFacebookProfileobjectjson- aJsonNodeobjectname- aStringobject
-