com.mikeblanton.paypal.util
Class CryptoUtil
java.lang.Object
|
+--com.mikeblanton.paypal.util.CryptoUtil
- public class CryptoUtil
- extends java.lang.Object
The CryptoUtil class provides helper methods for encrypting PayPal payment requests for use
with PayPal Encrypted Website Payments. The following items can be configured:
- Via System Properties:
paypaltools.config.file
: Full path to the configuration file to use while
retrieving configuration items.
paypaltools.paypal.cert
: Full path to the PayPal Public Cert to use for encryption.
paypaltools.merchant.key
: Full path to the Merchant Private Key to use for signing.
paypaltools.merchant.key.password
: Cleartext password used to read the Merchant Private Key.
paypaltools.merchant.cert
: Full path to the Merchant Certificate to use for signing.
paypaltools.certificate.factory.type
: Certificate Factory Type to use while reading the
Merchant Certificate and the PayPal Certificate. Default is X509
.
paypaltools.keystore.type
: Keystore Type to use while loading the Merchant
Private Key. Default is PKCS12
.
- Via Configuration File:
paypal.cert
: Full path to the PayPal Public Cert to use for encryption.
merchant.key
: Full path to the Merchant Private Key to use for signing.
merchant.key.password
: Cleartext password used to read the Merchant Private Key.
merchant.cert
: Full path to the Merchant Certificate to use for signing.
certificate.factory.type
: Certificate Factory Type to use while reading the
Merchant Certificate and the PayPal Certificate. Default is X509
.
keystore.type
: Keystore Type to use while loading the Merchant
Private Key. Default is PKCS12
.
- Version:
- $Revision: 1.7 $
- Author:
- Michael Blanton (mike@mikeblanton.com)
Method Summary |
static java.lang.String |
getButtonEncryptionValue(java.lang.String _data)
Sign and Envelope the passed data string, returning a PKCS7 blob that can be posted to
PayPal. |
static java.lang.String |
getButtonEncryptionValue(java.lang.String _data,
java.lang.String _privateKeyPath,
java.lang.String _certPath,
java.lang.String _payPalCertPath,
java.lang.String _keyPass)
Sign and Envelope the passed data string, returning a PKCS7 blob that can be posted to
PayPal. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PARAM_CONFIG_FILE
public static final java.lang.String PARAM_CONFIG_FILE
PARAM_PAYPAL_CERT
public static final java.lang.String PARAM_PAYPAL_CERT
PARAM_MERCHANT_KEY
public static final java.lang.String PARAM_MERCHANT_KEY
PARAM_MERCHANT_KEY_PASSWORD
public static final java.lang.String PARAM_MERCHANT_KEY_PASSWORD
PARAM_MERCHANT_CERT
public static final java.lang.String PARAM_MERCHANT_CERT
PARAM_CERTIFICATE_FACTORY_TYPE
public static final java.lang.String PARAM_CERTIFICATE_FACTORY_TYPE
PARAM_KEYSTORE_TYPE
public static final java.lang.String PARAM_KEYSTORE_TYPE
CONFIG_PAYPAL_CERT
public static final java.lang.String CONFIG_PAYPAL_CERT
CONFIG_MERCHANT_KEY
public static final java.lang.String CONFIG_MERCHANT_KEY
CONFIG_MERCHANT_KEY_PASSWORD
public static final java.lang.String CONFIG_MERCHANT_KEY_PASSWORD
CONFIG_MERCHANT_CERT
public static final java.lang.String CONFIG_MERCHANT_CERT
CONFIG_CERTIFICATE_FACTORY_TYPE
public static final java.lang.String CONFIG_CERTIFICATE_FACTORY_TYPE
CONFIG_KEYSTORE_TYPE
public static final java.lang.String CONFIG_KEYSTORE_TYPE
CryptoUtil
public CryptoUtil()
getButtonEncryptionValue
public static java.lang.String getButtonEncryptionValue(java.lang.String _data,
java.lang.String _privateKeyPath,
java.lang.String _certPath,
java.lang.String _payPalCertPath,
java.lang.String _keyPass)
throws java.io.IOException,
java.security.cert.CertificateException,
java.security.KeyStoreException,
java.security.UnrecoverableKeyException,
java.security.InvalidAlgorithmParameterException,
java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
org.bouncycastle.jce.cert.CertStoreException,
org.bouncycastle.cms.CMSException
- Sign and Envelope the passed data string, returning a PKCS7 blob that can be posted to
PayPal. The data is signed and encrypted using the passed in Keys and Certs.
Make sure the passed data string is seperated by UNIX linefeeds (ASCII 10, '\n').
- Parameters:
_data
- Cleartext data to encrypt._privateKeyPath
- Full path to the Private Key to use for signing the data (merchant_key.p12
)._certPath
- Full path to the Certificate to use for signing the data. (merchant_cert.cer
)._payPalCertPath
- Full path to the PayPal Public Certificate to use for encrypting
the data (paypal.cer
)._keyPass
- Cleartext password to use to read the Private Key (merchant_key.p12
).- Returns:
-
- Throws:
java.io.IOException
- java.security.cert.CertificateException
- java.security.KeyStoreException
- java.security.UnrecoverableKeyException
- java.security.InvalidAlgorithmParameterException
- java.security.NoSuchAlgorithmException
- java.security.NoSuchProviderException
- org.bouncycastle.jce.cert.CertStoreException
- org.bouncycastle.cms.CMSException
-
getButtonEncryptionValue
public static java.lang.String getButtonEncryptionValue(java.lang.String _data)
throws java.io.IOException,
java.security.cert.CertificateException,
java.security.KeyStoreException,
java.security.UnrecoverableKeyException,
java.security.InvalidAlgorithmParameterException,
java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
org.bouncycastle.jce.cert.CertStoreException,
org.bouncycastle.cms.CMSException
- Sign and Envelope the passed data string, returning a PKCS7 blob that can be posted to
PayPal. The data is signed and encrypted using the configured keys and certs.
Make sure the passed data string is seperated by UNIX linefeeds (ASCII 10, '\n').
- Parameters:
_data
- Cleartext data to encrypt and sign.- Returns:
-
- Throws:
java.io.IOException
- java.security.cert.CertificateException
- java.security.KeyStoreException
- java.security.UnrecoverableKeyException
- java.security.InvalidAlgorithmParameterException
- java.security.NoSuchAlgorithmException
- java.security.NoSuchProviderException
- org.bouncycastle.jce.cert.CertStoreException
- org.bouncycastle.cms.CMSException
-