Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.api.openidconnect;
  
  import java.util.List;
  import java.util.Map;
  
 
 public final class Session {
 
 	private Session() {
 	}

Returns the PayPal URL to which the user must be redirected to start the authentication / authorization process.

Parameters:
redirectURI Uri on merchant website to where the user must be redirected to post paypal login
scope The access privilges that you are requesting for from the user. Pass empty array for all scopes. See https://developer.paypal .com/webapps/developer/docs/classic/loginwithpaypal /ht_OpenIDConnect/#parameters for more information
apiContext com.paypal.base.rest.APIContext to be used for the call.
Returns:
Redirect URL
 
 	public static String getRedirectURL(String redirectURIList<Stringscope,
 			APIContext apiContext) {
 		return getRedirectURL(redirectURIscopeapiContextnull);
 	}
 
 	public static String getRedirectURL(String redirectURIList<Stringscope,
 			APIContext apiContextClientCredentials clientCredentials) {
 		String redirectURL = null;
 		Map<StringStringconfigurationMap = null;
 		try {
 			if (apiContext.getConfigurationMap() == null) {
 				configurationMap = SDKUtil.combineDefaultMap(ConfigManager
 			} else {
 				configurationMap = SDKUtil.combineDefaultMap(apiContext
 			}
 			String baseURL = configurationMap
 			if (baseURL == null || baseURL.trim().length() <= 0) {
 				if (configurationMap.get(.) == null
 						|| (!..equalsIgnoreCase(configurationMap
 								.equalsIgnoreCase(configurationMap
 										.get(.)))) {
 					throw new RuntimeException(
 							"Mode parameter not set in dynamic configuration map");
 				} else {
 					if (..equalsIgnoreCase(configurationMap
 							.get(.))) {
 					} else if (.
 							.equalsIgnoreCase(configurationMap
 									.get(.))) {
 					}
 				}
 			}
 			if (scope == null || scope.size() <= 0) {
 				scope = new ArrayList<String>();
 				scope.add("openid");
 				scope.add("profile");
 				scope.add("address");
 				scope.add("email");
 				scope.add("phone");
 				scope.add("https://uri.paypal.com/services/paypalattributes");
 				scope.add("https://uri.paypal.com/services/expresscheckout");
 			}
 			if (!scope.contains("openid")) {
 				scope.add("openid");
 			}
 			StringBuilder stringBuilder = new StringBuilder();
 
 			// TODO revisit method while removing the similar method without
 			// ClientCredentials; ClientID and ClientSecret should not be included
 			// in configuration map - add them to the ClientCredentials class
 			String clientID = null;
 			if (clientCredentials == null) {
 				clientID = configurationMap.get(.) != null ? configurationMap
 			} else {
				clientID = clientCredentials.getClientID() != null ? clientCredentials
						.getClientID() : "";
			}
			stringBuilder
					.append("client_id=")
					.append(URLEncoder.encode(clientID,
					.append("&response_type=").append("code").append("&scope=");
			StringBuilder scpBuilder = new StringBuilder();
			for (String str : scope) {
				scpBuilder.append(str).append(" ");
			}
			stringBuilder.append(URLEncoder.encode(scpBuilder.toString(),
			stringBuilder.append("&redirect_uri=").append(
					URLEncoder.encode(redirectURI.));
			redirectURL = baseURL + "/v1/authorize?" + stringBuilder.toString();
catch (UnsupportedEncodingException exe) {
			// Ignore
		}
		return redirectURL;
	}

Returns the URL to which the user must be redirected to logout from the OpenID provider (i.e. PayPal)

Parameters:
redirectURI URI on merchant website to where the user must be redirected to post logout
idToken id_token from the TokenInfo object
apiContext com.paypal.base.rest.APIContext to be used for the call.
Returns:
Logout URL
	public static String getLogoutUrl(String redirectURIString idToken,
			APIContext apiContext) {
		String logoutURL = null;
		Map<StringStringconfigurationMap = null;
		try {
			if (apiContext.getConfigurationMap() == null) {
				configurationMap = SDKUtil.combineDefaultMap(ConfigManager
else {
				configurationMap = SDKUtil.combineDefaultMap(apiContext
			}
			String baseURL = configurationMap
			if (baseURL == null || baseURL.trim().length() <= 0) {
				if (configurationMap.get(.) == null
						|| (!..equalsIgnoreCase(configurationMap
								.equalsIgnoreCase(configurationMap
					throw new RuntimeException(
							"Mode parameter not set in dynamic configuration map");
else {
					if (..equalsIgnoreCase(configurationMap
else if (.
							.equalsIgnoreCase(configurationMap
					}
				}
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder
					.append("id_token=")
					.append(URLEncoder.encode(idToken,
					.append("&redirect_uri=")
					.append(URLEncoder.encode(redirectURI,
							.)).append("&logout=true");
			logoutURL = baseURL + "/v1/endsession?" + stringBuilder.toString();
catch (UnsupportedEncodingException exe) {
			// Ignore
		}
		return logoutURL;
	}
New to GrepCode? Check out our FAQ X