On This Page
Using Java Sample Code for Basic Authentication
The sample code was developed and tested on a Solaris platform.
- Replace your Java installation’s existing security policy files with the new ones you downloaded from Oracle’s site:
ADDITIONAL INFORMATION
- Find your existingUS_export_policy.jarandlocal_policy.jarfiles in the$JAVA_HOME/jre/lib/securitydirectory.
- Rename or move your existing files to another directory.
- Copy the newUS_export_policy.jarandlocal_policy.jarfiles that you downloaded from Oracle to the$JAVA_HOME/jre/lib/securitydirectory.
- Edit the$JAVA_HOME/jre/lib/security/java.securityfile and insert the security provider right after the Oracle provider. Make sure to increment the numbers of the other providers in the list. Your list of security providers will now look similar to this:
ADDITIONAL INFORMATION
security.provider.1=sun.security.provider.Sun security.provider.3=com.sun.net.ssl.internal.ssl.Provider security.provider.4=com.sun.rsajca.Provider security.provider.5=com.sun.crypto.provider.SunJCE security.provider.6=sun.security.jgss.SunProvider - Import yourCybersourceSimple Order API .p12 security key into Internet Explorer.
ADDITIONAL INFORMATION
- Open an Internet Explorer Web browser, go toTools > Internet Options..., and click theContenttab.
- ClickCertificates....
- ClickImport...to open the Certificate Import Wizard, and clickNextto start the Wizard.
- Browse to the location of your .p12 security key and clickNext.For the password for the private key, enter yourCybersourcemerchant ID. For example, if your key is infodev.p12, enterinfodevas the password.
- On this page, check theMark this key as exportablebox and then clickNext.
- ClickNexton the Certificate Store page.
- ClickFinishand a confirmation that the import was successful appears.
- Create a key store file to contain yourCybersourceSimple Order API .p12 security key:
ADDITIONAL INFORMATION
- In a Web browser, go to one of these URLs:
- If you are in test mode and have not gone live withCybersource:https://batchtest.cybersource.com/upload/UploadBatchFile
- If you have gone live withCybersource:https://batch.cybersource.com/upload/UploadBatchFile
- For live transactions in India, https://batch.in.cybersource.com/upload/UploadBatchFile
- Go toFile > Properties.
- ClickCertificates.
- Click theCertification Pathtab.
- SelectDigiCert.com TLS/SSL Certification Authority.
- ClickView Certificate.
- Click theDetails tab.
- ClickCopy to Fileand thenNext.
- ClickBrowseand navigate to where you want to save the file.
- Enter the name that you want to use for the file, such as MyCert. ClickSaveand clickNext.
- ClickFinish.Your file, for exampleMyCert.cer, has been created in the location you specified.
- Go to$JAVA_HOME/bin/keytooland use the J2SE keytool program to create a keystore file that contains this newly created certificate. You must provide a pass phrase for the keystore. You MUST use the same password that you used in Step 3d above. For example, if your p12 key is infodev.p12, the pass phrase must be infodev.To create the keystore, enter this command:$JAVA_HOME/bin/keytool -import -file <path to certificate>/ <name of certificate file> -keystore <name of keystore file>.jks -storepass <pass phrase of keystore>For example:$JAVA_HOME/bin/keytool -import -file /home/bluu/MyCert.cer - keystore MyKeystore.jks -storepass myMerchantIDIf successful, the output will be similar to this example[XXXfrom 2020 guideXXX]:Owner: CN=batchtest.cybersource.com, OU=Operations, O=CybersourceCorporation, L=Mountain View, ST=California, C=US Issuer: CN=Entrust.net Secure Server Certification Authority, OU=(c) 1999 Entrust.net Limited, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), O=Entrust.net, C=US Serial number: 374e1b7b Valid from: Thu Nov 18 17:15:34 PST 2004 until: Tue Jan 31 17:51:24 PST 2006 Certificate fingerprints: MD5: BE:BF:B0:91:69:C4:7B:10:45:EC:D6:0F:16:AA:3D:77 SHA1: 07:F8:41:DC:B2:FC:F5:DA:FC:EE:09:7A:33:B8:29:15:31:18 Trust this certificate? [no]: yes Certificate was added to keystoreIf successful, the output will be similar to this example[XXXneeds approvalXXX]:Owner: CN=batchtest.cybersource.com, OU=Operations, O=CybersourceCorporation, L=Foster City, ST=California, C=US Issuer: CN=DigiCert.com TLS/SSL Certificate Authority, OU=(c) 2022 DigiCert.com Inc, OU=www.digicert.net/legal-repository/security, O=DigiCert.com, C=US Serial number: 374e1b7b Valid from: Monday Nov 18 17:15:34 PST 2024 until: Sat Jan 31 17:51:24 PST 2026 Certificate fingerprints: MD5: BE:BF:B0:91:69:C4:7B:10:45:EC:D6:0F:16:AA:3D:77 SHA1: 07:F8:41:DC:B2:FC:F5:DA:FC:EE:09:7A:33:B8:29:15:31:18 Trust this certificate? [no]: yes Certificate was added to keystore
- Modify theSSLFileTransfer.propsfile with your settings. The file is part of theCybersourcedownload package and looks similar to this example:
ADDITIONAL INFORMATION
# Upload host host=batchtest.cybersource.com # Upload port port=<Upload port> # Username to log into theBusiness CenterbcUserName=<Business Centerlogin name> # Password to log into theBusiness CenterbcPassword=<Business Centerlogin password> # File to upload uploadFile=<path to your file>/<file name> # Path where to upload it to (provided byCybersource) path=/upload/UploadBatchFile # YourCybersourcesecurity key key=<key location path>/<key file name> # New key store you just created that contains the certificate keyStore=<key store location>/<new key store name> # Pass phrase is the string you used in -storepass option when you # created the key store file earlier passPhrase=<pass phrase> - Set theJAVA_HOMEenvironment variable to the location in which you installed J2SE. For example:
ADDITIONAL INFORMATION
JAVA_HOME=/home/j2se - Include$JAVA_HOME/binin the PATH.
- Compile and run the sample:
ADDITIONAL INFORMATION
- Change to the directory location in which you stored theCybersourcesample files.
- Type this:javac SSLFileTransfer.java java SSLFileTransfer <path to props file>/SSLFileTransfer.propsIf the upload is successful, the output should look similar to this:HTTP/1.1 200 OK Date: Wed, 26 Jan 2020 17:26:31 GMT Server: Apache Coyote/1.0 Content-Type: text/plain Content-Length: 0 X-Cache: MISS from <your host> Connection: close UPLOAD FILE SUCCESSFUL