com.paypal.core.soap.SignatureHttpHeaderAuthStrategy 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.soap;
import java.util.HashMap;
import java.util.Map;
import com.paypal.core.AbstractSignatureHttpHeaderAuthStrategy;
import com.paypal.core.Constants;
import com.paypal.core.credential.SignatureCredential;
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 SignatureCredential} and
* retrieves them as HTTP headers
*
*/
public class SignatureHttpHeaderAuthStrategy extends
AbstractSignatureHttpHeaderAuthStrategy {
/**
* SignatureHttpHeaderAuthStrategy
*
* @param endPointUrl
*/
public SignatureHttpHeaderAuthStrategy(String endPointUrl) {
super(endPointUrl);
}
/**
* Processing for {@link TokenAuthorization} under
* {@link SignatureCredential}
*
* @param sigCred
* {@link SignatureCredential} instance
* @param tokenAuth
* {@link TokenAuthorization} instance
* @return Map of HTTP headers
* @throws OAuthException
*/
protected Map processTokenAuthorization(
SignatureCredential sigCred, TokenAuthorization tokenAuth)
throws OAuthException {
Map headers = new HashMap();
String authString = OAuthSignature.getFullAuthString(
sigCred.getUserName(), sigCred.getPassword(),
tokenAuth.getAccessToken(), tokenAuth.getTokenSecret(),
OAuthSignature.HTTPMethod.POST, endPointUrl, null);
headers.put(Constants.PAYPAL_AUTHORIZATION_MERCHANT_HEADER, authString);
return headers;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy