Skip to content

Commit a49f077

Browse files
franferraxmartinuy
andcommitted
8345221: Replace legacy with new Provider APIs in SunNativeGSS
Co-authored-by: Francisco Ferrari Bihurriet <[email protected]> Co-authored-by: Martin Balao <[email protected]> Reviewed-by: weijun
1 parent 2be07b5 commit a49f077

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
package sun.security.jgss.wrapper;
2727

2828
import java.io.Serial;
29-
import java.util.HashMap;
3029
import java.security.Provider;
3130

3231
import jdk.internal.util.OperatingSystem;
@@ -64,10 +63,10 @@ static void debug(String message) {
6463
System.err.println(NAME + ": " + message);
6564
}
6665

67-
private static final HashMap<String, String> MECH_MAP = constructMechMap();
66+
private static final Oid[] MECH_OIDS = getMechOIDs();
6867

6968
@SuppressWarnings("restricted")
70-
private static HashMap<String, String> constructMechMap() {
69+
private static Oid[] getMechOIDs() {
7170
try {
7271
// Ensure the InetAddress class is loaded before
7372
// loading j2gss. The library will access this class
@@ -112,28 +111,29 @@ private static HashMap<String, String> constructMechMap() {
112111
debug("Loaded GSS library: " + libName);
113112
}
114113
Oid[] mechs = GSSLibStub.indicateMechs();
115-
HashMap<String, String> map = new HashMap<>();
116-
for (int i = 0; i < mechs.length; i++) {
117-
if (DEBUG) {
118-
debug("Native MF for " + mechs[i]);
114+
if (DEBUG) {
115+
for (Oid mech : mechs) {
116+
debug("Native MF for " + mech);
119117
}
120-
map.put("GssApiMechanism." + mechs[i], MF_CLASS);
121118
}
122-
return map;
119+
return mechs;
123120
}
124121
}
125122
return null;
126123
}
127124

128-
// initialize INSTANCE after MECH_MAP is constructed
125+
// initialize INSTANCE after MECH_OIDS is constructed
129126
static final Provider INSTANCE = new SunNativeProvider();
130127

131128
public SunNativeProvider() {
132129
/* We are the Sun NativeGSS provider */
133130
super(NAME, PROVIDER_VER, INFO);
134131

135-
if (MECH_MAP != null) {
136-
putAll(MECH_MAP);
132+
if (MECH_OIDS != null) {
133+
for (Oid mech : MECH_OIDS) {
134+
putService(new Service(this, "GssApiMechanism",
135+
mech.toString(), MF_CLASS, null, null));
136+
}
137137
}
138138
}
139139
}

0 commit comments

Comments
 (0)