Skip to content

Commit 36da087

Browse files
iigoninbennygoerzigKarstenSchnitterKai Sternad
committed
rename SecurityProviderManager#excludeSunJCE to SecurityProviderManager#removeNonCompliantFipsProviders
Signed-off-by: Igonin <[email protected]> Co-authored-by: Benny Goerzig <[email protected]> Co-authored-by: Karsten Schnitter <[email protected]> Co-authored-by: Kai Sternad <[email protected]>
1 parent ec536d9 commit 36da087

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

server/src/main/java/org/opensearch/bootstrap/Bootstrap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private void setup(boolean addShutdownHook, Environment environment) throws Boot
199199
var cryptoStandard = System.getenv("OPENSEARCH_CRYPTO_STANDARD");
200200
if ("FIPS-140-3".equals(cryptoStandard) || "true".equalsIgnoreCase(System.getProperty("org.bouncycastle.fips.approved_only"))) {
201201
LogManager.getLogger(Bootstrap.class).info("running in FIPS-140-3 mode");
202-
SecurityProviderManager.excludeSunJCE();
202+
SecurityProviderManager.removeNonCompliantFipsProviders();
203203
}
204204

205205
// initialize probes before the security manager is installed

server/src/main/java/org/opensearch/bootstrap/SecurityProviderManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private SecurityProviderManager() {}
2323
* Removes the SunJCE provider from the list of installed security providers. This method is intended to be used when running
2424
* in a FIPS JVM and when the security file specifies additional configuration, instead of a complete replacement.
2525
*/
26-
public static void excludeSunJCE() {
26+
public static void removeNonCompliantFipsProviders() {
2727
Security.removeProvider(SUN_JCE);
2828
}
2929

server/src/test/java/org/opensearch/bootstrap/SecurityProviderManagerTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void setUp() throws Exception {
4646
// restore the same state as before running the tests.
4747
public static void removeSunJCE() {
4848
if (inFipsJvm()) {
49-
SecurityProviderManager.excludeSunJCE();
49+
SecurityProviderManager.removeNonCompliantFipsProviders();
5050
}
5151
}
5252

@@ -57,7 +57,7 @@ public void testCipherRC4() throws Exception {
5757
assertEquals(SUN_JCE, cipher.getProvider().getName());
5858

5959
// when
60-
SecurityProviderManager.excludeSunJCE();
60+
SecurityProviderManager.removeNonCompliantFipsProviders();
6161

6262
// then
6363
expectThrows(NoSuchAlgorithmException.class, () -> Cipher.getInstance(RC_4));
@@ -70,7 +70,7 @@ public void testCipherAES() throws Exception {
7070
assertEquals(TOP_PRIO_CIPHER_PROVIDER, cipher.getProvider().getName());
7171

7272
// when
73-
SecurityProviderManager.excludeSunJCE();
73+
SecurityProviderManager.removeNonCompliantFipsProviders();
7474

7575
// then
7676
if (inFipsJvm()) {
@@ -89,7 +89,7 @@ public void testCipher3Des() throws Exception {
8989
assertEquals(TOP_PRIO_CIPHER_PROVIDER, cipher.getProvider().getName());
9090

9191
// when
92-
SecurityProviderManager.excludeSunJCE();
92+
SecurityProviderManager.removeNonCompliantFipsProviders();
9393

9494
// then
9595
if (inFipsJvm()) {
@@ -108,7 +108,7 @@ public void testCipherDes() throws Exception {
108108
assertEquals(SUN_JCE, cipher.getProvider().getName());
109109

110110
// when
111-
SecurityProviderManager.excludeSunJCE();
111+
SecurityProviderManager.removeNonCompliantFipsProviders();
112112

113113
// then
114114
expectThrows(NoSuchAlgorithmException.class, () -> Cipher.getInstance(DES));
@@ -121,7 +121,7 @@ public void testCipherPBE() throws Exception {
121121
assertEquals(SUN_JCE, cipher.getProvider().getName());
122122

123123
// when
124-
SecurityProviderManager.excludeSunJCE();
124+
SecurityProviderManager.removeNonCompliantFipsProviders();
125125

126126
// then
127127
expectThrows(NoSuchAlgorithmException.class, () -> Cipher.getInstance(PBE));
@@ -134,15 +134,15 @@ public void testCipherBlowfish() throws Exception {
134134
assertEquals(SUN_JCE, cipher.getProvider().getName());
135135

136136
// when
137-
SecurityProviderManager.excludeSunJCE();
137+
SecurityProviderManager.removeNonCompliantFipsProviders();
138138

139139
// then
140140
expectThrows(NoSuchAlgorithmException.class, () -> Cipher.getInstance(BLOWFISH));
141141
}
142142

143143
public void testGetPosition() {
144144
assertTrue(SUN_JCE + " is installed", SecurityProviderManager.getPosition(SUN_JCE) > 0);
145-
SecurityProviderManager.excludeSunJCE();
145+
SecurityProviderManager.removeNonCompliantFipsProviders();
146146
assertTrue(SUN_JCE + " is uninstalled", SecurityProviderManager.getPosition(SUN_JCE) < 0);
147147
}
148148

test/framework/src/main/java/org/opensearch/bootstrap/BootstrapForTesting.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
import java.util.Optional;
7474
import java.util.Properties;
7575
import java.util.Set;
76-
import java.util.function.Supplier;
7776
import java.util.stream.Collectors;
7877

7978
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
@@ -138,7 +137,7 @@ public class BootstrapForTesting {
138137
// Log ifconfig output before SecurityManager is installed
139138
IfConfig.logIfNecessary();
140139
if (FipsMode.CHECK.isFipsEnabled()) {
141-
SecurityProviderManager.excludeSunJCE();
140+
SecurityProviderManager.removeNonCompliantFipsProviders();
142141
}
143142

144143
// install security manager if requested
@@ -223,8 +222,6 @@ public boolean implies(ProtectionDomain domain, Permission permission) {
223222
}
224223
}
225224

226-
static Supplier<Integer> sunJceInsertFunction;
227-
228225
/** Add the codebase url of the given classname to the codebases map, if the class exists. */
229226
private static void addClassCodebase(Map<String, URL> codebases, String name, String classname) {
230227
try {

0 commit comments

Comments
 (0)