我在Tomcat war应用程序中使用了ESAPI加密。我希望从war外部的目录加载ESAPI.properties文件,以便为每个环境提供不同的密钥和salt。我还希望每个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强制执行一个配置。这意味着属性文件位置在所有已部署的wars上都是强制的。(第一个选项使用ClassLoader.getSystemResource -requires该路径作为类路径的一部分)
有没有办法使用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;
}有什么建议吗?
发布于 2014-05-01 03:33:26
如果您想要为特定实例配置tomcat,首先想到的就是使用tomcat的setenv.sh脚本进行设置。就像这样
export JAVA_OPTS='$JAVA_OPTS -Dorg.owasp.esapi.resources="/path/resources"'https://stackoverflow.com/questions/14608638
复制相似问题