提交 db2ae416 编写于 作者: V valeriep

8031003: [Parfait] warnings from...

8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
Summary: Fixed various JNI exception pending warnings
Reviewed-by: weijun
上级 b05e2d58
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -48,10 +48,11 @@ class GSSLibStub { ...@@ -48,10 +48,11 @@ class GSSLibStub {
/** /**
* Initialization routine to dynamically load function pointers. * Initialization routine to dynamically load function pointers.
* *
* @param library name to dlopen * @param lib library name to dlopen
* @param debug set to true for reporting native debugging info
* @return true if succeeded, false otherwise. * @return true if succeeded, false otherwise.
*/ */
static native boolean init(String lib); static native boolean init(String lib, boolean debug);
private static native long getMechPtr(byte[] oidDerEncoding); private static native long getMechPtr(byte[] oidDerEncoding);
// Miscellaneous routines // Miscellaneous routines
......
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -100,7 +100,7 @@ public final class SunNativeProvider extends Provider { ...@@ -100,7 +100,7 @@ public final class SunNativeProvider extends Provider {
gssLibs = new String[]{ defaultLib }; gssLibs = new String[]{ defaultLib };
} }
for (String libName: gssLibs) { for (String libName: gssLibs) {
if (GSSLibStub.init(libName)) { if (GSSLibStub.init(libName, DEBUG)) {
debug("Loaded GSS library: " + libName); debug("Loaded GSS library: " + libName);
Oid[] mechs = GSSLibStub.indicateMechs(); Oid[] mechs = GSSLibStub.indicateMechs();
HashMap<String, String> map = HashMap<String, String> map =
......
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#include "jlong.h" #include "jlong.h"
#include <jni.h> #include <jni.h>
extern void throwOutOfMemoryError(JNIEnv *env, const char *message);
const int JAVA_DUPLICATE_TOKEN_CODE = 19; /* DUPLICATE_TOKEN */ const int JAVA_DUPLICATE_TOKEN_CODE = 19; /* DUPLICATE_TOKEN */
const int JAVA_OLD_TOKEN_CODE = 20; /* OLD_TOKEN */ const int JAVA_OLD_TOKEN_CODE = 20; /* OLD_TOKEN */
const int JAVA_UNSEQ_TOKEN_CODE = 21; /* UNSEQ_TOKEN */ const int JAVA_UNSEQ_TOKEN_CODE = 21; /* UNSEQ_TOKEN */
...@@ -82,7 +80,6 @@ jmethodID MID_InetAddress_getAddr; ...@@ -82,7 +80,6 @@ jmethodID MID_InetAddress_getAddr;
jmethodID MID_GSSNameElement_ctor; jmethodID MID_GSSNameElement_ctor;
jmethodID MID_GSSCredElement_ctor; jmethodID MID_GSSCredElement_ctor;
jmethodID MID_NativeGSSContext_ctor; jmethodID MID_NativeGSSContext_ctor;
jmethodID MID_SunNativeProvider_debug;
jfieldID FID_GSSLibStub_pMech; jfieldID FID_GSSLibStub_pMech;
jfieldID FID_NativeGSSContext_pContext; jfieldID FID_NativeGSSContext_pContext;
jfieldID FID_NativeGSSContext_srcName; jfieldID FID_NativeGSSContext_srcName;
...@@ -93,7 +90,8 @@ jfieldID FID_NativeGSSContext_delegatedCred; ...@@ -93,7 +90,8 @@ jfieldID FID_NativeGSSContext_delegatedCred;
jfieldID FID_NativeGSSContext_flags; jfieldID FID_NativeGSSContext_flags;
jfieldID FID_NativeGSSContext_lifetime; jfieldID FID_NativeGSSContext_lifetime;
jfieldID FID_NativeGSSContext_actualMech; jfieldID FID_NativeGSSContext_actualMech;
char debugBuf[256];
int JGSS_DEBUG;
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *jvm, void *reserved) { JNI_OnLoad(JavaVM *jvm, void *reserved) {
...@@ -291,13 +289,6 @@ JNI_OnLoad(JavaVM *jvm, void *reserved) { ...@@ -291,13 +289,6 @@ JNI_OnLoad(JavaVM *jvm, void *reserved) {
printf("Couldn't find NativeGSSContext(long, GSSLibStub) constructor\n"); printf("Couldn't find NativeGSSContext(long, GSSLibStub) constructor\n");
return JNI_ERR; return JNI_ERR;
} }
MID_SunNativeProvider_debug =
(*env)->GetStaticMethodID(env, CLS_SunNativeProvider, "debug",
"(Ljava/lang/String;)V");
if (MID_SunNativeProvider_debug == NULL) {
printf("Couldn't find SunNativeProvider.debug(String) method\n");
return JNI_ERR;
}
/* Compute and cache the field ID */ /* Compute and cache the field ID */
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSLibStub"); cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSLibStub");
if (cls == NULL) { if (cls == NULL) {
...@@ -448,14 +439,28 @@ jint getJavaErrorCode(int cNonCallingErr) { ...@@ -448,14 +439,28 @@ jint getJavaErrorCode(int cNonCallingErr) {
} }
return GSS_S_COMPLETE; return GSS_S_COMPLETE;
} }
/* Throws a Java Exception by name */
void throwByName(JNIEnv *env, const char *name, const char *msg) {
jclass cls = (*env)->FindClass(env, name);
if (cls != NULL) {
(*env)->ThrowNew(env, cls, msg);
}
}
void throwOutOfMemoryError(JNIEnv *env, const char *message) {
throwByName(env, "java/lang/OutOfMemoryError", message);
}
/* /*
* Utility routine for creating a java.lang.String object * Utility routine for creating a java.lang.String object
* using the specified gss_buffer_t structure. After the, * using the specified gss_buffer_t structure. The specified
* String object is created, the specified gss_buffer_t * gss_buffer_t structure is always released.
* structure is released.
*/ */
jstring getJavaString(JNIEnv *env, gss_buffer_t bytes) { jstring getJavaString(JNIEnv *env, gss_buffer_t bytes) {
jstring result; jstring result = NULL;
OM_uint32 minor; OM_uint32 minor;
int len; int len;
jbyteArray jbytes; jbyteArray jbytes;
...@@ -465,9 +470,18 @@ jstring getJavaString(JNIEnv *env, gss_buffer_t bytes) { ...@@ -465,9 +470,18 @@ jstring getJavaString(JNIEnv *env, gss_buffer_t bytes) {
NOTE: do NOT include the trailing NULL */ NOTE: do NOT include the trailing NULL */
len = bytes->length; len = bytes->length;
jbytes = (*env)->NewByteArray(env, len); jbytes = (*env)->NewByteArray(env, len);
if (jbytes == NULL) {
goto finish;
}
(*env)->SetByteArrayRegion(env, jbytes, 0, len, (jbyte *) bytes->value); (*env)->SetByteArrayRegion(env, jbytes, 0, len, (jbyte *) bytes->value);
if ((*env)->ExceptionCheck(env)) {
goto finish;
}
result = (*env)->NewObject(env, CLS_String, MID_String_ctor, result = (*env)->NewObject(env, CLS_String, MID_String_ctor,
jbytes); jbytes);
finish:
(*env)->DeleteLocalRef(env, jbytes); (*env)->DeleteLocalRef(env, jbytes);
(*ftab->releaseBuffer)(&minor, bytes); (*ftab->releaseBuffer)(&minor, bytes);
return result; return result;
...@@ -490,14 +504,15 @@ jstring getMinorMessage(JNIEnv *env, jobject jstub, OM_uint32 statusValue) { ...@@ -490,14 +504,15 @@ jstring getMinorMessage(JNIEnv *env, jobject jstub, OM_uint32 statusValue) {
} else { } else {
mech = GSS_C_NO_OID; mech = GSS_C_NO_OID;
} }
/* gss_display_status(...) => GSS_S_BAD_MECH, GSS_S_BAD_STATUS */ /* gss_display_status(...) => GSS_S_BAD_MECH, GSS_S_BAD_STATUS */
// TBD: check messageContext value and repeat the call if necessary
major = (*ftab->displayStatus)(&minor, statusValue, GSS_C_MECH_CODE, mech, major = (*ftab->displayStatus)(&minor, statusValue, GSS_C_MECH_CODE, mech,
&messageContext, &statusString); &messageContext, &statusString);
/* release intermediate buffers */
msg = getJavaString(env, &statusString); return getJavaString(env, &statusString);
(*ftab->releaseBuffer)(&minor, &statusString);
return msg;
} }
/* /*
* Utility routine checking the specified major and minor * Utility routine checking the specified major and minor
* status codes. GSSExceptions will be thrown if they are * status codes. GSSExceptions will be thrown if they are
...@@ -517,11 +532,9 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major, ...@@ -517,11 +532,9 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major,
routineErr = GSS_ROUTINE_ERROR(major); routineErr = GSS_ROUTINE_ERROR(major);
supplementaryInfo = GSS_SUPPLEMENTARY_INFO(major); supplementaryInfo = GSS_SUPPLEMENTARY_INFO(major);
sprintf(debugBuf, "%s Status major/minor = %x/%d", methodName, major, minor); TRACE3("%s Status major/minor = %x/%d", methodName, major, minor);
debug(env, debugBuf); TRACE3("c/r/s = %d/%d/%d ", callingErr>>24, routineErr>>16,
sprintf(debugBuf, "%s Status c/r/s = %d/%d/%d ", methodName, callingErr>>24, supplementaryInfo);
routineErr>>16, supplementaryInfo);
debug(env, debugBuf);
jmajor = getJavaErrorCode(routineErr | supplementaryInfo); jmajor = getJavaErrorCode(routineErr | supplementaryInfo);
jminor = minor; jminor = minor;
...@@ -529,11 +542,17 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major, ...@@ -529,11 +542,17 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major,
jmsg = NULL; jmsg = NULL;
if (minor != 0) { if (minor != 0) {
jmsg = getMinorMessage(env, jstub, minor); jmsg = getMinorMessage(env, jstub, minor);
if ((*env)->ExceptionCheck(env)) {
return;
}
} }
gssEx = (*env)->NewObject(env, CLS_GSSException, gssEx = (*env)->NewObject(env, CLS_GSSException,
MID_GSSException_ctor3, MID_GSSException_ctor3,
jmajor, jminor, jmsg); jmajor, jminor, jmsg);
if (gssEx != NULL) {
(*env)->Throw(env, gssEx); (*env)->Throw(env, gssEx);
}
} else { } else {
/* Error in calling the GSS api */ /* Error in calling the GSS api */
if (callingErr == GSS_S_CALL_INACCESSIBLE_READ) { if (callingErr == GSS_S_CALL_INACCESSIBLE_READ) {
...@@ -545,56 +564,88 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major, ...@@ -545,56 +564,88 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major,
} }
jmajor = 13; /* use GSSException.FAILURE for now */ jmajor = 13; /* use GSSException.FAILURE for now */
jmsg = (*env)->NewStringUTF(env, msg); jmsg = (*env)->NewStringUTF(env, msg);
if (jmsg == NULL) {
return;
}
gssEx = (*env)->NewObject(env, CLS_GSSException, gssEx = (*env)->NewObject(env, CLS_GSSException,
MID_GSSException_ctor3, MID_GSSException_ctor3,
jmajor, jminor, jmsg); jmajor, jminor, jmsg);
if (gssEx != NULL) {
(*env)->Throw(env, gssEx); (*env)->Throw(env, gssEx);
} }
}
} }
/* /*
* Utility routine for initializing gss_buffer_t structure * Utility routine for initializing gss_buffer_t structure
* with the byte[] in the specified jbyteArray object. * with the byte[] in the specified jbyteArray object.
* NOTE: need to call resetGSSBuffer(...) to free up * NOTE: must call resetGSSBuffer() to free up the resources
* the resources. * inside the gss_buffer_t structure.
*/ */
void initGSSBuffer(JNIEnv *env, jbyteArray jbytes, void initGSSBuffer(JNIEnv *env, jbyteArray jbytes,
gss_buffer_t cbytes) { gss_buffer_t cbytes) {
int len;
void* value;
if (jbytes != NULL) { if (jbytes != NULL) {
cbytes->length = (*env)->GetArrayLength(env, jbytes); len = (*env)->GetArrayLength(env, jbytes);
cbytes->value = (*env)->GetByteArrayElements(env, jbytes, NULL); value = malloc(len);
if (value == NULL) {
throwOutOfMemoryError(env, NULL);
return;
} else {
(*env)->GetByteArrayRegion(env, jbytes, 0, len, value);
if ((*env)->ExceptionCheck(env)) {
free(value);
return;
} else {
cbytes->length = len;
cbytes->value = value;
}
}
} else { } else {
cbytes->length = 0; cbytes->length = 0;
cbytes->value = NULL; cbytes->value = NULL;
} }
} }
/* /*
* Utility routine for unpinning/releasing the byte[] * Utility routine for freeing the bytes malloc'ed
* associated with the specified jbyteArray object. * in initGSSBuffer() method.
* NOTE: used in conjunction with initGSSBuffer(...). * NOTE: used in conjunction with initGSSBuffer(...).
*/ */
void resetGSSBuffer(JNIEnv *env, jbyteArray jbytes, void resetGSSBuffer(gss_buffer_t cbytes) {
gss_buffer_t cbytes) { if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER)) {
if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER) && free(cbytes->value);
(cbytes->length != 0)) { cbytes->length = 0;
(*env)->ReleaseByteArrayElements(env, jbytes, cbytes->value, cbytes->value = NULL;
JNI_ABORT);
} }
} }
/* /*
* Utility routine for creating a jbyteArray object using * Utility routine for creating a jbyteArray object using
* the byte[] value in specified gss_buffer_t structure. * the byte[] value in specified gss_buffer_t structure.
* NOTE: the specified gss_buffer_t structure will be * NOTE: the specified gss_buffer_t structure is always
* released in this routine. * released.
*/ */
jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) { jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) {
jbyteArray result; jbyteArray result = NULL;
OM_uint32 minor; // don't care, just so it compiles OM_uint32 minor; // don't care, just so it compiles
if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER) && if (cbytes != NULL) {
(cbytes->length != 0)) { if ((cbytes != GSS_C_NO_BUFFER) && (cbytes->length != 0)) {
result = (*env)->NewByteArray(env, cbytes->length); result = (*env)->NewByteArray(env, cbytes->length);
if (result == NULL) {
goto finish;
}
(*env)->SetByteArrayRegion(env, result, 0, cbytes->length, (*env)->SetByteArrayRegion(env, result, 0, cbytes->length,
cbytes->value); cbytes->value);
if ((*env)->ExceptionCheck(env)) {
result = NULL;
}
}
finish:
(*ftab->releaseBuffer)(&minor, cbytes); (*ftab->releaseBuffer)(&minor, cbytes);
return result; return result;
} }
...@@ -604,8 +655,7 @@ jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) { ...@@ -604,8 +655,7 @@ jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) {
/* /*
* Utility routine for creating a non-mech gss_OID using * Utility routine for creating a non-mech gss_OID using
* the specified org.ietf.jgss.Oid object. * the specified org.ietf.jgss.Oid object.
* NOTE: need to call deleteGSSOID(...) afterwards to * NOTE: must call deleteGSSOID(...) to free up the gss_OID.
* release the created gss_OID structure.
*/ */
gss_OID newGSSOID(JNIEnv *env, jobject jOid) { gss_OID newGSSOID(JNIEnv *env, jobject jOid) {
jbyteArray jbytes; jbyteArray jbytes;
...@@ -614,8 +664,7 @@ gss_OID newGSSOID(JNIEnv *env, jobject jOid) { ...@@ -614,8 +664,7 @@ gss_OID newGSSOID(JNIEnv *env, jobject jOid) {
if (jOid != NULL) { if (jOid != NULL) {
jbytes = (*env)->CallObjectMethod(env, jOid, MID_Oid_getDER); jbytes = (*env)->CallObjectMethod(env, jOid, MID_Oid_getDER);
if ((*env)->ExceptionCheck(env)) { if ((*env)->ExceptionCheck(env)) {
gssEx = (*env)->ExceptionOccurred(env); return GSS_C_NO_OID;
(*env)->Throw(env, gssEx);
} }
cOid = malloc(sizeof(struct gss_OID_desc_struct)); cOid = malloc(sizeof(struct gss_OID_desc_struct));
if (cOid == NULL) { if (cOid == NULL) {
...@@ -626,17 +675,24 @@ gss_OID newGSSOID(JNIEnv *env, jobject jOid) { ...@@ -626,17 +675,24 @@ gss_OID newGSSOID(JNIEnv *env, jobject jOid) {
cOid->elements = malloc(cOid->length); cOid->elements = malloc(cOid->length);
if (cOid->elements == NULL) { if (cOid->elements == NULL) {
throwOutOfMemoryError(env,NULL); throwOutOfMemoryError(env,NULL);
free(cOid); goto cleanup;
return GSS_C_NO_OID;
} }
(*env)->GetByteArrayRegion(env, jbytes, 2, cOid->length, (*env)->GetByteArrayRegion(env, jbytes, 2, cOid->length,
cOid->elements); cOid->elements);
(*env)->DeleteLocalRef(env, jbytes); if ((*env)->ExceptionCheck(env)) {
goto cleanup;
}
return cOid; return cOid;
} else { } else {
return GSS_C_NO_OID; return GSS_C_NO_OID;
} }
cleanup:
(*env)->DeleteLocalRef(env, jbytes);
free(cOid->elements);
free(cOid);
return GSS_C_NO_OID;
} }
/* /*
* Utility routine for releasing the specified gss_OID * Utility routine for releasing the specified gss_OID
* structure. * structure.
...@@ -648,6 +704,7 @@ void deleteGSSOID(gss_OID oid) { ...@@ -648,6 +704,7 @@ void deleteGSSOID(gss_OID oid) {
free(oid); free(oid);
} }
} }
/* /*
* Utility routine for creating a org.ietf.jgss.Oid * Utility routine for creating a org.ietf.jgss.Oid
* object using the specified gss_OID structure. * object using the specified gss_OID structure.
...@@ -656,7 +713,7 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) { ...@@ -656,7 +713,7 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) {
int cLen; int cLen;
char oidHdr[2]; char oidHdr[2];
jbyteArray jbytes; jbyteArray jbytes;
jobject result; jobject result = NULL;
if ((cOid == NULL) || (cOid == GSS_C_NO_OID)) { if ((cOid == NULL) || (cOid == GSS_C_NO_OID)) {
return NULL; return NULL;
...@@ -665,12 +722,20 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) { ...@@ -665,12 +722,20 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) {
oidHdr[0] = 6; oidHdr[0] = 6;
oidHdr[1] = cLen; oidHdr[1] = cLen;
jbytes = (*env)->NewByteArray(env, cLen+2); jbytes = (*env)->NewByteArray(env, cLen+2);
if (jbytes == NULL) {
return NULL;
}
(*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr); (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
(*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements); (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes); result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes);
if ((*env)->ExceptionCheck(env)) { if ((*env)->ExceptionCheck(env)) {
(*env)->Throw(env, (*env)->ExceptionOccurred(env)); return NULL;
} }
(*env)->DeleteLocalRef(env, jbytes); (*env)->DeleteLocalRef(env, jbytes);
return result; return result;
...@@ -681,7 +746,7 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) { ...@@ -681,7 +746,7 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) {
* NOTE: need to call deleteGSSOIDSet(...) afterwards * NOTE: need to call deleteGSSOIDSet(...) afterwards
* to release the created gss_OID_set structure. * to release the created gss_OID_set structure.
*/ */
gss_OID_set newGSSOIDSet(JNIEnv *env, gss_OID oid) { gss_OID_set newGSSOIDSet(gss_OID oid) {
gss_OID_set oidSet; gss_OID_set oidSet;
OM_uint32 minor; // don't care; just so it compiles OM_uint32 minor; // don't care; just so it compiles
...@@ -722,26 +787,26 @@ jobjectArray getJavaOIDArray(JNIEnv *env, gss_OID_set cOidSet) { ...@@ -722,26 +787,26 @@ jobjectArray getJavaOIDArray(JNIEnv *env, gss_OID_set cOidSet) {
if (cOidSet != NULL && cOidSet != GSS_C_NO_OID_SET) { if (cOidSet != NULL && cOidSet != GSS_C_NO_OID_SET) {
numOfOids = cOidSet->count; numOfOids = cOidSet->count;
jOidSet = (*env)->NewObjectArray(env, numOfOids, CLS_Oid, NULL); jOidSet = (*env)->NewObjectArray(env, numOfOids, CLS_Oid, NULL);
if (jOidSet != NULL) { if ((*env)->ExceptionCheck(env)) {
return NULL;
}
for (i = 0; i < numOfOids; i++) { for (i = 0; i < numOfOids; i++) {
jOid = getJavaOID(env, &(cOidSet->elements[i])); jOid = getJavaOID(env, &(cOidSet->elements[i]));
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
(*env)->SetObjectArrayElement(env, jOidSet, i, jOid); (*env)->SetObjectArrayElement(env, jOidSet, i, jOid);
(*env)->DeleteLocalRef(env, jOid); if ((*env)->ExceptionCheck(env)) {
return NULL;
} }
(*env)->DeleteLocalRef(env, jOid);
} }
return jOidSet; return jOidSet;
} }
return NULL; return NULL;
} }
void debug(JNIEnv *env, char *msg) { int sameMech(gss_OID mech, gss_OID mech2) {
jstring jmsg = (*env)->NewStringUTF(env, msg);
(*env)->CallStaticVoidMethod(env, CLS_SunNativeProvider,
MID_SunNativeProvider_debug, jmsg);
(*env)->DeleteLocalRef(env, jmsg);
}
int sameMech(JNIEnv *env, gss_OID mech, gss_OID mech2) {
int result = JNI_FALSE; // default to not equal int result = JNI_FALSE; // default to not equal
if (mech->length == mech2->length) { if (mech->length == mech2->length) {
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -37,12 +37,13 @@ extern "C" { ...@@ -37,12 +37,13 @@ extern "C" {
extern OM_uint32 getGSSTime(jint); extern OM_uint32 getGSSTime(jint);
extern void checkStatus(JNIEnv *, jobject, OM_uint32, OM_uint32, char*); extern void checkStatus(JNIEnv *, jobject, OM_uint32, OM_uint32, char*);
extern jint checkTime(OM_uint32); extern jint checkTime(OM_uint32);
extern void throwOutOfMemoryError(JNIEnv *, const char*);
extern void initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t); extern void initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t);
extern void resetGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t); extern void resetGSSBuffer(gss_buffer_t);
extern gss_OID newGSSOID(JNIEnv *, jobject); extern gss_OID newGSSOID(JNIEnv *, jobject);
extern void deleteGSSOID(gss_OID); extern void deleteGSSOID(gss_OID);
extern gss_OID_set newGSSOIDSet(JNIEnv *, gss_OID); extern gss_OID_set newGSSOIDSet(gss_OID);
extern void deleteGSSOIDSet(gss_OID_set); extern void deleteGSSOIDSet(gss_OID_set);
extern jbyteArray getJavaBuffer(JNIEnv *, gss_buffer_t); extern jbyteArray getJavaBuffer(JNIEnv *, gss_buffer_t);
...@@ -51,13 +52,12 @@ extern "C" { ...@@ -51,13 +52,12 @@ extern "C" {
extern jobjectArray getJavaOIDArray(JNIEnv *, gss_OID_set); extern jobjectArray getJavaOIDArray(JNIEnv *, gss_OID_set);
extern jstring getMinorMessage(JNIEnv *, jobject, OM_uint32); extern jstring getMinorMessage(JNIEnv *, jobject, OM_uint32);
extern void debug(JNIEnv *, char *); extern int sameMech(gss_OID, gss_OID);
extern int sameMech(JNIEnv *, gss_OID, gss_OID);
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *, void *); JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *, void *);
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *, void *); JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *, void *);
extern char debugBuf[]; extern int JGSS_DEBUG;
extern jclass CLS_Object; extern jclass CLS_Object;
extern jclass CLS_GSSNameElement; extern jclass CLS_GSSNameElement;
...@@ -85,6 +85,12 @@ extern "C" { ...@@ -85,6 +85,12 @@ extern "C" {
extern jfieldID FID_NativeGSSContext_flags; extern jfieldID FID_NativeGSSContext_flags;
extern jfieldID FID_NativeGSSContext_lifetime; extern jfieldID FID_NativeGSSContext_lifetime;
extern jfieldID FID_NativeGSSContext_actualMech; extern jfieldID FID_NativeGSSContext_actualMech;
#define TRACE0(s) { if (JGSS_DEBUG) { puts(s); fflush(stdout); }}
#define TRACE1(s, p1) { if (JGSS_DEBUG) { printf(s, p1); fflush(stdout); }}
#define TRACE2(s, p1, p2) { if (JGSS_DEBUG) { printf(s, p1, p2); fflush(stdout); }}
#define TRACE3(s, p1, p2, p3) { if (JGSS_DEBUG) { printf(s, p1, p2, p3); fflush(stdout); }}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册