• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Security Principal Problem, local and remote

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic