Skip to content

Commit c1a78b7

Browse files
committed
Update according to code review
1 parent 3229c52 commit c1a78b7

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public final class RestrictedSecurity {
107107

108108
userEnabledFIPS = Boolean.getBoolean("semeru.fips");
109109
allowSetProperties = Boolean.getBoolean("semeru.fips.allowsetproperties");
110-
suppressSunsetWarning = Boolean.getBoolean("semeru.restrictedsecurity.suppresssunsetwarning");
111-
ignoreSunsetExpiration = Boolean.getBoolean("semeru.restrictedsecurity.ignoresunsetexpiration");
110+
suppressSunsetWarning = getBooleanPropertyTreatEmptyAsTrue("semeru.restrictedsecurity.suppresssunsetwarning");
111+
ignoreSunsetExpiration = getBooleanPropertyTreatEmptyAsTrue("semeru.restrictedsecurity.ignoresunsetexpiration");
112112

113113
if (userEnabledFIPS) {
114114
if (isFIPSSupported) {
@@ -140,6 +140,19 @@ private RestrictedSecurity() {
140140
super();
141141
}
142142

143+
private static boolean getBooleanPropertyTreatEmptyAsTrue(String name) {
144+
String systemProp = System.getProperty(name);
145+
if (systemProp == null) {
146+
return false;
147+
}
148+
if (systemProp.isEmpty()) {
149+
// If set without a value (e.g., "-Dsemeru.restrictedsecurity.suppresssunsetwarning"),
150+
// treat it as true and suppress the warning.
151+
return true;
152+
}
153+
return Boolean.parseBoolean(systemProp);
154+
}
155+
143156
private static boolean isJarVerifierInStackTrace() {
144157
java.util.function.Predicate<Class<?>> isJarVerifier =
145158
clazz -> "java.util.jar.JarVerifier".equals(clazz.getName())

closed/test/jdk/openj9/internal/security/TestPolicySunset.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,32 @@ private static Stream<Arguments> patternMatches_expectedExitValue0() {
7676
// 1 - expired; supress=false; ignore=true
7777
Arguments.of("Test-Profile-PolicySunset-Expired",
7878
propertyFile,
79-
"false", "true",
79+
"=false", "=true",
8080
"WARNING: java will start with the requested restricted security profile but uncertified cryptography may be active"),
8181
// 2 - expired; supress=true; ignore=true, no warning
8282
Arguments.of("Test-Profile-PolicySunset-Expired",
8383
propertyFile,
84-
"true", "true",
84+
"=true", "=true",
8585
""),
8686
// 3 - expire soon (<=6 months); supress=false
8787
Arguments.of("Test-Profile-PolicySunset-ExpireSoon",
8888
updatedPropertyFile,
89-
"false", "false",
89+
"=false", "=false",
9090
"The restricted security profile RestrictedSecurity.Test-Profile-PolicySunset-ExpireSoon will expire"),
9191
// 4 - expire soon (<=6 months); supress=true, no warning
9292
Arguments.of("Test-Profile-PolicySunset-ExpireSoon",
9393
updatedPropertyFile,
94-
"true", "false",
94+
"=true", "=false",
9595
""),
9696
// 5 - not expire (>6 months); no warning
9797
Arguments.of("Test-Profile-PolicySunset-NotExpire",
9898
propertyFile,
99-
"false", "false",
99+
"=false", "=false",
100+
""),
101+
// 6 - expired; property treat empty as true, no warning
102+
Arguments.of("Test-Profile-PolicySunset-Expired",
103+
propertyFile,
104+
"", "" ,
100105
""));
101106
}
102107

@@ -107,12 +112,12 @@ private static Stream<Arguments> patternMatches_expectedExitValue1() {
107112
// 1 - expired; supress=false; ignore=false
108113
Arguments.of("Test-Profile-PolicySunset-Expired",
109114
propertyFile,
110-
"false", "false",
111-
"Use the -Dsemeru.restrictedsecurity.ignoresunsetexpiration to allow java to start while possibly using uncertified cryptography"),
115+
"=false", "=false",
116+
"Use -Dsemeru.restrictedsecurity.ignoresunsetexpiration to allow java to start while possibly using uncertified cryptography"),
112117
// 2 - expired; supress=true; ignore=false, no warning
113118
Arguments.of("Test-Profile-PolicySunset-Expired",
114119
propertyFile,
115-
"true", "false",
120+
"=true", "=false",
116121
""));
117122
}
118123

@@ -123,8 +128,8 @@ public void shouldContain_expectedExitValue0(String customprofile, String securi
123128
"-Dsemeru.fips=true",
124129
"-Dsemeru.customprofile=" + customprofile,
125130
"-Djava.security.properties=" + securityPropertyFile,
126-
"-Dsemeru.restrictedsecurity.suppresssunsetwarning=" + suppresssunsetwarning,
127-
"-Dsemeru.restrictedsecurity.ignoresunsetexpiration=" + ignoresunsetexpiration,
131+
"-Dsemeru.restrictedsecurity.suppresssunsetwarning" + suppresssunsetwarning,
132+
"-Dsemeru.restrictedsecurity.ignoresunsetexpiration" + ignoresunsetexpiration,
128133
"TestPolicySunset"
129134
);
130135
outputAnalyzer.reportDiagnosticSummary();
@@ -138,8 +143,8 @@ public void shouldContain_expectedExitValue1(String customprofile, String securi
138143
"-Dsemeru.fips=true",
139144
"-Dsemeru.customprofile=" + customprofile,
140145
"-Djava.security.properties=" + securityPropertyFile,
141-
"-Dsemeru.restrictedsecurity.suppresssunsetwarning=" + suppresssunsetwarning,
142-
"-Dsemeru.restrictedsecurity.ignoresunsetexpiration=" + ignoresunsetexpiration,
146+
"-Dsemeru.restrictedsecurity.suppresssunsetwarning" + suppresssunsetwarning,
147+
"-Dsemeru.restrictedsecurity.ignoresunsetexpiration" + ignoresunsetexpiration,
143148
"TestPolicySunset"
144149
);
145150
outputAnalyzer.reportDiagnosticSummary();

closed/test/jdk/openj9/internal/security/TestProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private static Stream<Arguments> patternMatches_expectedExitValue1() {
119119
// 15 - Test property - policy sunset.
120120
Arguments.of("Test-Profile-PolicySunset.Base",
121121
System.getProperty("test.src") + "/property-java.security",
122-
"Use the -Dsemeru.restrictedsecurity.ignoresunsetexpiration to allow java to start while possibly using uncertified cryptography"),
122+
"Use -Dsemeru.restrictedsecurity.ignoresunsetexpiration to allow java to start while possibly using uncertified cryptography"),
123123
// 16 - Test property - policy sunset format.
124124
Arguments.of("Test-Profile-PolicySunsetFormat.Base",
125125
System.getProperty("test.src") + "/property-java.security",

0 commit comments

Comments
 (0)