Interface Provider

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getAccessTokenPropertyPath​(java.lang.String clientId)
      Return the property path where the access token will be stored (if ProviderConfig is has access token storage enabled)
      Api getApi()
      Specifies an instance of scribe Api to use for this provider.
      User getCurrentUser​(SlingHttpServletRequest request)
      Use the request to get the User who has (or will have) oauth profile data attached
      java.lang.String getDetailsURL()
      OAuth provider's user details URL
      java.lang.String getErrorDescriptionFromValidateTokenResponseBody​(java.lang.String responseBody)
      Parse the response body and return the error description contained in the response
      java.lang.String[] getExtendedDetailsURLs​(java.lang.String scope)
      OAuth provider's user extended details URLs, depending on the specific scope
      java.lang.String[] getExtendedDetailsURLs​(java.lang.String scope, java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> props)
      OAuth provider's user extended details URLs, depending on the specific scope and previously fetched data (e.g.
      java.lang.String getId()
      Unique ID for this provider, used to match a ProviderConfig with this Provider
      java.lang.String getName()
      Readable name for this Provider
      java.lang.String getOAuthIdPropertyPath​(java.lang.String clientId)
      Return the property path where the oauth user id will be stored
      OAuthRequest getProtectedDataRequest​(java.lang.String url)
      Create an OAuthRequest to request protected data from the OAuth provider system.
      ProviderType getType()
      Currently only oauth 1a and oauth 2 are supported.
      java.lang.String getUserFolderPath​(java.lang.String userId, java.lang.String clientId, java.util.Map<java.lang.String,​java.lang.Object> props)
      Return the node path where the user should be created
      java.lang.String getUserIdFromValidateTokenResponseBody​(java.lang.String responseBody)
      Parse the response body and return the userId contained in the response
      java.lang.String getUserIdProperty()
      What is the user data property that contains this OAuth provider's user id? (e.g.
      java.lang.String getValidateTokenUrl​(java.lang.String clientId, java.lang.String token)
      Return the URL used to validate the token for this OAuth provider.
      boolean isValidToken​(java.lang.String responseBody, java.lang.String clientId, java.lang.String tokenType)
      Check the validity of a token
      java.util.Map<java.lang.String,​java.lang.Object> mapProperties​(java.lang.String srcUrl, java.lang.String clientId, java.util.Map<java.lang.String,​java.lang.Object> existing, java.util.Map<java.lang.String,​java.lang.String> newProperties)
      Map the provider's user properties name to CQ user properties.
      java.lang.String mapUserId​(java.lang.String userId, java.util.Map<java.lang.String,​java.lang.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.
      void onUserCreate​(User user)
      Method called after a user is updated (e.g.
      void onUserUpdate​(User user)
      Method called after a user is created (i.e.
      java.util.Map<java.lang.String,​java.lang.String> parseProfileDataResponse​(Response response)
      Parse the OAuth Response for protected profile data during profile import
    • Method Detail

      • getType

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

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

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

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

        java.lang.String[] getExtendedDetailsURLs​(java.lang.String scope,
                                                  java.lang.String userId,
                                                  java.util.Map<java.lang.String,​java.lang.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

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

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

        java.lang.String mapUserId​(java.lang.String userId,
                                   java.util.Map<java.lang.String,​java.lang.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

        java.lang.String getUserFolderPath​(java.lang.String userId,
                                           java.lang.String clientId,
                                           java.util.Map<java.lang.String,​java.lang.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

        java.util.Map<java.lang.String,​java.lang.Object> mapProperties​(java.lang.String srcUrl,
                                                                             java.lang.String clientId,
                                                                             java.util.Map<java.lang.String,​java.lang.Object> existing,
                                                                             java.util.Map<java.lang.String,​java.lang.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

        java.lang.String getAccessTokenPropertyPath​(java.lang.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

        java.lang.String getOAuthIdPropertyPath​(java.lang.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​(java.lang.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

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

        java.lang.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

        java.lang.String getValidateTokenUrl​(java.lang.String clientId,
                                             java.lang.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​(java.lang.String responseBody,
                             java.lang.String clientId,
                             java.lang.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

        java.lang.String getUserIdFromValidateTokenResponseBody​(java.lang.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

        java.lang.String getErrorDescriptionFromValidateTokenResponseBody​(java.lang.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