1
1
/*
2
2
* ===========================================================================
3
- * (c) Copyright IBM Corp. 2022, 2024 All Rights Reserved
3
+ * (c) Copyright IBM Corp. 2022, 2025 All Rights Reserved
4
4
* ===========================================================================
5
5
*
6
6
* This code is free software; you can redistribute it and/or modify it
24
24
package openj9 .internal .security ;
25
25
26
26
import java .nio .charset .StandardCharsets ;
27
- import java .security .AccessController ;
28
27
import java .security .MessageDigest ;
29
28
import java .security .NoSuchAlgorithmException ;
30
- import java .security .PrivilegedAction ;
31
29
import java .security .Provider ;
32
30
import java .security .Provider .Service ;
33
31
import java .time .LocalDate ;
@@ -93,30 +91,20 @@ public final class RestrictedSecurity {
93
91
supportedPlatformsOpenJCEPlus .put ("Arch" , List .of ("amd64" , "ppc64" , "s390x" ));
94
92
supportedPlatformsOpenJCEPlus .put ("OS" , List .of ("Linux" , "AIX" , "Windows" ));
95
93
96
- @ SuppressWarnings ("removal" )
97
- String [] props = AccessController .doPrivileged (
98
- new PrivilegedAction <>() {
99
- @ Override
100
- public String [] run () {
101
- return new String [] { System .getProperty ("semeru.fips" ),
102
- System .getProperty ("semeru.customprofile" ),
103
- System .getProperty ("os.name" ),
104
- System .getProperty ("os.arch" ),
105
- System .getProperty ("semeru.fips.allowsetproperties" ) };
106
- }
107
- });
94
+ String osName = System .getProperty ("os.name" );
95
+ String osArch = System .getProperty ("os.arch" );
108
96
109
97
boolean isOsSupported , isArchSupported ;
110
98
// Check whether the NSS FIPS solution is supported.
111
99
isOsSupported = false ;
112
100
for (String os : supportedPlatformsNSS .get ("OS" )) {
113
- if (props [ 2 ] .contains (os )) {
101
+ if (osName .contains (os )) {
114
102
isOsSupported = true ;
115
103
}
116
104
}
117
105
isArchSupported = false ;
118
106
for (String arch : supportedPlatformsNSS .get ("Arch" )) {
119
- if (props [ 3 ] .contains (arch )) {
107
+ if (osArch .contains (arch )) {
120
108
isArchSupported = true ;
121
109
}
122
110
}
@@ -125,13 +113,13 @@ public String[] run() {
125
113
// Check whether the OpenJCEPlus FIPS solution is supported.
126
114
isOsSupported = false ;
127
115
for (String os : supportedPlatformsOpenJCEPlus .get ("OS" )) {
128
- if (props [ 2 ] .contains (os )) {
116
+ if (osName .contains (os )) {
129
117
isOsSupported = true ;
130
118
}
131
119
}
132
120
isArchSupported = false ;
133
121
for (String arch : supportedPlatformsOpenJCEPlus .get ("Arch" )) {
134
- if (props [ 3 ] .contains (arch )) {
122
+ if (osArch .contains (arch )) {
135
123
isArchSupported = true ;
136
124
}
137
125
}
@@ -140,8 +128,8 @@ public String[] run() {
140
128
// Check the default solution to see if FIPS is supported.
141
129
isFIPSSupported = isNSSSupported ;
142
130
143
- userEnabledFIPS = Boolean .parseBoolean ( props [ 0 ] );
144
- allowSetProperties = Boolean .parseBoolean ( props [ 4 ] );
131
+ userEnabledFIPS = Boolean .getBoolean ( "semeru.fips" );
132
+ allowSetProperties = Boolean .getBoolean ( "semeru.fips.allowsetproperties" );
145
133
146
134
if (userEnabledFIPS ) {
147
135
if (isFIPSSupported ) {
@@ -151,12 +139,8 @@ public String[] run() {
151
139
}
152
140
153
141
// If user has specified a profile, use that
154
- if (props [1 ] != null ) {
155
- selectedProfile = props [1 ];
156
- userSetProfile = true ;
157
- } else {
158
- userSetProfile = false ;
159
- }
142
+ selectedProfile = System .getProperty ("semeru.customprofile" );
143
+ userSetProfile = selectedProfile != null ;
160
144
161
145
// Check if FIPS is supported on this platform without explicitly setting a profile.
162
146
if (userEnabledFIPS && !isFIPSSupported && !userSetProfile ) {
0 commit comments