![JAR search and dependency download from the Maven repository](/logo.png)
com.adobe.granite.auth.oauth.Provider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2012 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
package com.adobe.granite.auth.oauth;
import org.osgi.annotation.versioning.ConsumerType;
import org.apache.jackrabbit.api.security.user.User;
import org.apache.sling.api.SlingHttpServletRequest;
import org.scribe.builder.api.Api;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Response;
import java.io.IOException;
import java.util.Map;
/**
* Interface for OAuth providers.
*/
@ConsumerType
public interface Provider {
/**
* Currently only oauth 1a and oauth 2 are supported.
* @see ProviderType
* @return type
*/
ProviderType getType();
/**
* Specifies an instance of scribe {@link Api} to use for this provider.
* @return Api instance
*/
Api getApi();
/**
* OAuth provider's user details URL
* @return url
*/
String getDetailsURL();
/**
* OAuth provider's user extended details URLs, depending on the specific scope
* @return url
*/
String[] getExtendedDetailsURLs(String scope);
/**
* OAuth provider's user extended details URLs, depending on the specific scope and previously fetched data
* (e.g. {@link #getDetailsURL()}, {@link #getExtendedDetailsURLs(String)}).
* @param scope allows to specify a list of property names for each scope
* @param userId the userId
* @param props contains the data previously fetched.
* @return the list of urls to fetch extended data from.
*/
String[] getExtendedDetailsURLs(String scope, String userId, Map props);
/**
* Unique ID for this provider, used to match a ProviderConfig with this Provider
* @return ID of this provider
*/
String getId();
/**
* Readable name for this Provider
* @return name of this Provider
*/
String getName();
/**
* 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)
* @param userId provider's userId
* @param props map of all provider's properties for this userId
* @return CQ user id
*/
String mapUserId(String userId, Map props);
/**
* Return the node path where the user should be created
* @param userId User ID
* @param clientId Client ID in use when creating this user
* @param props Map of all provider's properties for this user
* @return Relative path to store this user within /home/users (e.g. "facebook/1234" might be appropriate for
* facebook user with id=12345678)
*/
String getUserFolderPath(String userId, String clientId, Map props);
/**
* Map the provider's user properties name to CQ user properties.
* This method will at least be called to map properties fetched from {@link #getDetailsURL()}.
* If {@link #getExtendedDetailsURLs(String)} is not null, this
* method will be called for the map of properties fetched from each url.
* @param srcUrl
* @param clientId in use to retrieve this set of properties
* @param existing CQ properties that have already been mapped
* @param newProperties addition provider properties that need to be mapped
* @return the result of mapping the new properties, and combining with the existing
*/
Map mapProperties(String srcUrl, String clientId, Map existing, Map newProperties);
/**
* Return the property path where the access token will be stored (if ProviderConfig is has access token storage enabled)
* @param clientId OAuth client ID
* @return the property path where access token may be stored for a user e.g. profile/someapp-clientid/accesstoken
*/
String getAccessTokenPropertyPath(String clientId);
/**
* Return the property path where the oauth user id will be stored
* @param clientId OAuth client ID
* @return The property path.
*/
String getOAuthIdPropertyPath(String clientId);
/**
* Use the request to get the User who has (or will have) oauth profile data attached
* @param request HTTP request containing the user information
* @return the User or null, if no User is associated with the request
*/
User getCurrentUser(SlingHttpServletRequest request);
/**
* Method called after a user is updated (e.g. profile data is mapped and applied to the user);
*
*/
void onUserCreate(User user);
/**
* Method called after a user is created (i.e. profile data is mapped and applied to user already);
*
*/
void onUserUpdate(User user);
/**
* Create an OAuthRequest to request protected data from the OAuth provider system.
* @param url URL of the request
* @return The OAuthRequest
*
* @since 2.0
*/
OAuthRequest getProtectedDataRequest(String url);
/**
* Parse the OAuth Response for protected profile data during profile import
* @param response Response with profile data
* @return Map of profile properties
*
* @since 2.0
*/
Map parseProfileDataResponse(Response response) throws IOException;
/**
* What is the user data property that contains this OAuth provider's user id? (e.g. "id")
* @return The property that contains the user ID.
*/
String getUserIdProperty();
/**
* Return the URL used to validate the token for this OAuth provider.
*
* @param clientId OAuth client ID
* @param token Token
* @return url or null if validate token is not supported
*
* @since 2.1
*/
String getValidateTokenUrl(String clientId, String token);
/**
* Check the validity of a token
*
* @param responseBody Response body containing the answer to the token validation request.
* @param clientId Client ID that should have issued the token.
* @param tokenType Accepted token type.
* @return 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
*/
boolean isValidToken(String responseBody, String clientId, String tokenType);
/**
* Parse the response body and return the userId contained in the response
*
* @return the userId contained in the response or null if is not contained
*
* @since 2.1
*/
String getUserIdFromValidateTokenResponseBody(String responseBody);
/**
* Parse the response body and return the error description contained in the response
*
* @return the error description contained in the response or null if is not contained
*
* @since 2.1
*/
String getErrorDescriptionFromValidateTokenResponseBody(String responseBody);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy