Interface Provider

All Known Subinterfaces:
Provider2

@ConsumerType public interface Provider
Interface for OAuth providers.
  • Method Details

    • getType

      ProviderType getType()
      Currently only oauth 1a and oauth 2 are supported.
      Returns:
      type
      See Also:
    • getApi

      Api getApi()
      Specifies an instance of scribe Api to use for this provider.
      Returns:
      Api instance
    • getDetailsURL

      String getDetailsURL()
      OAuth provider's user details URL
      Returns:
      url
    • getExtendedDetailsURLs

      String[] getExtendedDetailsURLs(String scope)
      OAuth provider's user extended details URLs, depending on the specific scope
      Returns:
      url
    • getExtendedDetailsURLs

      String[] getExtendedDetailsURLs(String scope, String userId, Map<String,Object> props)
      OAuth provider's user extended details URLs, depending on the specific scope and previously fetched data (e.g. getDetailsURL(), getExtendedDetailsURLs(String)).
      Parameters:
      scope - allows to specify a list of property names for each scope
      userId - the userId
      props - contains the data previously fetched.
      Returns:
      the list of urls to fetch extended data from.
    • getId

      String getId()
      Unique ID for this provider, used to match a ProviderConfig with this Provider
      Returns:
      ID of this provider
    • getName

      String getName()
      Readable name for this Provider
      Returns:
      name of this Provider
    • mapUserId

      String mapUserId(String userId, Map<String,Object> props)
      Map the provider's userid to CRX user id; Note that usernames must be unique so the returned username should always include some prefix specific to this provider (e.g. in case facebook and twitter have a user with the same username)
      Parameters:
      userId - provider's userId
      props - map of all provider's properties for this userId
      Returns:
      CQ user id
    • getUserFolderPath

      String getUserFolderPath(String userId, String clientId, Map<String,Object> props)
      Return the node path where the user should be created
      Parameters:
      userId - User ID
      clientId - Client ID in use when creating this user
      props - Map of all provider's properties for this user
      Returns:
      Relative path to store this user within /home/users (e.g. "facebook/1234" might be appropriate for facebook user with id=12345678)
    • mapProperties

      Map<String,Object> mapProperties(String srcUrl, String clientId, Map<String,Object> existing, Map<String,String> newProperties)
      Map the provider's user properties name to CQ user properties. This method will at least be called to map properties fetched from getDetailsURL(). If getExtendedDetailsURLs(String) is not null, this method will be called for the map of properties fetched from each url.
      Parameters:
      srcUrl -
      clientId - in use to retrieve this set of properties
      existing - CQ properties that have already been mapped
      newProperties - addition provider properties that need to be mapped
      Returns:
      the result of mapping the new properties, and combining with the existing
    • getAccessTokenPropertyPath

      String getAccessTokenPropertyPath(String clientId)
      Return the property path where the access token will be stored (if ProviderConfig is has access token storage enabled)
      Parameters:
      clientId - OAuth client ID
      Returns:
      the property path where access token may be stored for a user e.g. profile/someapp-clientid/accesstoken
    • getOAuthIdPropertyPath

      String getOAuthIdPropertyPath(String clientId)
      Return the property path where the oauth user id will be stored
      Parameters:
      clientId - OAuth client ID
      Returns:
      The property path.
    • getCurrentUser

      User getCurrentUser(SlingHttpServletRequest request)
      Use the request to get the User who has (or will have) oauth profile data attached
      Parameters:
      request - HTTP request containing the user information
      Returns:
      the User or null, if no User is associated with the request
    • onUserCreate

      void onUserCreate(User user)
      Method called after a user is updated (e.g. profile data is mapped and applied to the user);
    • onUserUpdate

      void onUserUpdate(User user)
      Method called after a user is created (i.e. profile data is mapped and applied to user already);
    • getProtectedDataRequest

      OAuthRequest getProtectedDataRequest(String url)
      Create an OAuthRequest to request protected data from the OAuth provider system.
      Parameters:
      url - URL of the request
      Returns:
      The OAuthRequest
      Since:
      2.0
    • parseProfileDataResponse

      Map<String,String> parseProfileDataResponse(Response response) throws IOException
      Parse the OAuth Response for protected profile data during profile import
      Parameters:
      response - Response with profile data
      Returns:
      Map of profile properties
      Throws:
      IOException
      Since:
      2.0
    • getUserIdProperty

      String getUserIdProperty()
      What is the user data property that contains this OAuth provider's user id? (e.g. "id")
      Returns:
      The property that contains the user ID.
    • getValidateTokenUrl

      String getValidateTokenUrl(String clientId, String token)
      Return the URL used to validate the token for this OAuth provider.
      Parameters:
      clientId - OAuth client ID
      token - Token
      Returns:
      url or null if validate token is not supported
      Since:
      2.1
    • isValidToken

      boolean isValidToken(String responseBody, String clientId, String tokenType)
      Check the validity of a token
      Parameters:
      responseBody - Response body containing the answer to the token validation request.
      clientId - Client ID that should have issued the token.
      tokenType - Accepted token type.
      Returns:
      true if the response body contains the validity of the token, the token has been issued for the provided clientId and the token type matches with the one provided
      Since:
      2.1
    • getUserIdFromValidateTokenResponseBody

      String getUserIdFromValidateTokenResponseBody(String responseBody)
      Parse the response body and return the userId contained in the response
      Returns:
      the userId contained in the response or null if is not contained
      Since:
      2.1
    • getErrorDescriptionFromValidateTokenResponseBody

      String getErrorDescriptionFromValidateTokenResponseBody(String responseBody)
      Parse the response body and return the error description contained in the response
      Returns:
      the error description contained in the response or null if is not contained
      Since:
      2.1