File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I read my context.xml's JNDIRealm settings dynamically?

 
Michael Brown
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JNDIRealm in my context.xml that connects to Active Directory in order to authorise users in application...

It all works fine.

I'm just wondering if there is a way to read this JNDIRealm settings ( connectionName , connectionPassword and connectionURL ) dynamically from some Java class inside my application...?

For example using something like Context.lookup("MyRealm") and getting it's properties...

I use Tomcat 6.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving; this isn't Struts-related.
 
Michael Brown
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, now that I think about it - you're right...

My application is written using struts2, but this is not Struts2 related question...

My appologies...
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17624
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The actual security infrastructure items won't be visible inside the webapp. Not only would that be a potential security risk (the app user and the app itself could even have different security connections!), but also it wouldn't be possible in a transparent way. One of the great things about security realms is that you can use a tomcat-users.xml file for testing even though the production system is LDAP-authenticated.

However, you CAN set up a system where the info you want is inferred based on the user principal name, using that as an argument to an LDAP search.

The example you cited, however, seems to have more to do with database connections. And like security realms, in J(2)EE, database connections are generally best left completely in the hands of the container. You wouldn't (I hope!) get a different connection for each user! For one thing, it places the DBA in the position of having to duplicate the security team's work for each web application user.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic