diff --git a/rhino-tools/src/main/java/org/mozilla/javascript/tools/shell/Main.java b/rhino-tools/src/main/java/org/mozilla/javascript/tools/shell/Main.java
index 1393d17ef6..70a9aab04a 100644
--- a/rhino-tools/src/main/java/org/mozilla/javascript/tools/shell/Main.java
+++ b/rhino-tools/src/main/java/org/mozilla/javascript/tools/shell/Main.java
@@ -32,6 +32,7 @@
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.Kit;
import org.mozilla.javascript.NativeArray;
+import org.mozilla.javascript.RhinoConfig;
import org.mozilla.javascript.RhinoException;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
@@ -132,7 +133,7 @@ public void quit(Context cx, int exitCode) {
*/
public static void main(String args[]) {
try {
- if (Boolean.getBoolean("rhino.use_java_policy_security")) {
+ if (RhinoConfig.getBoolean("rhino.use_java_policy_security")) {
initJavaPolicySecuritySupport();
}
} catch (SecurityException ex) {
diff --git a/rhino/src/main/java/org/mozilla/javascript/RhinoConfig.java b/rhino/src/main/java/org/mozilla/javascript/RhinoConfig.java
new file mode 100644
index 0000000000..8d170325b7
--- /dev/null
+++ b/rhino/src/main/java/org/mozilla/javascript/RhinoConfig.java
@@ -0,0 +1,167 @@
+package org.mozilla.javascript;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/**
+ * Utility class to read current rhino configuration.
+ *
+ *
Rhino properties typically begins with "rhino." (properties) or "RHINO_" (env)
+ *
+ *
The configuration is read from these locations:
+ *
+ *
+ * - rhino.config file from current class' classpath
+ *
- rhino.config file from current threas's classpath
+ *
- rhino.config file from current directory
+ *
- System-properties starting with "rhino."
+ *
- env variables starting with "RHINO_" (underscores are replaced by '.' and string is
+ *
+ *
+ * The config files are in UTF-8 format and all keys in this configuration are case-insensitive and
+ * dot/underscore-insensitive.
+ *
+ * This means, "rhino.use_java_policy_security" is equvalent to "RHINO_USE_JAVA_POLICY_SECURITY"
+ *
+ * @author Roland Praml, Foconis Analytics GmbH
+ */
+public class RhinoConfig {
+ private static final Map PROPERTIES =
+ AccessController.doPrivileged((PrivilegedAction