11/*
22 * ===========================================================================
3- * (c) Copyright IBM Corp. 2022, 2024 All Rights Reserved
3+ * (c) Copyright IBM Corp. 2022, 2025 All Rights Reserved
44 * ===========================================================================
55 *
66 * This code is free software; you can redistribute it and/or modify it
2424package openj9 .internal .security ;
2525
2626import java .nio .charset .StandardCharsets ;
27- import java .security .AccessController ;
2827import java .security .MessageDigest ;
2928import java .security .NoSuchAlgorithmException ;
30- import java .security .PrivilegedAction ;
3129import java .security .Provider ;
3230import java .security .Provider .Service ;
3331import java .time .LocalDate ;
@@ -93,30 +91,20 @@ public final class RestrictedSecurity {
9391 supportedPlatformsOpenJCEPlus .put ("Arch" , List .of ("amd64" , "ppc64" , "s390x" ));
9492 supportedPlatformsOpenJCEPlus .put ("OS" , List .of ("Linux" , "AIX" , "Windows" ));
9593
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" );
10896
10997 boolean isOsSupported , isArchSupported ;
11098 // Check whether the NSS FIPS solution is supported.
11199 isOsSupported = false ;
112100 for (String os : supportedPlatformsNSS .get ("OS" )) {
113- if (props [ 2 ] .contains (os )) {
101+ if (osName .contains (os )) {
114102 isOsSupported = true ;
115103 }
116104 }
117105 isArchSupported = false ;
118106 for (String arch : supportedPlatformsNSS .get ("Arch" )) {
119- if (props [ 3 ] .contains (arch )) {
107+ if (osArch .contains (arch )) {
120108 isArchSupported = true ;
121109 }
122110 }
@@ -125,13 +113,13 @@ public String[] run() {
125113 // Check whether the OpenJCEPlus FIPS solution is supported.
126114 isOsSupported = false ;
127115 for (String os : supportedPlatformsOpenJCEPlus .get ("OS" )) {
128- if (props [ 2 ] .contains (os )) {
116+ if (osName .contains (os )) {
129117 isOsSupported = true ;
130118 }
131119 }
132120 isArchSupported = false ;
133121 for (String arch : supportedPlatformsOpenJCEPlus .get ("Arch" )) {
134- if (props [ 3 ] .contains (arch )) {
122+ if (osArch .contains (arch )) {
135123 isArchSupported = true ;
136124 }
137125 }
@@ -140,8 +128,8 @@ public String[] run() {
140128 // Check the default solution to see if FIPS is supported.
141129 isFIPSSupported = isNSSSupported ;
142130
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" );
145133
146134 if (userEnabledFIPS ) {
147135 if (isFIPSSupported ) {
@@ -151,12 +139,8 @@ public String[] run() {
151139 }
152140
153141 // 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 ;
160144
161145 // Check if FIPS is supported on this platform without explicitly setting a profile.
162146 if (userEnabledFIPS && !isFIPSSupported && !userSetProfile ) {
0 commit comments