简体   繁体   中英

How to use web.xml to define security realm / jaas domain

I've been tasked to have my (Java-GWT) web app determine the environment it's in based on the hostname of the server the app is running in. This would be easy enough to do if this check existed in the code (via InetAddress.getLocalHost().getHostName() although not preferred I know), but the request is that I add this configuration to the web.xml via the method mentioned in the title.

I don't know much about defining security realms or jaas domains but what I need is simple. I simply need to read in the hostname of the server and if the string patter prod exists, set a flag or value that the app code can access and decide against. Hopefully this makes sense.

If this strategy seems like a flawed one altogether, I'm open to suggestions on the best way to have my app determine which environment it's running in.

If I understand well, you want you application to know what environment it is running on. This has nothing to do with security (or at least I don't see it)

I would set the environment descriptive name as a property external to the application, for example as a custom JNDI resource, system property o environment property. Preferable the first in order to let the application declare its dependency, via a <env-entry>

https://docs.oracle.com/cd/E19857-01/820-1639/6nda10e5g/index.html#bhanr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM