Oracle8i Enterprise JavaBeans Developer's Guide and Reference
Release 3 (8.1.7)

Part Number A83725-01


Solution Area



Go to previous page Go to beginning of chapter Go to next page

Server-Side Authentication Example



This is the exact same example as under examples/ejb/basic/helloworld,
except that this example is using SSL server side auth. So, except for the 
SSL details, please refer to the readme file under 
examples/ejb/basic/helloworld for other details.

The purpose of the example is to show how to use ssl server side 
authentication. Since the client doesn't have certificate in this
case, it still passes username/password. 

Setup required

You need to open the encrypted wallet(ewallet.der) provided in this directory 
using the wallet manager tool provided by Oracle, and save it as clear
text wallet (cwallet.sso). The password is welcome12. 
Copy the generated cwallet.sso into TNS_ADMIN directory.

The encrypted wallet(ewallet.der) is only valid for Solaris platforms. For 
other platforms, you should generate the wallet using Oracle's owm tool.

The parameter SSL_CLIENT_AUTHENTICATION in $TNSADMIN/sqlnet.ora should be set 

Restart the database.


import hello.Hello;
import hello.HelloHome;

import oracle.aurora.jndi.sess_iiop.ServiceCtx;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;

public class Client
  public static void main (String[] args) throws Exception {
    if (args.length != 4) {
      System.out.println ("usage: Client serviceURL objectName user password");
      System.exit (1);
    String serviceURL = args [0];
    String objectName = args [1];
    String user = args [2];
    String password = args [3];

    Hashtable env = new Hashtable ();
    env.put (Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
    env.put (Context.SECURITY_PRINCIPAL, user);
    env.put (Context.SECURITY_CREDENTIALS, password);
    Context ic = new InitialContext (env);

    HelloHome hello_home = (HelloHome)ic.lookup (serviceURL + objectName);
    Hello hello = hello_home.create ();
    System.out.println (hello.helloWorld ());

Home Interface

package hello;

import javax.ejb.EJBHome;
import javax.ejb.CreateException;
import java.rmi.RemoteException;

public interface HelloHome extends EJBHome
  public Hello create () throws RemoteException, CreateException;

Remote Interface

package hello;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;

public interface Hello extends EJBObject  
  public String helloWorld () throws RemoteException;

Bean Implementation

package helloServer;

import javax.ejb.SessionBean;
import javax.ejb.CreateException;
import javax.ejb.SessionContext;
import java.rmi.RemoteException;

public class HelloBean implements SessionBean
  // Methods of the Hello interface
  public String helloWorld () throws RemoteException {
    String v = System.getProperty("oracle.server.version");
    return "Hello client, your javavm version is " + v + ".";

  // Methods of the SessionBean
  public void ejbCreate () throws RemoteException, CreateException {}
  public void ejbRemove() {}
  public void setSessionContext (SessionContext ctx) {}
  public void ejbActivate () {}
  public void ejbPassivate () {}

Go to previous page
Go to beginning of chapter
Go to next page
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.


Solution Area