1812058
# HG changeset patch
1812058
# User andrew
1812058
# Date 1545198926 0
1812058
#      Wed Dec 19 05:55:26 2018 +0000
1812058
# Node ID f2cbd688824c128db7fa848c8732fb0ab3507776
1812058
# Parent  81f07f6d1f8b7b51b136d3974c61bc8bb513770c
1812058
PR3695: Allow use of system crypto policy to be disabled by the user
1812058
Summary: Read user overrides first so security.useSystemPropertiesFile can be disabled and add -Djava.security.disableSystemPropertiesFile
1812058
1812058
diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java
1812058
--- a/src/java.base/share/classes/java/security/Security.java
1812058
+++ b/src/java.base/share/classes/java/security/Security.java
1812058
@@ -125,31 +125,6 @@
1812058
         }
1812058
 
1812058
         if ("true".equalsIgnoreCase(props.getProperty
1812058
-                ("security.useSystemPropertiesFile"))) {
1812058
-
1812058
-            // now load the system file, if it exists, so its values
1812058
-            // will win if they conflict with the earlier values
1812058
-            try (BufferedInputStream bis =
1812058
-                 new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
1812058
-                props.load(bis);
1812058
-                loadedProps = true;
1812058
-
1812058
-                if (sdebug != null) {
1812058
-                    sdebug.println("reading system security properties file " +
1812058
-                                   SYSTEM_PROPERTIES);
1812058
-                    sdebug.println(props.toString());
1812058
-                }
1812058
-            } catch (IOException e) {
1812058
-                if (sdebug != null) {
1812058
-                    sdebug.println
1812058
-                        ("unable to load security properties from " +
1812058
-                         SYSTEM_PROPERTIES);
1812058
-                    e.printStackTrace();
1812058
-                }
1812058
-            }
1812058
-        }
1812058
-
1812058
-        if ("true".equalsIgnoreCase(props.getProperty
1812058
                 ("security.overridePropertiesFile"))) {
1812058
 
1812058
             String extraPropFile = System.getProperty
1812058
@@ -215,6 +190,33 @@
1812058
             }
1812058
         }
1812058
 
1812058
+        String disableSystemProps = System.getProperty("java.security.disableSystemPropertiesFile");
1812058
+        if (disableSystemProps == null &&
1812058
+            "true".equalsIgnoreCase(props.getProperty
1812058
+                ("security.useSystemPropertiesFile"))) {
1812058
+
1812058
+            // now load the system file, if it exists, so its values
1812058
+            // will win if they conflict with the earlier values
1812058
+            try (BufferedInputStream bis =
1812058
+                 new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
1812058
+                props.load(bis);
1812058
+                loadedProps = true;
1812058
+
1812058
+                if (sdebug != null) {
1812058
+                    sdebug.println("reading system security properties file " +
1812058
+                                   SYSTEM_PROPERTIES);
1812058
+                    sdebug.println(props.toString());
1812058
+                }
1812058
+            } catch (IOException e) {
1812058
+                if (sdebug != null) {
1812058
+                    sdebug.println
1812058
+                        ("unable to load security properties from " +
1812058
+                         SYSTEM_PROPERTIES);
1812058
+                    e.printStackTrace();
1812058
+                }
1812058
+            }
1812058
+        }
1812058
+
1812058
         if (!loadedProps) {
1812058
             initializeStatic();
1812058
             if (sdebug != null) {