|
26 | 26 | package sun.security.jgss.wrapper;
|
27 | 27 |
|
28 | 28 | import java.io.Serial;
|
29 |
| -import java.util.HashMap; |
30 | 29 | import java.security.Provider;
|
31 | 30 |
|
32 | 31 | import jdk.internal.util.OperatingSystem;
|
@@ -64,10 +63,10 @@ static void debug(String message) {
|
64 | 63 | System.err.println(NAME + ": " + message);
|
65 | 64 | }
|
66 | 65 |
|
67 |
| - private static final HashMap<String, String> MECH_MAP = constructMechMap(); |
| 66 | + private static final Oid[] MECH_OIDS = getMechOIDs(); |
68 | 67 |
|
69 | 68 | @SuppressWarnings("restricted")
|
70 |
| - private static HashMap<String, String> constructMechMap() { |
| 69 | + private static Oid[] getMechOIDs() { |
71 | 70 | try {
|
72 | 71 | // Ensure the InetAddress class is loaded before
|
73 | 72 | // loading j2gss. The library will access this class
|
@@ -112,28 +111,29 @@ private static HashMap<String, String> constructMechMap() {
|
112 | 111 | debug("Loaded GSS library: " + libName);
|
113 | 112 | }
|
114 | 113 | 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); |
119 | 117 | }
|
120 |
| - map.put("GssApiMechanism." + mechs[i], MF_CLASS); |
121 | 118 | }
|
122 |
| - return map; |
| 119 | + return mechs; |
123 | 120 | }
|
124 | 121 | }
|
125 | 122 | return null;
|
126 | 123 | }
|
127 | 124 |
|
128 |
| - // initialize INSTANCE after MECH_MAP is constructed |
| 125 | + // initialize INSTANCE after MECH_OIDS is constructed |
129 | 126 | static final Provider INSTANCE = new SunNativeProvider();
|
130 | 127 |
|
131 | 128 | public SunNativeProvider() {
|
132 | 129 | /* We are the Sun NativeGSS provider */
|
133 | 130 | super(NAME, PROVIDER_VER, INFO);
|
134 | 131 |
|
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 | + } |
137 | 137 | }
|
138 | 138 | }
|
139 | 139 | }
|
0 commit comments