Skip to main content

Problem with EJB Authentication

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
alexdeguays
Offline
Joined: 2012-06-11

Hi!

I'm using Glassfish to develope an application and I've a problem: I don't know how to propagate credentials from the EJB's caller (a desktop application) to the server. I wrote this:

Properties prop=new Properties();
prop.setProperty("org.omg.CORBA.ORBInitialHost","localhost");
prop.setProperty("org.omg.CORBA.ORBInitialPort","3700");
prop.setProperty("java.naming.security.principal","alexweb");
prop.setProperty("java.naming.security.credentials","abcde");
InitialContext ctx=new InitialContext(prop);
JndiEJBRemote bean=(JndiEJBRemote)ctx.lookup("java:global/JndiPrueba1JndiPrueba1-ejb/JndiEJB");

And then, I call a bean's method that returns an string with the caller's principal, like this:

ctx.getCallerPrincipal().getName();

But I obtain "ANONYMOUS". Can somebody tell me why? Thank you guys!