All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paypal.core.nvp.CertificateHttpHeaderAuthStrategy Maven / Gradle / Ivy

Go to download

PayPal Java SDK Core library base and common to PayPal SDKs. The paypal-core library is a dependency for all PayPal related Java SDKs

There is a newer version: 1.7.2
Show newest version
package com.paypal.core.nvp;

import java.util.HashMap;
import java.util.Map;

import com.paypal.core.AbstractCertificateHttpHeaderAuthStrategy;
import com.paypal.core.Constants;
import com.paypal.core.credential.CertificateCredential;
import com.paypal.core.credential.TokenAuthorization;
import com.paypal.sdk.exceptions.OAuthException;
import com.paypal.sdk.util.OAuthSignature;

/**
 * CertificateHttpHeaderAuthStrategy is an implementation of
 * {@link AuthenticationStrategy} which acts on {@link CertificateCredential}
 * and retrieves them as HTTP headers
 * 
 */
public class CertificateHttpHeaderAuthStrategy extends
		AbstractCertificateHttpHeaderAuthStrategy {

	/**
	 * CertificateHttpHeaderAuthStrategy
	 * 
	 * @param endPointUrl
	 */
	public CertificateHttpHeaderAuthStrategy(String endPointUrl) {
		super(endPointUrl);
	}

	/**
	 * Processing for {@link TokenAuthorization} under
	 * {@link CertificateCredential}
	 * 
	 * @param credential
	 *            {@link CertificateCredential} instance
	 * @param tokenAuth
	 *            {@link TokenAuthorization} instance
	 * @return Map of HTTP headers
	 * @throws OAuthException
	 */
	protected Map processTokenAuthorization(
			CertificateCredential credential, TokenAuthorization tokenAuth)
			throws OAuthException {
		Map headers = new HashMap();
		String authString = OAuthSignature.getFullAuthString(
				credential.getUserName(), credential.getPassword(),
				tokenAuth.getAccessToken(), tokenAuth.getTokenSecret(),
				OAuthSignature.HTTPMethod.POST, endPointUrl, null);
		headers.put(Constants.PAYPAL_AUTHORIZATION_PLATFORM_HEADER, authString);
		return headers;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy