Using Java Sample Code for Basic Authentication

The sample code was developed and tested on a Solaris platform.
  1. Replace your Java installation’s existing security policy files with the new ones you downloaded from Oracle’s site:

    ADDITIONAL INFORMATION

    1. Find your existing
      US_export_policy.jar
      and
      local_policy.jar
      files in the
      $JAVA_HOME/jre/lib/security
      directory.
    2. Rename or move your existing files to another directory.
    3. Copy the new
      US_export_policy.jar
      and
      local_policy.jar
      files that you downloaded from Oracle to the
      $JAVA_HOME/jre/lib/security
      directory.
  2. Edit the
    $JAVA_HOME/jre/lib/security/java.security
    file 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
  3. Import your
    Cybersource
    Simple Order API .p12 security key into Internet Explorer.

    ADDITIONAL INFORMATION

    1. Open an Internet Explorer Web browser, go to
      Tools > Internet Options...
      , and click the
      Content
      tab.
    2. Click
      Certificates...
      .
    3. Click
      Import...
      to open the Certificate Import Wizard, and click
      Next
      to start the Wizard.
    4. Browse to the location of your .p12 security key and click
      Next
      .
      For the password for the private key, enter your
      Cybersource
      merchant ID. For example, if your key is infodev.p12, enter
      infodev
      as the password.
    5. On this page, check the
      Mark this key as exportable
      box and then click
      Next
      .
    6. Click
      Next
      on the Certificate Store page.
    7. Click
      Finish
      and a confirmation that the import was successful appears.
  4. Create a key store file to contain your
    Cybersource
    Simple Order API .p12 security key:

    ADDITIONAL INFORMATION

    1. In a Web browser, go to one of these URLs:
      • If you are in test mode and have not gone live with
        Cybersource
        :

        https://batchtest.cybersource.com/upload/UploadBatchFile
      • If you have gone live with
        Cybersource
        :

        https://batch.cybersource.com/upload/UploadBatchFile
      • For live transactions in India, https://batch.in.cybersource.com/upload/UploadBatchFile
    2. Go to
      File > Properties
      .
    3. Click
      Certificates
      .
    4. Click the
      Certification Path
      tab.
    5. Select
      DigiCert.com TLS/SSL Certification Authority
      .
    6. Click
      View Certificate
      .
    7. Click the
      Detail
      s tab.
    8. Click
      Copy to File
      and then
      Next
      .
    9. Click
      Browse
      and navigate to where you want to save the file.
    10. Enter the name that you want to use for the file, such as MyCert. Click
      Save
      and click
      Next
      .
    11. Click
      Finish
      .
      Your file, for example
      MyCert.cer
      , has been created in the location you specified.
    12. Go to
      $JAVA_HOME/bin/keytool
      and 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 myMerchantID
      If successful, the output will be similar to this example
      [XXX 
      from 2020 guide
       XXX]
      :
      Owner: CN=batchtest.cybersource.com, OU=Operations, O=
      Cybersource
      Corporation, 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 keystore
      If successful, the output will be similar to this example
      [XXX 
      needs approval
       XXX]
      :
      Owner: CN=batchtest.cybersource.com, OU=Operations, O=
      Cybersource
      Corporation, 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
  5. Modify the
    SSLFileTransfer.props
    file with your settings. The file is part of the
    Cybersource
    download package and looks similar to this example:

    ADDITIONAL INFORMATION

    # Upload host host=batchtest.cybersource.com # Upload port port=<Upload port> # Username to log into the
    Business Center
    bcUserName=<
    Business Center
    login name> # Password to log into the
    Business Center
    bcPassword=<
    Business Center
    login password> # File to upload uploadFile=<path to your file>/<file name> # Path where to upload it to (provided by
    Cybersource
    ) path=/upload/UploadBatchFile # Your
    Cybersource
    security 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>
  6. Set the
    JAVA_HOME
    environment variable to the location in which you installed J2SE. For example:

    ADDITIONAL INFORMATION

    JAVA_HOME=/home/j2se
  7. Include
    $JAVA_HOME/bin
    in the PATH.
  8. Compile and run the sample:

    ADDITIONAL INFORMATION

    1. Change to the directory location in which you stored the
      Cybersource
      sample files.
    2. Type this:
      javac SSLFileTransfer.java java SSLFileTransfer <path to props file>/SSLFileTransfer.props
      If 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