tomcat - Tomcat 中的 ESAPI 属性文件

标签 tomcat esapi

我在 Tomcat war 应用程序中使用 ESAPI 加密。我想从 war 之外的目录加载 ESAPI.properties 文件,以便每个环境都有不同的 key 和盐。 我也希望每场 war 都有不同的 ESAPI.properties 文件,这样每个应用程序都可以进行个性化配置。 根据 org.owasp.esapi.reference.DefaultSecurityConfiguration 的文档,实现该目标的方法很少。

1) SecurityConfiguration.setResourceDirectory( "C:\temp\resources").

2) System.getProperty( "org.owasp.esapi.resources")

3) System.getProperty( "user.home") + "/.esapi"目录内

4) 类路径上的第一个“.esapi”或“esapi”目录。

前 3 个选项将为每个 tomcat 强制执行一个配置。这意味着属性文件位置在所有部署的 war 中强制执行。 (第一个选项使用 ClassLoader.getSystemResource - 要求路径是类路径的一部分)

有没有办法使用 Tomcat 配置来完成它?

我还找到了一种覆盖 ESAPI 默认安全配置的方法,我可以在其中扩展 DefaultSecurityConfiguration 并覆盖 getResourceFile,但是 ESAPI javadoc 说应该“永远”使用此方法 - 我不确定这是什么原因.

 package org.owasp.esapi;
 public final class ESAPI{   
 /**
 * Overrides the current security configuration with a new implementation. This is meant
 * to be used as a temporary means to alter the behavior of the ESAPI and should *NEVER*
 * be used in a production environment as it will affect the behavior and configuration of
 * the ESAPI *GLOBALLY*.
 *
 * To clear an overridden Configuration, simple call this method with null for the config
 * parameter.
 *
 * @param config
 * @return
 */
public static void override( SecurityConfiguration config ) {
    overrideConfig = config;
}

有什么建议吗?

最佳答案

如果您想要针对特定​​实例的 tomcat 配置,首先想到的是使用 tomcat 的 setenv.sh 脚本进行设置。有点像

export JAVA_OPTS='$JAVA_OPTS -Dorg.owasp.esapi.resources="/path/resources"'

关于tomcat - Tomcat 中的 ESAPI 属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14608638/

相关文章:

java - Tomcat 返回的当前目录路径与 JUnit 测试返回的路径不同

java.net.SocketTimeoutException : Read timed out under Tomcat

java - 为什么 ESAPI 编码器不能与 Java 1.8 一起使用

java - 使用 ESAPI 进行编码/解码

java - 允许某些字符不受 ESAPI 编码器的影响吗?

java - 在 apache tomcat 中部署应用程序时出错

用于 RedHat 的 JAVA_OPTS

java - 尝试访问 dao bean 时 Autowiring 依赖项的注入(inject)失败

java - SafeString 的正则表达式

java - 使用 ESAPI 编码器编码 JSON