This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes How can I read my context.xml's JNDIRealm settings dynamically? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How can I read my context.xml Watch "How can I read my context.xml New topic
Author

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

Michael Brown
Greenhorn

Joined: May 05, 2008
Posts: 27
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

Joined: Sep 29, 2008
Posts: 12617

Moving; this isn't Struts-related.
Michael Brown
Greenhorn

Joined: May 05, 2008
Posts: 27
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

Joined: Jun 25, 2001
Posts: 15959
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I read my context.xml's JNDIRealm settings dynamically?
 
Similar Threads
How to get user credentials from LDAP using Apache Tomacet JNDIRealm
How to configure Tomcat for authentication against Active Directory of Windows Server 2003
JNDI realm strange problem(Tomcat 6.0.16)
user roles shared between application
How to setup Realm in WebSphere like tomcat?