Search code examples
javapropertiesesapi

Setting resource directory for ESAPI


Working with OWASP's ESAPI, I found myself stuck at this particular line of code.

private static String customDirectory = System.getProperty("org.owasp.esapi.resources");

The code returns null as there is no such system property "org.owasp.esapi.resources" set on my computer. Is there any way to set this property on my computer permanently?


Solution

  • You need to pass it into your JVM as a command line property. Most application containers use the environment variable JAVA_OPTS as a "permanent" store of options that should be passed to the JVM. You can try to do something like this:

    In *nix:

    export JAVA_OPTS="-Dorg.owasp.esapi.resources=/path/to/esapi/configuration"
    

    In windows:

    set JAVA_OPTS="-Dorg.owasp.esapi.resources=C:\path\to\esapi\configuration"
    

    You can add this to windows or linux as a startup command and it will always be set if you desire, or add it to your application's startup script for a more localized solution.