Class GenericOAuth20ProfileDefinition

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.generic.GenericOAuth20ProfileDefinition

public class GenericOAuth20ProfileDefinition extends OAuthProfileDefinition

This class is the user profile for generic OAuth2 with appropriate getters.

The map of profileAttributes is intended to replace the primary/secondary attributes where the key is the name of the attribute and the value is the path to obtain that attribute from the json response starting from firstNodePath

Author:
Julio Arrebola
  • Field Summary

    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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Extract the user profile from the response (JSON, XML...) of the profile url.
    Getter for the field firstNodePath.
    Getter for the field profileAttributes.
    getProfileUrl(com.github.scribejava.core.model.Token accessToken, OAuthConfiguration configuration)
    Retrieve the url of the profile of the authenticated user for the provider.
    com.github.scribejava.core.model.Verb
    Get HTTP Method to request profile.
    void
    profileAttribute(String name, String tag, org.pac4j.core.profile.converter.AttributeConverter converter)
    Add an attribute as a primary one and its converter.
    void
    profileAttribute(String name, org.pac4j.core.profile.converter.AttributeConverter converter)
    Add an attribute as a primary one and its converter.
    void
    setFirstNodePath(String firstNodePath)
    Setter for the field firstNodePath.
    void
    setProfileUrl(String profileUrl)
    Setter for the field profileUrl.
    void
    setProfileVerb(com.github.scribejava.core.model.Verb value)
    Setter for the field profileVerb.

    Methods inherited from class org.pac4j.core.profile.definition.CommonProfileDefinition

    configurePrimaryAttributes

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GenericOAuth20ProfileDefinition

      public GenericOAuth20ProfileDefinition()
  • Method Details

    • setProfileVerb

      public void setProfileVerb(com.github.scribejava.core.model.Verb value)

      Setter for the field profileVerb.

      Parameters:
      value - a Verb object
    • getProfileVerb

      public com.github.scribejava.core.model.Verb getProfileVerb()
      Get HTTP Method to request profile.
      Overrides:
      getProfileVerb in class OAuthProfileDefinition
      Returns:
      http verb
    • setProfileUrl

      public void setProfileUrl(String profileUrl)

      Setter for the field profileUrl.

      Parameters:
      profileUrl - a String object
    • 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:
      getProfileUrl in class OAuthProfileDefinition
      Parameters:
      accessToken - only used when constructing dynamic urls from data in the token
      configuration - the current configuration
      Returns:
      the url of the user profile given by the provider
    • extractUserProfile

      public OAuth20Profile extractUserProfile(String body)
      Extract the user profile from the response (JSON, XML...) of the profile url.
      Specified by:
      extractUserProfile in class OAuthProfileDefinition
      Parameters:
      body - the response body
      Returns:
      the returned profile
    • getProfileAttributes

      public Map<String,String> getProfileAttributes()

      Getter for the field profileAttributes.

      Returns:
      a Map object
    • profileAttribute

      public void profileAttribute(String name, org.pac4j.core.profile.converter.AttributeConverter converter)
      Add an attribute as a primary one and its converter.
      Parameters:
      name - name of the attribute
      converter - converter
    • profileAttribute

      public void profileAttribute(String name, String tag, org.pac4j.core.profile.converter.AttributeConverter converter)
      Add an attribute as a primary one and its converter.
      Parameters:
      name - name of the attribute
      tag - json reference
      converter - converter
    • getFirstNodePath

      public String getFirstNodePath()

      Getter for the field firstNodePath.

      Returns:
      a String object
    • setFirstNodePath

      public void setFirstNodePath(String firstNodePath)

      Setter for the field firstNodePath.

      Parameters:
      firstNodePath - a String object