Oracle® Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 2 (10.1.2) Part No. B15505-01 |
|
![]() Previous |
![]() Next |
When you access EJBs in a remote container, you must pass valid credentials to this container. See "Setting JNDI Properties" for more information.
Pure Java clients define their credentials in the jndi.properties
file deployed with the EAR file.
Servlets or JavaBeans running within the container pass their credentials within the InitialContext
, which is created to look up the remote EJBs.
Note: For basic OC4J security configuration information, including CSiV2, see the Oracle Application Server Containers for J2EE Security Guide. |
Indicate the username (principal) and password (credentials) to use when looking up remote EJBs in the jndi.properties
file.
For example, if you want to access remote EJBs as POMGR/welcome
, define the following properties. The factory.initial
property indicates that you will use the Oracle JNDI implementation:
java.naming.security.principal=POMGR java.naming.security.credentials=welcome java.naming.factory.initial= com.evermind.server.ApplicationClientInitialContextFactory java.naming.provider.url=opmn:ormi://opmnhost:oc4j_inst1/ejbsamples
In your application program, authenticate and access the remote EJBs, as shown below:
InitialContext ic = new InitialContext(); CustomerHome = (CustomerHome)ic.lookup("java:comp/env/purchaseOrderBean");
To access remote EJBs from a servlet or JavaBean, pass the credentials in the InitialContext
object, as follows:
Hashtable env = new Hashtable(); env.put("java.naming.provider.url", "opmn:ormi://opmnhost:oc4j_inst1/ejbsamples"); env.put("java.naming.factory.initial", "com.evermind.server.ApplicationClientInitialContextFactory"); env.put(Context.SECURITY_PRINCIPAL, "POMGR"); env.put(Context.SECURITY_CREDENTIALS, "welcome"); Context ic = new InitialContext (env); CustomerHome = (CustomerHome) ic.lookup ("java:comp/env/purchaseOrderBean");