com.paypal.base.util
Class OAuthSignature

java.lang.Object
  extended by com.paypal.base.util.OAuthSignature

public class OAuthSignature
extends Object


Nested Class Summary
static class OAuthSignature.HTTPMethod
           
 
Field Summary
static String OAUTH_VERSION
           
 
Constructor Summary
OAuthSignature(String consumerKey, String consumerSecret)
          Default Constructor
 
Method Summary
 void addParameter(String name, String value)
          Adds Parameter.
 String computeV1Signature()
          Computes OAuth Signature as per OAuth specification using signature Method.
static Map getAuthHeader(String apiUserName, String apiPassword, String accessToken, String tokenSecret, OAuthSignature.HTTPMethod httpMethod, String scriptURI, Map queryParams)
          Accepts the required parameters and Provides OAuth signature and TimeStamp.
static String getFullAuthString(String apiUserName, String apiPassword, String accessToken, String tokenSecret, OAuthSignature.HTTPMethod httpMethod, String scriptURI, Map queryParams)
          Computes the value of the X_PP_AUTHORIZATION header
 void setHTTPMethod(OAuthSignature.HTTPMethod method)
          Sets HTTP Method
 void setRequestURI(String uri)
          Sets URI for signature computation.
 void setToken(String token)
          Sets Token to be used to generate signature.
 void setTokenSecret(String secret)
          Sets Token secret as received in Token response.
 void setTokenTimestamp(String timestamp)
          Sets time stamp for signature computation.
 boolean verifyV1Signature(String signature)
          verifyV1Signature verifies signature against computed signature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OAUTH_VERSION

public static final String OAUTH_VERSION
See Also:
Constant Field Values
Constructor Detail

OAuthSignature

public OAuthSignature(String consumerKey,
                      String consumerSecret)
Default Constructor

Parameters:
consumerKey - - Consumer key shared between PayPal and Consumer (OAuth consumer)
consumerSecret - - Secret shared between PayPal and Consumer (OAuth consumer)
Method Detail

setToken

public void setToken(String token)
Sets Token to be used to generate signature.

Parameters:
token - - String version of Token. The token could be Access or Request

addParameter

public void addParameter(String name,
                         String value)
Adds Parameter. Parameter could be part of URL, POST data.

Parameters:
name - parameter name with no URL encoding applied
value - parameter value with no URL encoding applied

setTokenSecret

public void setTokenSecret(String secret)
Sets Token secret as received in Token response.

Parameters:
secret - byte array of token secret

setRequestURI

public void setRequestURI(String uri)
                   throws OAuthException
Sets URI for signature computation.

Parameters:
uri - - Script URI which will be normalized to scheme://authority:port/path if not normalized already.
Throws:
OAuthException

setTokenTimestamp

public void setTokenTimestamp(String timestamp)
Sets time stamp for signature computation.

Parameters:
timestamp - - time stamp at which Token request sends.

setHTTPMethod

public void setHTTPMethod(OAuthSignature.HTTPMethod method)
Sets HTTP Method

Parameters:
method - HTTP method used for sending OAuth request

computeV1Signature

public String computeV1Signature()
                          throws OAuthException
Computes OAuth Signature as per OAuth specification using signature Method. using the specified encoding scheme enc.

Returns:
the Base64 encoded string.
Throws:
OAuthException - if invalid arguments.

verifyV1Signature

public boolean verifyV1Signature(String signature)
                          throws OAuthException
verifyV1Signature verifies signature against computed signature.

Returns:
true if signature verified otherwise false
Throws:
OAuthException - in case there are any failures in signature computation.

getAuthHeader

public static Map getAuthHeader(String apiUserName,
                                String apiPassword,
                                String accessToken,
                                String tokenSecret,
                                OAuthSignature.HTTPMethod httpMethod,
                                String scriptURI,
                                Map queryParams)
                         throws OAuthException
Accepts the required parameters and Provides OAuth signature and TimeStamp.

Parameters:
apiUserName - API User name.
apiPassword - API Password of user.
accessToken - Obtained during Permission Request of token.
tokenSecret - Obtained during Permission Request of token.
httpMethod - HTTP Method (GET,POST etc.)
scriptURI - API Server End Point.
queryParams - Extra 'name/value' parameters if required.
Returns:
Map of HTTPHeaders
Throws:
OAuthException

getFullAuthString

public static String getFullAuthString(String apiUserName,
                                       String apiPassword,
                                       String accessToken,
                                       String tokenSecret,
                                       OAuthSignature.HTTPMethod httpMethod,
                                       String scriptURI,
                                       Map queryParams)
                                throws OAuthException
Computes the value of the X_PP_AUTHORIZATION header

Parameters:
apiUserName - API User name.
apiPassword - API Password of user.
accessToken - Obtained during Permission Request of token.
tokenSecret - Obtained during Permission Request of token.
httpMethod - HTTP Method (GET,POST etc.)
scriptURI - API Server End Point.
queryParams - Extra 'name/value' parameters if required.
Returns:
Auth String
Throws:
OAuthException


Copyright © 2015. All Rights Reserved.