1 |
# HG changeset patch |
2 |
# User andrew |
3 |
# Date 1545198926 0 |
4 |
# Wed Dec 19 05:55:26 2018 +0000 |
5 |
# Node ID f2cbd688824c128db7fa848c8732fb0ab3507776 |
6 |
# Parent 81f07f6d1f8b7b51b136d3974c61bc8bb513770c |
7 |
PR3695: Allow use of system crypto policy to be disabled by the user |
8 |
Summary: Read user overrides first so security.useSystemPropertiesFile can be disabled and add -Djava.security.disableSystemPropertiesFile |
9 |
|
10 |
diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java |
11 |
--- a/src/java.base/share/classes/java/security/Security.java |
12 |
+++ b/src/java.base/share/classes/java/security/Security.java |
13 |
@@ -125,31 +125,6 @@ |
14 |
} |
15 |
|
16 |
if ("true".equalsIgnoreCase(props.getProperty |
17 |
- ("security.useSystemPropertiesFile"))) { |
18 |
- |
19 |
- // now load the system file, if it exists, so its values |
20 |
- // will win if they conflict with the earlier values |
21 |
- try (BufferedInputStream bis = |
22 |
- new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) { |
23 |
- props.load(bis); |
24 |
- loadedProps = true; |
25 |
- |
26 |
- if (sdebug != null) { |
27 |
- sdebug.println("reading system security properties file " + |
28 |
- SYSTEM_PROPERTIES); |
29 |
- sdebug.println(props.toString()); |
30 |
- } |
31 |
- } catch (IOException e) { |
32 |
- if (sdebug != null) { |
33 |
- sdebug.println |
34 |
- ("unable to load security properties from " + |
35 |
- SYSTEM_PROPERTIES); |
36 |
- e.printStackTrace(); |
37 |
- } |
38 |
- } |
39 |
- } |
40 |
- |
41 |
- if ("true".equalsIgnoreCase(props.getProperty |
42 |
("security.overridePropertiesFile"))) { |
43 |
|
44 |
String extraPropFile = System.getProperty |
45 |
@@ -215,6 +190,33 @@ |
46 |
} |
47 |
} |
48 |
|
49 |
+ String disableSystemProps = System.getProperty("java.security.disableSystemPropertiesFile"); |
50 |
+ if (disableSystemProps == null && |
51 |
+ "true".equalsIgnoreCase(props.getProperty |
52 |
+ ("security.useSystemPropertiesFile"))) { |
53 |
+ |
54 |
+ // now load the system file, if it exists, so its values |
55 |
+ // will win if they conflict with the earlier values |
56 |
+ try (BufferedInputStream bis = |
57 |
+ new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) { |
58 |
+ props.load(bis); |
59 |
+ loadedProps = true; |
60 |
+ |
61 |
+ if (sdebug != null) { |
62 |
+ sdebug.println("reading system security properties file " + |
63 |
+ SYSTEM_PROPERTIES); |
64 |
+ sdebug.println(props.toString()); |
65 |
+ } |
66 |
+ } catch (IOException e) { |
67 |
+ if (sdebug != null) { |
68 |
+ sdebug.println |
69 |
+ ("unable to load security properties from " + |
70 |
+ SYSTEM_PROPERTIES); |
71 |
+ e.printStackTrace(); |
72 |
+ } |
73 |
+ } |
74 |
+ } |
75 |
+ |
76 |
if (!loadedProps) { |
77 |
initializeStatic(); |
78 |
if (sdebug != null) { |