com.paypal.core.nvp.CertificateHttpHeaderAuthStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of paypal-core Show documentation
Show all versions of paypal-core Show documentation
PayPal Java SDK Core library base and common to PayPal SDKs. The paypal-core library is a dependency for all PayPal related Java SDKs
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 - 2025 Weber Informatics LLC | Privacy Policy