Skip to content

Commit

Permalink
8345221: Replace legacy with new Provider APIs in SunNativeGSS
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco Ferrari Bihurriet <[email protected]>
Co-authored-by: Martin Balao <[email protected]>
Reviewed-by: weijun
  • Loading branch information
franferrax and martinuy committed Dec 3, 2024
1 parent 2be07b5 commit a49f077
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package sun.security.jgss.wrapper;

import java.io.Serial;
import java.util.HashMap;
import java.security.Provider;

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

private static final HashMap<String, String> MECH_MAP = constructMechMap();
private static final Oid[] MECH_OIDS = getMechOIDs();

@SuppressWarnings("restricted")
private static HashMap<String, String> constructMechMap() {
private static Oid[] getMechOIDs() {
try {
// Ensure the InetAddress class is loaded before
// loading j2gss. The library will access this class
Expand Down Expand Up @@ -112,28 +111,29 @@ private static HashMap<String, String> constructMechMap() {
debug("Loaded GSS library: " + libName);
}
Oid[] mechs = GSSLibStub.indicateMechs();
HashMap<String, String> map = new HashMap<>();
for (int i = 0; i < mechs.length; i++) {
if (DEBUG) {
debug("Native MF for " + mechs[i]);
if (DEBUG) {
for (Oid mech : mechs) {
debug("Native MF for " + mech);
}
map.put("GssApiMechanism." + mechs[i], MF_CLASS);
}
return map;
return mechs;
}
}
return null;
}

// initialize INSTANCE after MECH_MAP is constructed
// initialize INSTANCE after MECH_OIDS is constructed
static final Provider INSTANCE = new SunNativeProvider();

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

if (MECH_MAP != null) {
putAll(MECH_MAP);
if (MECH_OIDS != null) {
for (Oid mech : MECH_OIDS) {
putService(new Service(this, "GssApiMechanism",
mech.toString(), MF_CLASS, null, null));
}
}
}
}

0 comments on commit a49f077

Please sign in to comment.