Ang*_*ons 18 java security web-applications esapi
我正在尝试使用ESAPI.jar为我的Web应用程序提供安全性.基本上我刚开始使用ESAPI.jar.但问题是我无法使用ESAPI运行一个简单的程序.小代码片段是:
String clean = ESAPI.encoder().canonicalize("someString");
Randomizer r=ESAPI.randomizer();
System.out.println(r);
System.out.println(clean);
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Attempting to load ESAPI.properties via file I/O.
Attempting to load ESAPI.properties as resource file via file I/O.
Not found in 'org.owasp.esapi.resources' directory or file not readable: D:\Eclipse-Workspace\Test\ESAPI.properties
Not found in SystemResource Directory/resourceDirectory: .esapi\ESAPI.properties
Not found in 'user.home' (C:\Documents and Settings\user.user) directory: C:\Documents and Settings\user.user\esapi\ESAPI.properties
Loading ESAPI.properties via file I/O failed. Exception was: java.io.FileNotFoundException
Attempting to load ESAPI.properties via the classpath.
ESAPI.properties could not be loaded by any means. Fail. Exception was: java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource.
Exception in thread "main" org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException SecurityConfiguration class (org.owasp.esapi.reference.DefaultSecurityConfiguration) CTOR threw exception.
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:129)
at org.owasp.esapi.ESAPI.securityConfiguration(ESAPI.java:184)
at org.owasp.esapi.ESAPI.encoder(ESAPI.java:99)
at org.rancore.testJasp.TestEsapi.main(TestEsapi.java:59)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:86)
... 3 more
Caused by: org.owasp.esapi.errors.ConfigurationException: ESAPI.properties could not be loaded by any means. Fail.
at org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfiguration(DefaultSecurityConfiguration.java:439)
at org.owasp.esapi.reference.DefaultSecurityConfiguration.<init>(DefaultSecurityConfiguration.java:227)
at org.owasp.esapi.reference.DefaultSecurityConfiguration.getInstance(DefaultSecurityConfiguration.java:75)
... 8 more
Caused by: java.lang.IllegalArgumentException: Failed to load ESAPI.properties as a classloader resource.
at org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfigurationFromClasspath(DefaultSecurityConfiguration.java:667)
at org.owasp.esapi.reference.DefaultSecurityConfiguration.loadConfiguration(DefaultSecurityConfiguration.java:436)
... 10 more
Run Code Online (Sandbox Code Playgroud)
我曾尝试在我的源文件夹中复制3个ESAPI属性文件,并在构建路径上配置它们但仍然没有成功.我尝试了许多排列和组合无济于事.
请指导我.
属性文件的内容是:
# User Messages
Error.creating.randomizer=Error creating randomizer
This.is.test.message=This {0} is {1} a test {2} message
# Validation Messages
# Log Messages
Run Code Online (Sandbox Code Playgroud)
Jas*_*ean 22
ESAPI.properties文件中应包含3行以上的行.
http://code.google.com/p/owasp-esapi-java/source/browse/trunk/configuration/esapi/ESAPI.properties
根据我的经验,ESAPI.properties文件需要与esapi.jar位于同一文件夹中,或者需要编译到资源目录中的jar中.
/resources/ESAPI.properties
Run Code Online (Sandbox Code Playgroud)
我相信任何一个都应该奏效.如果ESAPI找不到该文件,则在其他位置查找该文件.
代码就在第612行:http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/reference/DefaultSecurityConfiguration. java的
我自己刚刚经历过这个。
当我从 esapi lib 目录添加较新的 jar 时,一切正常!
我在控制台最后收到了这条消息:
ESAPI.accessController found: org.owasp.esapi.reference.DefaultAccessController@1cb8deef
Run Code Online (Sandbox Code Playgroud)
注意:有一个 ESAPI_en_US.properties 文件,但它只有几行。只需使用以下文件:\esapi-2.1.0-dist\src\test\resources\esapi\ESAPI.properties。这是完整的完整文件。