简体   繁体   English

如何使用web.xml定义安全领域/ Jaas域

[英]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. 我的任务是让我的(Java-GWT)Web应用程序根据运行该应用程序的服务器的主机名确定其所在的环境。如果此检查存在于代码中(通过InetAddress),这将很容易做到。 .getLocalHost()。getHostName()虽然不是首选,但我的要求是我通过标题中提到的方法将此配置添加到web.xml中。

I don't know much about defining security realms or jaas domains but what I need is simple. 我对定义安全领域或jaas域了解不多,但我需要的很简单。 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. 我只需要读入服务器的主机名,如果字符串patter prod存在,就设置一个标志或值,应用程序代码可以访问该标志或值,并据此做出决定。 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. 我将环境描述名称设置为应用程序外部的属性,例如,作为自定义JNDI资源,系统属性或环境属性。 Preferable the first in order to let the application declare its dependency, via a <env-entry> 为了让应用程序通过<env-entry>声明其依赖性,最好是第一个

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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