Chapter 4, “Developing PowerBuilder Clients”

The section “Enabling PowerBuilder clients to communicate with EJBs” describes how to generate proxy classes for the EJBs deployed in an application server, and how to code a PowerBuilder client application to communicate with a proxy server. You can also set up IIOPS listeners for secure connections between PowerBuilder clients and proxy servers, which is documented below.

StepsSetting up IIOPS listeners for the Client Edition proxy server

  1. On a machine where an EAServer 5.x client runtime is installed, set the JAGUAR_CLIENT_ROOT environment variable to the client runtime root directory.

  2. Verify that the database files, sybcert.db and sybkey.db, exist in JAGUAR_CLIENT_ROOT\db.

  3. Set the JAGSSL environment variable to true.

  4. Start the PowerBuilder IDE in the same environment where JAGUAR_CLIENT_ROOT and JAGSSL are set.

  5. Code your client application, using the “Sample PowerBuilder client,” below, as a guide.

StepsSetting up IIOPS listeners for the Server Edition proxy server

  1. Run:

    set-certificate admin@system -file sample.crt
    

    where sample.crt is a certificate file that contains an X509 certificate in Base64 encoding format.

    To create a sample certificate file, see “Sample certificate”.

  2. Code your PowerBuilder client application, using the sample below as a guide.

Sample PowerBuilder client

This sample PowerBuilder client sets up an IIOPS listener and uses the secure connection to invoke the pbtest/n_pbadd component, which is deployed in the application server.

SSLServiceProvider l_ssl
integer li_rc

this.getContextService("SSLServiceProvider", l_ssl)

// Set the SSL properties
li_rc = l_ssl.setglobalproperty( "qop", "sybpks_domestic_mutual_auth" )

if li_rc <> 0 then
   MessageBox("Error Setting SSL Parameters", "Error " + String(li_rc) +
   " when setting QOP")
   return
end if

li_rc = l_ssl.setglobalproperty( "pin", "sybase" )

if li_rc <> 0 then
   MessageBox("Error Setting SSL Parameters", "Error " + String(li_rc) +
   " when setting PIN")
   return
end if

li_rc = l_ssl.setglobalproperty( "certificateLabel", "Sample1 Test ID" )

if li_rc <> 0 then
   MessageBox("Error Setting SSL Parameters", "Error " + String(li_rc) +
   " when setting certificate label")
   return
end if

//Invoke component Powerscript

long ll_rc
connection ln_connect
n_pbadd ln_mycomp

ln_connect = CREATE connection

ln_connect.userid = "admin@system"
ln_connect.password = "sybase123"
ln_connect.driver = "jaguar"
ln_connect.options = "ORBLogIIOP='true', ORBLogFile='c:\orb.log'"
ln_connect.location = "iiops://my-pc:2002"
ln_connect.options = ln_connect.options + ",ORBForceSSL='true'"

ll_rc = ln_connect.ConnectToServer()

if ll_rc = 0 then
   ll_rc = ln_connect.CreateInstance(ln_myComp, "pbtest/n_pbadd")

if ll_rc = 0 then
   MessageBox("Add Returned", ln_myComp.add(3,5) )
else
   MessageBox("Create Instance Failed", "Error: " + string(ll_rc) + + " " +
   ln_connect.errText, StopSign!)
end if
else
   MessageBox("Connect to Server Failed", "Error: " + string(ll_rc) + + " "
   + ln_connect.errText, StopSign!)
end if

ln_connect.disconnectServer()

Sample certificate

To create a sample certificate, you can run the following Ant script, which calls the genkey task to generate a public/private key pair, then calls keytool.exe to export the public key to an X509 certificate in printable encoding format (Base64).

This example assumes familiarity with the keytool and certificate architecture used by Sun Microsystems. For more information, see the keytool documentation.

<!-- Generate a keypair -->

<target name="gen-key-pair">
 <genkey alias="duke" keypass="keypass" 
   keystore="keystore.jks" storepass="storepass"
   verbose="true">
   <dname>
      <param name="CN" value="Duke User Name"/>
      <param name="OU" value="Engineering"/>
      <param name="O"  value="Sun Microsystems"/>
      <param name="L"  value="Cupertino"/>
      <param name="ST"  value="CA"/>
      <param name="C"  value="US"/>
   </dname>
 </genkey>
</target>

<!-- Export the public key for duke -->

<target name="export-pub-key">
 <exec executable="keytool.exe">
   <arg value="-export"/>
   <arg value="-rfc"/>
   <arg value="-keystore"/>
   <arg path="keystore.jks"/>
   <arg value="-storepass"/>
   <arg value="storepass"/>
   <arg value="-keypass"/>
   <arg value="keypass"/>
   <arg value="-alias"/>
   <arg value="sample"/>
   <arg value="-file"/>
   <arg path="sample.crt"/>
 </exec>
</target>