author | michaelm |
Thu, 06 Feb 2014 22:12:09 +0000 | |
changeset 22940 | 56b3ab8ec81c |
parent 16488 | 816b9df68a9f |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include "NativeUtil.h" |
|
27 |
#include "NativeFunc.h" |
|
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
5506
diff
changeset
|
28 |
#include "jlong.h" |
16488
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
29 |
#include <jni.h> |
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
30 |
#include "jni_util.h" |
16488
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
31 |
|
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
32 |
extern void throwOutOfMemoryError(JNIEnv *env, const char *message); |
2 | 33 |
|
34 |
const int JAVA_DUPLICATE_TOKEN_CODE = 19; /* DUPLICATE_TOKEN */ |
|
35 |
const int JAVA_OLD_TOKEN_CODE = 20; /* OLD_TOKEN */ |
|
36 |
const int JAVA_UNSEQ_TOKEN_CODE = 21; /* UNSEQ_TOKEN */ |
|
37 |
const int JAVA_GAP_TOKEN_CODE = 22; /* GAP_TOKEN */ |
|
38 |
const int JAVA_ERROR_CODE[] = { |
|
39 |
2, /* BAD_MECH */ |
|
40 |
3, /* BAD_NAME */ |
|
41 |
4, /* BAD_NAMETYPE */ |
|
42 |
1, /* BAD_BINDINGS */ |
|
43 |
5, /* BAD_STATUS */ |
|
44 |
6, /* BAD_MIC */ |
|
45 |
13, /* NO_CRED */ |
|
46 |
12, /* NO_CONTEXT */ |
|
47 |
10, /* DEFECTIVE_TOKEN */ |
|
48 |
9, /* DEFECTIVE_CREDENTIAL */ |
|
49 |
8, /* CREDENTIAL_EXPIRED */ |
|
50 |
7, /* CONTEXT_EXPIRED */ |
|
51 |
11, /* FAILURE */ |
|
52 |
14, /* BAD_QOP */ |
|
53 |
15, /* UNAUTHORIZED */ |
|
54 |
16, /* UNAVAILABLE */ |
|
55 |
17, /* DUPLICATE_ELEMENT */ |
|
56 |
18, /* NAME_NOT_MN */ |
|
57 |
}; |
|
58 |
const char SPNEGO_BYTES[] = { |
|
59 |
0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 |
|
60 |
}; |
|
61 |
||
62 |
jclass CLS_Object; |
|
63 |
jclass CLS_String; |
|
64 |
jclass CLS_Oid; |
|
65 |
jclass CLS_GSSException; |
|
66 |
jclass CLS_GSSNameElement; |
|
67 |
jclass CLS_GSSCredElement; |
|
68 |
jclass CLS_NativeGSSContext; |
|
69 |
jclass CLS_SunNativeProvider; |
|
70 |
jmethodID MID_String_ctor; |
|
71 |
jmethodID MID_Oid_ctor1; |
|
72 |
jmethodID MID_Oid_getDER; |
|
73 |
jmethodID MID_MessageProp_getPrivacy; |
|
74 |
jmethodID MID_MessageProp_getQOP; |
|
75 |
jmethodID MID_MessageProp_setPrivacy; |
|
76 |
jmethodID MID_MessageProp_setQOP; |
|
77 |
jmethodID MID_MessageProp_setSupplementaryStates; |
|
78 |
jmethodID MID_GSSException_ctor3; |
|
79 |
jmethodID MID_ChannelBinding_getInitiatorAddr; |
|
80 |
jmethodID MID_ChannelBinding_getAcceptorAddr; |
|
81 |
jmethodID MID_ChannelBinding_getAppData; |
|
82 |
jmethodID MID_InetAddress_getAddr; |
|
83 |
jmethodID MID_GSSNameElement_ctor; |
|
84 |
jmethodID MID_GSSCredElement_ctor; |
|
85 |
jmethodID MID_NativeGSSContext_ctor; |
|
86 |
jmethodID MID_SunNativeProvider_debug; |
|
87 |
jfieldID FID_GSSLibStub_pMech; |
|
88 |
jfieldID FID_NativeGSSContext_pContext; |
|
89 |
jfieldID FID_NativeGSSContext_srcName; |
|
90 |
jfieldID FID_NativeGSSContext_targetName; |
|
91 |
jfieldID FID_NativeGSSContext_isInitiator; |
|
92 |
jfieldID FID_NativeGSSContext_isEstablished; |
|
93 |
jfieldID FID_NativeGSSContext_delegatedCred; |
|
94 |
jfieldID FID_NativeGSSContext_flags; |
|
95 |
jfieldID FID_NativeGSSContext_lifetime; |
|
96 |
jfieldID FID_NativeGSSContext_actualMech; |
|
97 |
char debugBuf[256]; |
|
98 |
||
99 |
JNIEXPORT jint JNICALL |
|
100 |
JNI_OnLoad(JavaVM *jvm, void *reserved) { |
|
101 |
JNIEnv *env; |
|
102 |
jclass cls; |
|
103 |
||
104 |
if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) { |
|
105 |
return JNI_EVERSION; /* JNI version not supported */ |
|
106 |
} |
|
107 |
/* Retrieve and store the classes in global ref */ |
|
108 |
cls = (*env)->FindClass(env, "java/lang/Object"); |
|
109 |
if (cls == NULL) { |
|
110 |
printf("Couldn't find Object class\n"); |
|
111 |
return JNI_ERR; |
|
112 |
} |
|
113 |
CLS_Object = (*env)->NewGlobalRef(env, cls); |
|
114 |
if (CLS_Object == NULL) { |
|
115 |
return JNI_ERR; |
|
116 |
} |
|
117 |
cls = (*env)->FindClass(env, "java/lang/String"); |
|
118 |
if (cls == NULL) { |
|
119 |
printf("Couldn't find String class\n"); |
|
120 |
return JNI_ERR; |
|
121 |
} |
|
122 |
CLS_String = (*env)->NewGlobalRef(env, cls); |
|
123 |
if (CLS_String == NULL) { |
|
124 |
return JNI_ERR; |
|
125 |
} |
|
126 |
cls = (*env)->FindClass(env, "org/ietf/jgss/Oid"); |
|
127 |
if (cls == NULL) { |
|
128 |
printf("Couldn't find org.ietf.jgss.Oid class\n"); |
|
129 |
return JNI_ERR; |
|
130 |
} |
|
131 |
CLS_Oid = (*env)->NewGlobalRef(env, cls); |
|
132 |
if (CLS_Oid == NULL) { |
|
133 |
return JNI_ERR; |
|
134 |
} |
|
135 |
cls = (*env)->FindClass(env, "org/ietf/jgss/GSSException"); |
|
136 |
if (cls == NULL) { |
|
137 |
printf("Couldn't find org.ietf.jgss.GSSException class\n"); |
|
138 |
return JNI_ERR; |
|
139 |
} |
|
140 |
CLS_GSSException = (*env)->NewGlobalRef(env, cls); |
|
141 |
if (CLS_GSSException == NULL) { |
|
142 |
return JNI_ERR; |
|
143 |
} |
|
144 |
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSNameElement"); |
|
145 |
if (cls == NULL) { |
|
146 |
printf("Couldn't find sun.security.jgss.wrapper.GSSNameElement class\n"); |
|
147 |
return JNI_ERR; |
|
148 |
} |
|
149 |
CLS_GSSNameElement = (*env)->NewGlobalRef(env, cls); |
|
150 |
if (CLS_GSSException == NULL) { |
|
151 |
return JNI_ERR; |
|
152 |
} |
|
153 |
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSCredElement"); |
|
154 |
if (cls == NULL) { |
|
155 |
printf("Couldn't find sun.security.jgss.wrapper.GSSCredElement class\n"); |
|
156 |
return JNI_ERR; |
|
157 |
} |
|
158 |
CLS_GSSCredElement = (*env)->NewGlobalRef(env, cls); |
|
159 |
if (CLS_GSSCredElement == NULL) { |
|
160 |
return JNI_ERR; |
|
161 |
} |
|
162 |
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/NativeGSSContext"); |
|
163 |
if (cls == NULL) { |
|
164 |
printf("Couldn't find sun.security.jgss.wrapper.NativeGSSContext class\n"); |
|
165 |
return JNI_ERR; |
|
166 |
} |
|
167 |
CLS_NativeGSSContext = (*env)->NewGlobalRef(env, cls); |
|
168 |
if (CLS_NativeGSSContext == NULL) { |
|
169 |
return JNI_ERR; |
|
170 |
} |
|
171 |
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/SunNativeProvider"); |
|
172 |
if (cls == NULL) { |
|
173 |
printf("Couldn't find sun.security.jgss.wrapper.SunNativeProvider class\n"); |
|
174 |
return JNI_ERR; |
|
175 |
} |
|
176 |
CLS_SunNativeProvider = (*env)->NewGlobalRef(env, cls); |
|
177 |
if (CLS_SunNativeProvider == NULL) { |
|
178 |
return JNI_ERR; |
|
179 |
} |
|
180 |
/* Compute and cache the method ID */ |
|
181 |
MID_String_ctor = (*env)->GetMethodID(env, CLS_String, |
|
182 |
"<init>", "([B)V"); |
|
183 |
if (MID_String_ctor == NULL) { |
|
184 |
printf("Couldn't find String(byte[]) constructor\n"); |
|
185 |
return JNI_ERR; |
|
186 |
} |
|
187 |
MID_Oid_ctor1 = |
|
188 |
(*env)->GetMethodID(env, CLS_Oid, "<init>", "([B)V"); |
|
189 |
if (MID_Oid_ctor1 == NULL) { |
|
190 |
printf("Couldn't find Oid(byte[]) constructor\n"); |
|
191 |
return JNI_ERR; |
|
192 |
} |
|
193 |
MID_Oid_getDER = (*env)->GetMethodID(env, CLS_Oid, "getDER", "()[B"); |
|
194 |
if (MID_Oid_getDER == NULL) { |
|
195 |
printf("Couldn't find Oid.getDER() method\n"); |
|
196 |
return JNI_ERR; |
|
197 |
} |
|
198 |
cls = (*env)->FindClass(env, "org/ietf/jgss/MessageProp"); |
|
199 |
if (cls == NULL) { |
|
200 |
printf("Couldn't find org.ietf.jgss.MessageProp class\n"); |
|
201 |
return JNI_ERR; |
|
202 |
} |
|
203 |
MID_MessageProp_getPrivacy = |
|
204 |
(*env)->GetMethodID(env, cls, "getPrivacy", "()Z"); |
|
205 |
if (MID_MessageProp_getPrivacy == NULL) { |
|
206 |
printf("Couldn't find MessageProp.getPrivacy() method\n"); |
|
207 |
return JNI_ERR; |
|
208 |
} |
|
209 |
MID_MessageProp_getQOP = (*env)->GetMethodID(env, cls, "getQOP", "()I"); |
|
210 |
if (MID_MessageProp_getQOP == NULL) { |
|
211 |
printf("Couldn't find MessageProp.getQOP() method\n"); |
|
212 |
return JNI_ERR; |
|
213 |
} |
|
214 |
MID_MessageProp_setPrivacy = |
|
215 |
(*env)->GetMethodID(env, cls, "setPrivacy", "(Z)V"); |
|
216 |
if (MID_MessageProp_setPrivacy == NULL) { |
|
217 |
printf("Couldn't find MessageProp.setPrivacy(boolean) method\n"); |
|
218 |
return JNI_ERR; |
|
219 |
} |
|
220 |
MID_MessageProp_setQOP = (*env)->GetMethodID(env, cls, "setQOP", "(I)V"); |
|
221 |
if (MID_MessageProp_setQOP == NULL) { |
|
222 |
printf("Couldn't find MessageProp.setQOP(int) method\n"); |
|
223 |
return JNI_ERR; |
|
224 |
} |
|
225 |
MID_MessageProp_setSupplementaryStates = |
|
226 |
(*env)->GetMethodID(env, cls, "setSupplementaryStates", |
|
227 |
"(ZZZZILjava/lang/String;)V"); |
|
228 |
if (MID_MessageProp_setSupplementaryStates == NULL) { |
|
229 |
printf("Couldn't find MessageProp.setSupplementaryStates(...) method\n"); |
|
230 |
return JNI_ERR; |
|
231 |
} |
|
232 |
MID_GSSException_ctor3 = (*env)->GetMethodID |
|
233 |
(env, CLS_GSSException, "<init>", "(IILjava/lang/String;)V"); |
|
234 |
if (MID_GSSException_ctor3 == NULL) { |
|
235 |
printf("Couldn't find GSSException(int, int, String) constructor\n"); |
|
236 |
return JNI_ERR; |
|
237 |
} |
|
238 |
cls = (*env)->FindClass(env, "org/ietf/jgss/ChannelBinding"); |
|
239 |
if (cls == NULL) { |
|
240 |
printf("Couldn't find org.ietf.jgss.ChannelBinding class\n"); |
|
241 |
return JNI_ERR; |
|
242 |
} |
|
243 |
MID_ChannelBinding_getInitiatorAddr = |
|
244 |
(*env)->GetMethodID(env, cls, "getInitiatorAddress", |
|
245 |
"()Ljava/net/InetAddress;"); |
|
246 |
if (MID_ChannelBinding_getInitiatorAddr == NULL) { |
|
247 |
printf("Couldn't find ChannelBinding.getInitiatorAddress() method\n"); |
|
248 |
return JNI_ERR; |
|
249 |
} |
|
250 |
MID_ChannelBinding_getAcceptorAddr = |
|
251 |
(*env)->GetMethodID(env, cls, "getAcceptorAddress", |
|
252 |
"()Ljava/net/InetAddress;"); |
|
253 |
if (MID_ChannelBinding_getAcceptorAddr == NULL) { |
|
254 |
printf("Couldn't find ChannelBinding.getAcceptorAddress() method\n"); |
|
255 |
return JNI_ERR; |
|
256 |
} |
|
257 |
MID_ChannelBinding_getAppData = |
|
258 |
(*env)->GetMethodID(env, cls, "getApplicationData", "()[B"); |
|
259 |
if (MID_ChannelBinding_getAppData == NULL) { |
|
260 |
printf("Couldn't find ChannelBinding.getApplicationData() method\n"); |
|
261 |
return JNI_ERR; |
|
262 |
} |
|
263 |
cls = (*env)->FindClass(env, "java/net/InetAddress"); |
|
264 |
if (cls == NULL) { |
|
265 |
printf("Couldn't find java.net.InetAddress class\n"); |
|
266 |
return JNI_ERR; |
|
267 |
} |
|
268 |
MID_InetAddress_getAddr = (*env)->GetMethodID(env, cls, "getAddress", |
|
269 |
"()[B"); |
|
270 |
if (MID_InetAddress_getAddr == NULL) { |
|
271 |
printf("Couldn't find InetAddress.getAddress() method\n"); |
|
272 |
return JNI_ERR; |
|
273 |
} |
|
274 |
MID_GSSNameElement_ctor = |
|
275 |
(*env)->GetMethodID(env, CLS_GSSNameElement, |
|
276 |
"<init>", "(JLsun/security/jgss/wrapper/GSSLibStub;)V"); |
|
277 |
if (MID_GSSNameElement_ctor == NULL) { |
|
278 |
printf("Couldn't find GSSNameElement(long, GSSLibStub) constructor\n"); |
|
279 |
return JNI_ERR; |
|
280 |
} |
|
281 |
MID_GSSCredElement_ctor = |
|
282 |
(*env)->GetMethodID(env, CLS_GSSCredElement, "<init>", |
|
283 |
"(JLsun/security/jgss/wrapper/GSSNameElement;Lorg/ietf/jgss/Oid;)V"); |
|
284 |
if (MID_GSSCredElement_ctor == NULL) { |
|
285 |
printf("Couldn't find GSSCredElement(long, GSSLibStub) constructor\n"); |
|
286 |
return JNI_ERR; |
|
287 |
} |
|
288 |
MID_NativeGSSContext_ctor = |
|
289 |
(*env)->GetMethodID(env, CLS_NativeGSSContext, "<init>", |
|
290 |
"(JLsun/security/jgss/wrapper/GSSLibStub;)V"); |
|
291 |
if (MID_NativeGSSContext_ctor == NULL) { |
|
292 |
printf("Couldn't find NativeGSSContext(long, GSSLibStub) constructor\n"); |
|
293 |
return JNI_ERR; |
|
294 |
} |
|
295 |
MID_SunNativeProvider_debug = |
|
296 |
(*env)->GetStaticMethodID(env, CLS_SunNativeProvider, "debug", |
|
297 |
"(Ljava/lang/String;)V"); |
|
298 |
if (MID_SunNativeProvider_debug == NULL) { |
|
299 |
printf("Couldn't find SunNativeProvider.debug(String) method\n"); |
|
300 |
return JNI_ERR; |
|
301 |
} |
|
302 |
/* Compute and cache the field ID */ |
|
303 |
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSLibStub"); |
|
304 |
if (cls == NULL) { |
|
305 |
printf("Couldn't find sun.security.jgss.wrapper.GSSLibStub class\n"); |
|
306 |
return JNI_ERR; |
|
307 |
} |
|
308 |
FID_GSSLibStub_pMech = |
|
309 |
(*env)->GetFieldID(env, cls, "pMech", "J"); |
|
310 |
if (FID_GSSLibStub_pMech == NULL) { |
|
311 |
printf("Couldn't find GSSLibStub.pMech field\n"); |
|
312 |
return JNI_ERR; |
|
313 |
} |
|
314 |
FID_NativeGSSContext_pContext = |
|
315 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "pContext", "J"); |
|
316 |
if (FID_NativeGSSContext_pContext == NULL) { |
|
317 |
printf("Couldn't find NativeGSSContext.pContext field\n"); |
|
318 |
return JNI_ERR; |
|
319 |
} |
|
320 |
FID_NativeGSSContext_srcName = |
|
321 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "srcName", |
|
322 |
"Lsun/security/jgss/wrapper/GSSNameElement;"); |
|
323 |
if (FID_NativeGSSContext_srcName == NULL) { |
|
324 |
printf("Couldn't find NativeGSSContext.srcName field\n"); |
|
325 |
return JNI_ERR; |
|
326 |
} |
|
327 |
FID_NativeGSSContext_targetName = |
|
328 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "targetName", |
|
329 |
"Lsun/security/jgss/wrapper/GSSNameElement;"); |
|
330 |
if (FID_NativeGSSContext_targetName == NULL) { |
|
331 |
printf("Couldn't find NativeGSSContext.targetName field\n"); |
|
332 |
return JNI_ERR; |
|
333 |
} |
|
334 |
FID_NativeGSSContext_isInitiator = |
|
335 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "isInitiator", "Z"); |
|
336 |
if (FID_NativeGSSContext_isInitiator == NULL) { |
|
337 |
printf("Couldn't find NativeGSSContext.isInitiator field\n"); |
|
338 |
return JNI_ERR; |
|
339 |
} |
|
340 |
FID_NativeGSSContext_isEstablished = |
|
341 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "isEstablished", "Z"); |
|
342 |
if (FID_NativeGSSContext_isEstablished == NULL) { |
|
343 |
printf("Couldn't find NativeGSSContext.isEstablished field\n"); |
|
344 |
return JNI_ERR; |
|
345 |
} |
|
346 |
FID_NativeGSSContext_delegatedCred = |
|
347 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "delegatedCred", |
|
348 |
"Lsun/security/jgss/wrapper/GSSCredElement;"); |
|
349 |
if (FID_NativeGSSContext_delegatedCred == NULL) { |
|
350 |
printf("Couldn't find NativeGSSContext.delegatedCred field\n"); |
|
351 |
return JNI_ERR; |
|
352 |
} |
|
353 |
FID_NativeGSSContext_flags = |
|
354 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "flags", "I"); |
|
355 |
if (FID_NativeGSSContext_flags == NULL) { |
|
356 |
printf("Couldn't find NativeGSSContext.flags field\n"); |
|
357 |
return JNI_ERR; |
|
358 |
} |
|
359 |
FID_NativeGSSContext_lifetime = |
|
360 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "lifetime", "I"); |
|
361 |
if (FID_NativeGSSContext_lifetime == NULL) { |
|
362 |
printf("Couldn't find NativeGSSContext.lifetime field\n"); |
|
363 |
return JNI_ERR; |
|
364 |
} |
|
365 |
FID_NativeGSSContext_actualMech = |
|
366 |
(*env)->GetFieldID(env, CLS_NativeGSSContext, "actualMech", |
|
367 |
"Lorg/ietf/jgss/Oid;"); |
|
368 |
if (FID_NativeGSSContext_actualMech == NULL) { |
|
369 |
printf("Couldn't find NativeGSSContext.actualMech field\n"); |
|
370 |
return JNI_ERR; |
|
371 |
} |
|
372 |
return JNI_VERSION_1_2; |
|
373 |
} |
|
374 |
||
375 |
JNIEXPORT void JNICALL |
|
376 |
JNI_OnUnload(JavaVM *jvm, void *reserved) { |
|
377 |
JNIEnv *env; |
|
378 |
||
379 |
if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) { |
|
380 |
return; |
|
381 |
} |
|
382 |
/* Delete the global refs */ |
|
383 |
(*env)->DeleteGlobalRef(env, CLS_Object); |
|
384 |
(*env)->DeleteGlobalRef(env, CLS_String); |
|
385 |
(*env)->DeleteGlobalRef(env, CLS_Oid); |
|
386 |
(*env)->DeleteGlobalRef(env, CLS_GSSException); |
|
387 |
(*env)->DeleteGlobalRef(env, CLS_GSSNameElement); |
|
388 |
(*env)->DeleteGlobalRef(env, CLS_GSSCredElement); |
|
389 |
(*env)->DeleteGlobalRef(env, CLS_SunNativeProvider); |
|
390 |
return; |
|
391 |
} |
|
392 |
||
393 |
const OM_uint32 JAVA_MAX = GSS_C_INDEFINITE/2; |
|
394 |
||
395 |
/* |
|
396 |
* Utility routine for converting the C unsigned integer time |
|
397 |
* to Java signed integer time. |
|
398 |
*/ |
|
399 |
jint getJavaTime(OM_uint32 ctime) { |
|
400 |
jint result; |
|
401 |
||
402 |
/* special handle values equals or more than JAVA_MAX */ |
|
403 |
if (ctime == GSS_C_INDEFINITE) { |
|
404 |
result = JAVA_MAX; |
|
405 |
} else if (ctime >= JAVA_MAX) { |
|
406 |
result = JAVA_MAX-1; |
|
407 |
} else { |
|
408 |
result = ctime; |
|
409 |
} |
|
410 |
return result; |
|
411 |
} |
|
412 |
/* |
|
413 |
* Utility routine for converting the Java signed integer time |
|
414 |
* to C unsigned integer time. |
|
415 |
*/ |
|
416 |
OM_uint32 getGSSTime(jint jtime) { |
|
417 |
OM_uint32 result; |
|
418 |
||
419 |
/* special handle values equal to JAVA_MAX */ |
|
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
5506
diff
changeset
|
420 |
if (jtime == (jint)JAVA_MAX) { |
2 | 421 |
result = GSS_C_INDEFINITE; |
422 |
} else { |
|
423 |
result = jtime; |
|
424 |
} |
|
425 |
return result; |
|
426 |
} |
|
427 |
/* |
|
428 |
* Utility routine for mapping the C error code to the |
|
429 |
* Java one. The routine errors really should have |
|
430 |
* shared the same values but unfortunately don't. |
|
431 |
*/ |
|
432 |
jint getJavaErrorCode(int cNonCallingErr) { |
|
433 |
int cRoutineErr, cSuppStatus; |
|
434 |
/* map the routine errors */ |
|
435 |
cRoutineErr = GSS_ROUTINE_ERROR(cNonCallingErr) >> 16; |
|
436 |
if (cRoutineErr != GSS_S_COMPLETE) { |
|
437 |
return JAVA_ERROR_CODE[cRoutineErr-1]; |
|
438 |
} |
|
439 |
/* map the supplementary infos */ |
|
440 |
cSuppStatus = GSS_SUPPLEMENTARY_INFO(cNonCallingErr); |
|
441 |
if (cSuppStatus & GSS_S_DUPLICATE_TOKEN) { |
|
442 |
return JAVA_DUPLICATE_TOKEN_CODE; |
|
443 |
} else if (cSuppStatus & GSS_S_OLD_TOKEN) { |
|
444 |
return JAVA_OLD_TOKEN_CODE; |
|
445 |
} else if (cSuppStatus & GSS_S_UNSEQ_TOKEN) { |
|
446 |
return JAVA_UNSEQ_TOKEN_CODE; |
|
447 |
} else if (cSuppStatus & GSS_S_GAP_TOKEN) { |
|
448 |
return JAVA_GAP_TOKEN_CODE; |
|
449 |
} |
|
450 |
return GSS_S_COMPLETE; |
|
451 |
} |
|
452 |
/* |
|
453 |
* Utility routine for creating a java.lang.String object |
|
454 |
* using the specified gss_buffer_t structure. After the, |
|
455 |
* String object is created, the specified gss_buffer_t |
|
456 |
* structure is released. |
|
457 |
*/ |
|
458 |
jstring getJavaString(JNIEnv *env, gss_buffer_t bytes) { |
|
459 |
jstring result; |
|
460 |
OM_uint32 minor; |
|
461 |
int len; |
|
462 |
jbyteArray jbytes; |
|
463 |
||
464 |
if (bytes != NULL) { |
|
465 |
/* constructs the String object with new String(byte[]) |
|
466 |
NOTE: do NOT include the trailing NULL */ |
|
467 |
len = bytes->length; |
|
468 |
jbytes = (*env)->NewByteArray(env, len); |
|
469 |
(*env)->SetByteArrayRegion(env, jbytes, 0, len, (jbyte *) bytes->value); |
|
470 |
result = (*env)->NewObject(env, CLS_String, MID_String_ctor, |
|
471 |
jbytes); |
|
472 |
(*env)->DeleteLocalRef(env, jbytes); |
|
473 |
(*ftab->releaseBuffer)(&minor, bytes); |
|
474 |
return result; |
|
475 |
} /* else fall through */ |
|
476 |
return NULL; |
|
477 |
} |
|
478 |
/* |
|
479 |
* Utility routine for generate message for the specified minor |
|
480 |
* status code. |
|
481 |
*/ |
|
482 |
jstring getMinorMessage(JNIEnv *env, jobject jstub, OM_uint32 statusValue) { |
|
483 |
OM_uint32 messageContext, minor, major; |
|
484 |
gss_buffer_desc statusString; |
|
485 |
gss_OID mech; |
|
486 |
jstring msg; |
|
487 |
||
488 |
messageContext = 0; |
|
489 |
if (jstub != NULL) { |
|
14414
f338be3ef659
8001579: Cleanup warnings in security native code
jzavgren
parents:
5506
diff
changeset
|
490 |
mech = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jstub, FID_GSSLibStub_pMech)); |
2 | 491 |
} else { |
492 |
mech = GSS_C_NO_OID; |
|
493 |
} |
|
494 |
/* gss_display_status(...) => GSS_S_BAD_MECH, GSS_S_BAD_STATUS */ |
|
495 |
major = (*ftab->displayStatus)(&minor, statusValue, GSS_C_MECH_CODE, mech, |
|
496 |
&messageContext, &statusString); |
|
497 |
/* release intermediate buffers */ |
|
498 |
msg = getJavaString(env, &statusString); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
499 |
if (msg == NULL && !(*env)->ExceptionCheck(env)) { |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
500 |
throwOutOfMemoryError(env, NULL); |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
501 |
} |
2 | 502 |
(*ftab->releaseBuffer)(&minor, &statusString); |
503 |
return msg; |
|
504 |
} |
|
505 |
/* |
|
506 |
* Utility routine checking the specified major and minor |
|
507 |
* status codes. GSSExceptions will be thrown if they are |
|
508 |
* not GSS_S_COMPLETE (i.e. 0). |
|
509 |
*/ |
|
510 |
void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major, |
|
511 |
OM_uint32 minor, char* methodName) { |
|
512 |
int callingErr, routineErr, supplementaryInfo; |
|
513 |
jint jmajor, jminor; |
|
514 |
char* msg; |
|
515 |
jstring jmsg; |
|
516 |
jthrowable gssEx; |
|
517 |
||
518 |
if (major == GSS_S_COMPLETE) return; |
|
519 |
||
520 |
callingErr = GSS_CALLING_ERROR(major); |
|
521 |
routineErr = GSS_ROUTINE_ERROR(major); |
|
522 |
supplementaryInfo = GSS_SUPPLEMENTARY_INFO(major); |
|
523 |
||
524 |
sprintf(debugBuf, "%s Status major/minor = %x/%d", methodName, major, minor); |
|
525 |
debug(env, debugBuf); |
|
526 |
sprintf(debugBuf, "%s Status c/r/s = %d/%d/%d ", methodName, callingErr>>24, |
|
527 |
routineErr>>16, supplementaryInfo); |
|
528 |
debug(env, debugBuf); |
|
529 |
||
530 |
jmajor = getJavaErrorCode(routineErr | supplementaryInfo); |
|
531 |
jminor = minor; |
|
532 |
if (jmajor != GSS_S_COMPLETE) { |
|
533 |
jmsg = NULL; |
|
534 |
if (minor != 0) { |
|
535 |
jmsg = getMinorMessage(env, jstub, minor); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
536 |
CHECK_NULL(jmsg); |
2 | 537 |
} |
538 |
gssEx = (*env)->NewObject(env, CLS_GSSException, |
|
539 |
MID_GSSException_ctor3, |
|
540 |
jmajor, jminor, jmsg); |
|
541 |
(*env)->Throw(env, gssEx); |
|
542 |
} else { |
|
543 |
/* Error in calling the GSS api */ |
|
544 |
if (callingErr == GSS_S_CALL_INACCESSIBLE_READ) { |
|
545 |
msg = "A required input parameter cannot be read"; |
|
546 |
} else if (callingErr == GSS_S_CALL_INACCESSIBLE_WRITE) { |
|
547 |
msg = "A required output parameter cannot be write"; |
|
548 |
} else { |
|
549 |
msg = "A parameter was malformed"; |
|
550 |
} |
|
551 |
jmajor = 13; /* use GSSException.FAILURE for now */ |
|
552 |
jmsg = (*env)->NewStringUTF(env, msg); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
553 |
CHECK_NULL(jmsg); |
2 | 554 |
gssEx = (*env)->NewObject(env, CLS_GSSException, |
555 |
MID_GSSException_ctor3, |
|
556 |
jmajor, jminor, jmsg); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
557 |
CHECK_NULL(gssEx); |
2 | 558 |
(*env)->Throw(env, gssEx); |
559 |
} |
|
560 |
} |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
561 |
|
2 | 562 |
/* |
563 |
* Utility routine for initializing gss_buffer_t structure |
|
564 |
* with the byte[] in the specified jbyteArray object. |
|
565 |
* NOTE: need to call resetGSSBuffer(...) to free up |
|
566 |
* the resources. |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
567 |
* Return JNI_TRUE if GetByteArrayElements() returns ok, JNI_FALSE otherwise |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
568 |
* If JNI_FALSE returned, then an exception has been thrown. |
2 | 569 |
*/ |
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
570 |
int initGSSBuffer(JNIEnv *env, jbyteArray jbytes, |
2 | 571 |
gss_buffer_t cbytes) { |
572 |
if (jbytes != NULL) { |
|
573 |
cbytes->length = (*env)->GetArrayLength(env, jbytes); |
|
574 |
cbytes->value = (*env)->GetByteArrayElements(env, jbytes, NULL); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
575 |
if (cbytes->value == NULL) { |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
576 |
if (!(*env)->ExceptionCheck(env)) { |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
577 |
throwOutOfMemoryError(env, NULL); |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
578 |
} |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
579 |
return JNI_FALSE; |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
580 |
} |
2 | 581 |
} else { |
582 |
cbytes->length = 0; |
|
583 |
cbytes->value = NULL; |
|
584 |
} |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
585 |
return JNI_TRUE; |
2 | 586 |
} |
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
587 |
|
2 | 588 |
/* |
589 |
* Utility routine for unpinning/releasing the byte[] |
|
590 |
* associated with the specified jbyteArray object. |
|
591 |
* NOTE: used in conjunction with initGSSBuffer(...). |
|
592 |
*/ |
|
593 |
void resetGSSBuffer(JNIEnv *env, jbyteArray jbytes, |
|
594 |
gss_buffer_t cbytes) { |
|
595 |
if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER) && |
|
596 |
(cbytes->length != 0)) { |
|
597 |
(*env)->ReleaseByteArrayElements(env, jbytes, cbytes->value, |
|
598 |
JNI_ABORT); |
|
599 |
} |
|
600 |
} |
|
601 |
/* |
|
602 |
* Utility routine for creating a jbyteArray object using |
|
603 |
* the byte[] value in specified gss_buffer_t structure. |
|
604 |
* NOTE: the specified gss_buffer_t structure will be |
|
605 |
* released in this routine. |
|
606 |
*/ |
|
607 |
jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) { |
|
608 |
jbyteArray result; |
|
609 |
OM_uint32 minor; // don't care, just so it compiles |
|
610 |
||
611 |
if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER) && |
|
612 |
(cbytes->length != 0)) { |
|
613 |
result = (*env)->NewByteArray(env, cbytes->length); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
614 |
if (result != NULL) |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
615 |
(*env)->SetByteArrayRegion(env, result, 0, cbytes->length, |
2 | 616 |
cbytes->value); |
617 |
(*ftab->releaseBuffer)(&minor, cbytes); |
|
618 |
return result; |
|
619 |
} |
|
620 |
return NULL; |
|
621 |
} |
|
622 |
||
623 |
/* |
|
624 |
* Utility routine for creating a non-mech gss_OID using |
|
625 |
* the specified org.ietf.jgss.Oid object. |
|
626 |
* NOTE: need to call deleteGSSOID(...) afterwards to |
|
627 |
* release the created gss_OID structure. |
|
628 |
*/ |
|
629 |
gss_OID newGSSOID(JNIEnv *env, jobject jOid) { |
|
630 |
jbyteArray jbytes; |
|
631 |
gss_OID cOid; |
|
632 |
jthrowable gssEx; |
|
633 |
if (jOid != NULL) { |
|
634 |
jbytes = (*env)->CallObjectMethod(env, jOid, MID_Oid_getDER); |
|
635 |
if ((*env)->ExceptionCheck(env)) { |
|
636 |
gssEx = (*env)->ExceptionOccurred(env); |
|
637 |
(*env)->Throw(env, gssEx); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
638 |
return GSS_C_NO_OID; |
2 | 639 |
} |
640 |
cOid = malloc(sizeof(struct gss_OID_desc_struct)); |
|
16488
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
641 |
if (cOid == NULL) { |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
642 |
throwOutOfMemoryError(env,NULL); |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
643 |
return GSS_C_NO_OID; |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
644 |
} |
2 | 645 |
cOid->length = (*env)->GetArrayLength(env, jbytes) - 2; |
646 |
cOid->elements = malloc(cOid->length); |
|
16488
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
647 |
if (cOid->elements == NULL) { |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
648 |
throwOutOfMemoryError(env,NULL); |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
649 |
free(cOid); |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
650 |
return GSS_C_NO_OID; |
816b9df68a9f
8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents:
14414
diff
changeset
|
651 |
} |
2 | 652 |
(*env)->GetByteArrayRegion(env, jbytes, 2, cOid->length, |
653 |
cOid->elements); |
|
654 |
(*env)->DeleteLocalRef(env, jbytes); |
|
655 |
return cOid; |
|
656 |
} else { |
|
657 |
return GSS_C_NO_OID; |
|
658 |
} |
|
659 |
} |
|
660 |
/* |
|
661 |
* Utility routine for releasing the specified gss_OID |
|
662 |
* structure. |
|
663 |
* NOTE: used in conjunction with newGSSOID(...). |
|
664 |
*/ |
|
665 |
void deleteGSSOID(gss_OID oid) { |
|
666 |
if (oid != GSS_C_NO_OID) { |
|
667 |
free(oid->elements); |
|
668 |
free(oid); |
|
669 |
} |
|
670 |
} |
|
671 |
/* |
|
672 |
* Utility routine for creating a org.ietf.jgss.Oid |
|
673 |
* object using the specified gss_OID structure. |
|
674 |
*/ |
|
675 |
jobject getJavaOID(JNIEnv *env, gss_OID cOid) { |
|
676 |
int cLen; |
|
677 |
char oidHdr[2]; |
|
678 |
jbyteArray jbytes; |
|
679 |
jobject result; |
|
680 |
||
681 |
if ((cOid == NULL) || (cOid == GSS_C_NO_OID)) { |
|
682 |
return NULL; |
|
683 |
} |
|
684 |
cLen = cOid->length; |
|
685 |
oidHdr[0] = 6; |
|
686 |
oidHdr[1] = cLen; |
|
687 |
jbytes = (*env)->NewByteArray(env, cLen+2); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
688 |
CHECK_NULL_RETURN(jbytes, NULL); |
2 | 689 |
(*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr); |
690 |
(*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements); |
|
691 |
||
692 |
result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
693 |
JNU_CHECK_EXCEPTION_RETURN(env, NULL); |
2 | 694 |
(*env)->DeleteLocalRef(env, jbytes); |
695 |
return result; |
|
696 |
} |
|
697 |
/* |
|
698 |
* Utility routine for creating a gss_OID_set structure |
|
699 |
* using the specified gss_OID. |
|
700 |
* NOTE: need to call deleteGSSOIDSet(...) afterwards |
|
701 |
* to release the created gss_OID_set structure. |
|
702 |
*/ |
|
703 |
gss_OID_set newGSSOIDSet(JNIEnv *env, gss_OID oid) { |
|
704 |
gss_OID_set oidSet; |
|
705 |
OM_uint32 minor; // don't care; just so it compiles |
|
706 |
||
707 |
if (oid->length != 6 || |
|
708 |
memcmp(oid->elements, SPNEGO_BYTES, 6) != 0) { |
|
709 |
(*ftab->createEmptyOidSet)(&minor, &oidSet); |
|
710 |
(*ftab->addOidSetMember)(&minor, oid, &oidSet); |
|
711 |
return oidSet; |
|
712 |
} else { |
|
713 |
// Use all mechs for SPNEGO in order to work with |
|
714 |
// various native GSS impls |
|
715 |
return (ftab->mechs); |
|
716 |
} |
|
717 |
} |
|
718 |
/* |
|
719 |
* Utility routine for releasing a gss_OID_set structure. |
|
720 |
* NOTE: used in conjunction with newGSSOIDSet(...). |
|
721 |
*/ |
|
722 |
void deleteGSSOIDSet(gss_OID_set oidSet) { |
|
723 |
OM_uint32 minor; /* don't care; just so it compiles */ |
|
724 |
||
725 |
if ((oidSet != ftab->mechs) && |
|
726 |
(oidSet != NULL) && (oidSet != GSS_C_NO_OID_SET)) { |
|
727 |
(*ftab->releaseOidSet)(&minor, &oidSet); |
|
728 |
} |
|
729 |
} |
|
730 |
/* |
|
731 |
* Utility routine for creating a org.ietf.jgss.Oid[] |
|
732 |
* using the specified gss_OID_set structure. |
|
733 |
*/ |
|
734 |
jobjectArray getJavaOIDArray(JNIEnv *env, gss_OID_set cOidSet) { |
|
735 |
int numOfOids = 0; |
|
736 |
jobjectArray jOidSet; |
|
737 |
jobject jOid; |
|
738 |
int i; |
|
739 |
jthrowable gssEx; |
|
740 |
||
741 |
if (cOidSet != NULL && cOidSet != GSS_C_NO_OID_SET) { |
|
742 |
numOfOids = cOidSet->count; |
|
743 |
jOidSet = (*env)->NewObjectArray(env, numOfOids, CLS_Oid, NULL); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
744 |
if (jOidSet == NULL) { |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
745 |
return NULL; |
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
746 |
} |
2 | 747 |
if (jOidSet != NULL) { |
748 |
for (i = 0; i < numOfOids; i++) { |
|
749 |
jOid = getJavaOID(env, &(cOidSet->elements[i])); |
|
750 |
(*env)->SetObjectArrayElement(env, jOidSet, i, jOid); |
|
751 |
(*env)->DeleteLocalRef(env, jOid); |
|
752 |
} |
|
753 |
} |
|
754 |
return jOidSet; |
|
755 |
} |
|
756 |
return NULL; |
|
757 |
} |
|
758 |
||
759 |
void debug(JNIEnv *env, char *msg) { |
|
760 |
jstring jmsg = (*env)->NewStringUTF(env, msg); |
|
22940
56b3ab8ec81c
8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents:
16488
diff
changeset
|
761 |
CHECK_NULL(jmsg); |
2 | 762 |
(*env)->CallStaticVoidMethod(env, CLS_SunNativeProvider, |
763 |
MID_SunNativeProvider_debug, jmsg); |
|
764 |
(*env)->DeleteLocalRef(env, jmsg); |
|
765 |
} |
|
766 |
||
767 |
int sameMech(JNIEnv *env, gss_OID mech, gss_OID mech2) { |
|
768 |
int result = JNI_FALSE; // default to not equal |
|
769 |
||
770 |
if (mech->length == mech2->length) { |
|
771 |
result = (memcmp(mech->elements, mech2->elements, mech->length) == 0); |
|
772 |
} |
|
773 |
return result; |
|
774 |
} |