Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Security Principal Problem, local and remote

 
Aps Raps
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application running on the local server, accessing EJBs on a remote server. The local principal needed to access the web application is not the same as the remote user credentials.
1. Before invoking an ejb method from a delegate, I create the InitalContext with the required remote credentials and invoke the EJB.
2. After invocation I close the remote context explicitely so as to access my web application.

If I dont close the remote context, my web app stops working. If I close the remote context, I have to do a get InitialContext before each EJB method invocation and this can be expensive.

Can local and remote context co-exist? Is there some way by which I can avoid getting the initial context each time in the delegate? Would appreciate any help here.
 
Rovas Kram
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can just change the environment before and after you call the remote server - without closing the context.


Hashtable env = Context.getEnvironment();
env.put("java.naming.security.principal", "YourPrincipal");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic