Interface Provider

    • 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

        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 -
        clientId - 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 retreive 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 -
        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 -
        Returns:
      • getCurrentUser

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

        void onUserCreate​(User user)
        Called after a user is updated (e.g. profile data is mapped and applied to the user);
        Parameters:
        user -
      • onUserUpdate

        void onUserUpdate​(User user)
        Called after a user is created (i.e. profile data is mapped and applied to user already);
        Parameters:
        user -
      • getProtectedDataRequest

        OAuthRequest getProtectedDataRequest​(String url)
        Create an OAuthRequest to request protected data from the OAuth provider system.
        Parameters:
        url -
        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 -
        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:
      • getValidateTokenUrl

        String getValidateTokenUrl​(String clientId,
                                   String token)
        OAuth provider validate token URL
        Parameters:
        clientId -
        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 -
        clientId -
        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
        Parameters:
        responseBody -
        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
        Parameters:
        responseBody -
        Returns:
        the error description contained in the response or null if is not contained
        Since:
        2.1