Skip to content

Commit 33602fc

Browse files
authored
Merge pull request ibmruntimes#732 from taoliult/sasl
Add provider name and class name mapping in Restricted Security mode
2 parents db90e02 + 6ff96c9 commit 33602fc

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

closed/adds/jdk/src/share/classes/openj9/internal/security/RestrictedSecurity.java

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ===========================================================================
3-
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
3+
* (c) Copyright IBM Corp. 2022, 2024 All Rights Reserved
44
* ===========================================================================
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -670,6 +670,19 @@ private void initProviders() {
670670
// Provider with argument (provider name + optional argument).
671671
providers.add(pNum - 1, providerName);
672672

673+
// Remove the provider's optional arguments if present.
674+
pos = providerName.indexOf(' ');
675+
if (pos >= 0) {
676+
providerName = providerName.substring(0, pos);
677+
}
678+
providerName = providerName.trim();
679+
680+
// Remove argument, e.g. -NSS-FIPS, if present.
681+
pos = providerName.indexOf('-');
682+
if (pos >= 0) {
683+
providerName = providerName.substring(0, pos);
684+
}
685+
673686
// Provider name defined in provider construction method.
674687
providerName = getProvidersSimpleName(providerName);
675688
providersSimpleName.add(pNum - 1, providerName);
@@ -935,6 +948,13 @@ boolean isRestrictedProviderAllowed(String providerName) {
935948
debug.println("Checking the provider " + providerName + " in restricted security mode.");
936949
}
937950

951+
// Remove argument, e.g. -NSS-FIPS, if present.
952+
int pos = providerName.indexOf('-');
953+
if (pos >= 0) {
954+
providerName = providerName.substring(0, pos);
955+
}
956+
957+
// Provider name defined in provider construction method.
938958
providerName = getProvidersSimpleName(providerName);
939959

940960
// Check if the provider is in restricted security provider list.
@@ -963,30 +983,27 @@ boolean isRestrictedProviderAllowed(String providerName) {
963983
/**
964984
* Get the provider name defined in provider construction method.
965985
*
966-
* @param providerName provider name or provider with packages or arguments
986+
* @param providerName provider name or provider with packages
967987
* @return provider name defined in provider construction method
968988
*/
969989
private static String getProvidersSimpleName(String providerName) {
970-
// Remove the provider's optional arguments if present.
971-
int pos = providerName.indexOf(' ');
972-
providerName = (pos < 0) ? providerName.trim() : providerName.substring(0, pos).trim();
973-
974-
// Remove argument, e.g. -NSS-FIPS, if present.
975-
pos = providerName.indexOf('-');
976-
providerName = (pos < 0) ? providerName : providerName.substring(0, pos);
977-
978990
if (providerName.equals("com.sun.net.ssl.internal.ssl.Provider")) {
979991
// In JDK 8, the main class for the SunJSSE provider is
980992
// com.sun.net.ssl.internal.ssl.Provider
981993
return "SunJSSE";
982994
} else if (providerName.equals("sun.security.provider.Sun")) {
983995
// In JDK 8, the main class for the SUN provider is sun.security.provider.Sun
984996
return "SUN";
997+
} else if (providerName.equals("com.sun.security.sasl.Provider")) {
998+
// The main class for the SunSASL provider is com.sun.security.sasl.Provider.
999+
return "SunSASL";
9851000
} else {
9861001
// Remove the provider's class package names if present.
987-
pos = providerName.lastIndexOf('.');
988-
providerName = (pos < 0) ? providerName : providerName.substring(pos + 1);
989-
// Provider without arguments and package names.
1002+
int pos = providerName.lastIndexOf('.');
1003+
if (pos >= 0) {
1004+
providerName = providerName.substring(pos + 1);
1005+
}
1006+
// Provider without package names.
9901007
return providerName;
9911008
}
9921009
}

0 commit comments

Comments
 (0)