users@glassfish.java.net

Pass Principal to EJB from external app

From: <glassfish_at_javadesktop.org>
Date: Thu, 04 Jun 2009 04:54:52 PDT

Hello,

I have spent half a day with glassfish v2 trying to find what seems to be trivial information: how do I pass a caller's principal, so that it could be retrieved from EJBContext inside container (by ctx.getCallerPrincipal()).

I know that at least servlet container delegates it behind the scenes. But I need to do this manually from external java app, for ex., from junit tests. Without passing a principal, I am calling EJB without a problem by looking up the initial context with these params:
env.setProperty("java.naming.factory.initial", com.sun.enterprise.naming.SerialInitContextFactory");
env.setProperty("org.omg.CORBA.ORBInitialHost", "hostname");
env.setProperty("org.omg.CORBA.ORBInitialPort", "port");
env.setProperty(Context.PROVIDER_URL, "url");

I assumed that adding these line will solve the problem:
env.setProperty(Context.SECURITY_PRINCIPAL, "uname");
env.setProperty(Context.SECURITY_CREDENTIALS, "passw");

Hawever, with these settings the caller's pincipal name inside container is ANONYMOUS.

Can anyone help me out with this?
Thank you!
[Message sent by forum member 'saadakka' (saadakka)]

http://forums.java.net/jive/thread.jspa?messageID=349104