8187443: Forest Consolidation: Move files to unified layout

Reviewed-by: darcy, ihse
This commit is contained in:
Erik Joelsson 2017-09-12 19:03:39 +02:00
parent 270fe13182
commit 3789983e89
56923 changed files with 3 additions and 15727 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,817 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "NativeUtil.h"
#include "NativeFunc.h"
#include "jlong.h"
#include <jni.h>
#include "jni_util.h"
const int JAVA_DUPLICATE_TOKEN_CODE = 19; /* DUPLICATE_TOKEN */
const int JAVA_OLD_TOKEN_CODE = 20; /* OLD_TOKEN */
const int JAVA_UNSEQ_TOKEN_CODE = 21; /* UNSEQ_TOKEN */
const int JAVA_GAP_TOKEN_CODE = 22; /* GAP_TOKEN */
const int JAVA_ERROR_CODE[] = {
2, /* BAD_MECH */
3, /* BAD_NAME */
4, /* BAD_NAMETYPE */
1, /* BAD_BINDINGS */
5, /* BAD_STATUS */
6, /* BAD_MIC */
13, /* NO_CRED */
12, /* NO_CONTEXT */
10, /* DEFECTIVE_TOKEN */
9, /* DEFECTIVE_CREDENTIAL */
8, /* CREDENTIAL_EXPIRED */
7, /* CONTEXT_EXPIRED */
11, /* FAILURE */
14, /* BAD_QOP */
15, /* UNAUTHORIZED */
16, /* UNAVAILABLE */
17, /* DUPLICATE_ELEMENT */
18, /* NAME_NOT_MN */
};
const char SPNEGO_BYTES[] = {
0x2b, 0x06, 0x01, 0x05, 0x05, 0x02
};
jclass CLS_Object;
jclass CLS_String;
jclass CLS_Oid;
jclass CLS_GSSException;
jclass CLS_GSSNameElement;
jclass CLS_GSSCredElement;
jclass CLS_NativeGSSContext;
jclass CLS_SunNativeProvider;
jmethodID MID_String_ctor;
jmethodID MID_Oid_ctor1;
jmethodID MID_Oid_getDER;
jmethodID MID_MessageProp_getPrivacy;
jmethodID MID_MessageProp_getQOP;
jmethodID MID_MessageProp_setPrivacy;
jmethodID MID_MessageProp_setQOP;
jmethodID MID_MessageProp_setSupplementaryStates;
jmethodID MID_GSSException_ctor3;
jmethodID MID_ChannelBinding_getInitiatorAddr;
jmethodID MID_ChannelBinding_getAcceptorAddr;
jmethodID MID_ChannelBinding_getAppData;
jmethodID MID_InetAddress_getAddr;
jmethodID MID_GSSNameElement_ctor;
jmethodID MID_GSSCredElement_ctor;
jmethodID MID_NativeGSSContext_ctor;
jfieldID FID_GSSLibStub_pMech;
jfieldID FID_NativeGSSContext_pContext;
jfieldID FID_NativeGSSContext_srcName;
jfieldID FID_NativeGSSContext_targetName;
jfieldID FID_NativeGSSContext_isInitiator;
jfieldID FID_NativeGSSContext_isEstablished;
jfieldID FID_NativeGSSContext_delegatedCred;
jfieldID FID_NativeGSSContext_flags;
jfieldID FID_NativeGSSContext_lifetime;
jfieldID FID_NativeGSSContext_actualMech;
int JGSS_DEBUG;
JNIEXPORT jint JNICALL
DEF_JNI_OnLoad(JavaVM *jvm, void *reserved) {
JNIEnv *env;
jclass cls;
if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) {
return JNI_EVERSION; /* JNI version not supported */
}
/* Retrieve and store the classes in global ref */
cls = (*env)->FindClass(env, "java/lang/Object");
if (cls == NULL) {
printf("Couldn't find Object class\n");
return JNI_ERR;
}
CLS_Object = (*env)->NewGlobalRef(env, cls);
if (CLS_Object == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "java/lang/String");
if (cls == NULL) {
printf("Couldn't find String class\n");
return JNI_ERR;
}
CLS_String = (*env)->NewGlobalRef(env, cls);
if (CLS_String == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "org/ietf/jgss/Oid");
if (cls == NULL) {
printf("Couldn't find org.ietf.jgss.Oid class\n");
return JNI_ERR;
}
CLS_Oid = (*env)->NewGlobalRef(env, cls);
if (CLS_Oid == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "org/ietf/jgss/GSSException");
if (cls == NULL) {
printf("Couldn't find org.ietf.jgss.GSSException class\n");
return JNI_ERR;
}
CLS_GSSException = (*env)->NewGlobalRef(env, cls);
if (CLS_GSSException == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSNameElement");
if (cls == NULL) {
printf("Couldn't find sun.security.jgss.wrapper.GSSNameElement class\n");
return JNI_ERR;
}
CLS_GSSNameElement = (*env)->NewGlobalRef(env, cls);
if (CLS_GSSException == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSCredElement");
if (cls == NULL) {
printf("Couldn't find sun.security.jgss.wrapper.GSSCredElement class\n");
return JNI_ERR;
}
CLS_GSSCredElement = (*env)->NewGlobalRef(env, cls);
if (CLS_GSSCredElement == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/NativeGSSContext");
if (cls == NULL) {
printf("Couldn't find sun.security.jgss.wrapper.NativeGSSContext class\n");
return JNI_ERR;
}
CLS_NativeGSSContext = (*env)->NewGlobalRef(env, cls);
if (CLS_NativeGSSContext == NULL) {
return JNI_ERR;
}
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/SunNativeProvider");
if (cls == NULL) {
printf("Couldn't find sun.security.jgss.wrapper.SunNativeProvider class\n");
return JNI_ERR;
}
CLS_SunNativeProvider = (*env)->NewGlobalRef(env, cls);
if (CLS_SunNativeProvider == NULL) {
return JNI_ERR;
}
/* Compute and cache the method ID */
MID_String_ctor = (*env)->GetMethodID(env, CLS_String,
"<init>", "([B)V");
if (MID_String_ctor == NULL) {
printf("Couldn't find String(byte[]) constructor\n");
return JNI_ERR;
}
MID_Oid_ctor1 =
(*env)->GetMethodID(env, CLS_Oid, "<init>", "([B)V");
if (MID_Oid_ctor1 == NULL) {
printf("Couldn't find Oid(byte[]) constructor\n");
return JNI_ERR;
}
MID_Oid_getDER = (*env)->GetMethodID(env, CLS_Oid, "getDER", "()[B");
if (MID_Oid_getDER == NULL) {
printf("Couldn't find Oid.getDER() method\n");
return JNI_ERR;
}
cls = (*env)->FindClass(env, "org/ietf/jgss/MessageProp");
if (cls == NULL) {
printf("Couldn't find org.ietf.jgss.MessageProp class\n");
return JNI_ERR;
}
MID_MessageProp_getPrivacy =
(*env)->GetMethodID(env, cls, "getPrivacy", "()Z");
if (MID_MessageProp_getPrivacy == NULL) {
printf("Couldn't find MessageProp.getPrivacy() method\n");
return JNI_ERR;
}
MID_MessageProp_getQOP = (*env)->GetMethodID(env, cls, "getQOP", "()I");
if (MID_MessageProp_getQOP == NULL) {
printf("Couldn't find MessageProp.getQOP() method\n");
return JNI_ERR;
}
MID_MessageProp_setPrivacy =
(*env)->GetMethodID(env, cls, "setPrivacy", "(Z)V");
if (MID_MessageProp_setPrivacy == NULL) {
printf("Couldn't find MessageProp.setPrivacy(boolean) method\n");
return JNI_ERR;
}
MID_MessageProp_setQOP = (*env)->GetMethodID(env, cls, "setQOP", "(I)V");
if (MID_MessageProp_setQOP == NULL) {
printf("Couldn't find MessageProp.setQOP(int) method\n");
return JNI_ERR;
}
MID_MessageProp_setSupplementaryStates =
(*env)->GetMethodID(env, cls, "setSupplementaryStates",
"(ZZZZILjava/lang/String;)V");
if (MID_MessageProp_setSupplementaryStates == NULL) {
printf("Couldn't find MessageProp.setSupplementaryStates(...) method\n");
return JNI_ERR;
}
MID_GSSException_ctor3 = (*env)->GetMethodID
(env, CLS_GSSException, "<init>", "(IILjava/lang/String;)V");
if (MID_GSSException_ctor3 == NULL) {
printf("Couldn't find GSSException(int, int, String) constructor\n");
return JNI_ERR;
}
cls = (*env)->FindClass(env, "org/ietf/jgss/ChannelBinding");
if (cls == NULL) {
printf("Couldn't find org.ietf.jgss.ChannelBinding class\n");
return JNI_ERR;
}
MID_ChannelBinding_getInitiatorAddr =
(*env)->GetMethodID(env, cls, "getInitiatorAddress",
"()Ljava/net/InetAddress;");
if (MID_ChannelBinding_getInitiatorAddr == NULL) {
printf("Couldn't find ChannelBinding.getInitiatorAddress() method\n");
return JNI_ERR;
}
MID_ChannelBinding_getAcceptorAddr =
(*env)->GetMethodID(env, cls, "getAcceptorAddress",
"()Ljava/net/InetAddress;");
if (MID_ChannelBinding_getAcceptorAddr == NULL) {
printf("Couldn't find ChannelBinding.getAcceptorAddress() method\n");
return JNI_ERR;
}
MID_ChannelBinding_getAppData =
(*env)->GetMethodID(env, cls, "getApplicationData", "()[B");
if (MID_ChannelBinding_getAppData == NULL) {
printf("Couldn't find ChannelBinding.getApplicationData() method\n");
return JNI_ERR;
}
cls = (*env)->FindClass(env, "java/net/InetAddress");
if (cls == NULL) {
printf("Couldn't find java.net.InetAddress class\n");
return JNI_ERR;
}
MID_InetAddress_getAddr = (*env)->GetMethodID(env, cls, "getAddress",
"()[B");
if (MID_InetAddress_getAddr == NULL) {
printf("Couldn't find InetAddress.getAddress() method\n");
return JNI_ERR;
}
MID_GSSNameElement_ctor =
(*env)->GetMethodID(env, CLS_GSSNameElement,
"<init>", "(JLsun/security/jgss/wrapper/GSSLibStub;)V");
if (MID_GSSNameElement_ctor == NULL) {
printf("Couldn't find GSSNameElement(long, GSSLibStub) constructor\n");
return JNI_ERR;
}
MID_GSSCredElement_ctor =
(*env)->GetMethodID(env, CLS_GSSCredElement, "<init>",
"(JLsun/security/jgss/wrapper/GSSNameElement;Lorg/ietf/jgss/Oid;)V");
if (MID_GSSCredElement_ctor == NULL) {
printf("Couldn't find GSSCredElement(long, GSSLibStub) constructor\n");
return JNI_ERR;
}
MID_NativeGSSContext_ctor =
(*env)->GetMethodID(env, CLS_NativeGSSContext, "<init>",
"(JLsun/security/jgss/wrapper/GSSLibStub;)V");
if (MID_NativeGSSContext_ctor == NULL) {
printf("Couldn't find NativeGSSContext(long, GSSLibStub) constructor\n");
return JNI_ERR;
}
/* Compute and cache the field ID */
cls = (*env)->FindClass(env, "sun/security/jgss/wrapper/GSSLibStub");
if (cls == NULL) {
printf("Couldn't find sun.security.jgss.wrapper.GSSLibStub class\n");
return JNI_ERR;
}
FID_GSSLibStub_pMech =
(*env)->GetFieldID(env, cls, "pMech", "J");
if (FID_GSSLibStub_pMech == NULL) {
printf("Couldn't find GSSLibStub.pMech field\n");
return JNI_ERR;
}
FID_NativeGSSContext_pContext =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "pContext", "J");
if (FID_NativeGSSContext_pContext == NULL) {
printf("Couldn't find NativeGSSContext.pContext field\n");
return JNI_ERR;
}
FID_NativeGSSContext_srcName =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "srcName",
"Lsun/security/jgss/wrapper/GSSNameElement;");
if (FID_NativeGSSContext_srcName == NULL) {
printf("Couldn't find NativeGSSContext.srcName field\n");
return JNI_ERR;
}
FID_NativeGSSContext_targetName =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "targetName",
"Lsun/security/jgss/wrapper/GSSNameElement;");
if (FID_NativeGSSContext_targetName == NULL) {
printf("Couldn't find NativeGSSContext.targetName field\n");
return JNI_ERR;
}
FID_NativeGSSContext_isInitiator =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "isInitiator", "Z");
if (FID_NativeGSSContext_isInitiator == NULL) {
printf("Couldn't find NativeGSSContext.isInitiator field\n");
return JNI_ERR;
}
FID_NativeGSSContext_isEstablished =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "isEstablished", "Z");
if (FID_NativeGSSContext_isEstablished == NULL) {
printf("Couldn't find NativeGSSContext.isEstablished field\n");
return JNI_ERR;
}
FID_NativeGSSContext_delegatedCred =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "delegatedCred",
"Lsun/security/jgss/wrapper/GSSCredElement;");
if (FID_NativeGSSContext_delegatedCred == NULL) {
printf("Couldn't find NativeGSSContext.delegatedCred field\n");
return JNI_ERR;
}
FID_NativeGSSContext_flags =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "flags", "I");
if (FID_NativeGSSContext_flags == NULL) {
printf("Couldn't find NativeGSSContext.flags field\n");
return JNI_ERR;
}
FID_NativeGSSContext_lifetime =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "lifetime", "I");
if (FID_NativeGSSContext_lifetime == NULL) {
printf("Couldn't find NativeGSSContext.lifetime field\n");
return JNI_ERR;
}
FID_NativeGSSContext_actualMech =
(*env)->GetFieldID(env, CLS_NativeGSSContext, "actualMech",
"Lorg/ietf/jgss/Oid;");
if (FID_NativeGSSContext_actualMech == NULL) {
printf("Couldn't find NativeGSSContext.actualMech field\n");
return JNI_ERR;
}
return JNI_VERSION_1_2;
}
JNIEXPORT void JNICALL
DEF_JNI_OnUnload(JavaVM *jvm, void *reserved) {
JNIEnv *env;
if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) {
return;
}
/* Delete the global refs */
(*env)->DeleteGlobalRef(env, CLS_Object);
(*env)->DeleteGlobalRef(env, CLS_String);
(*env)->DeleteGlobalRef(env, CLS_Oid);
(*env)->DeleteGlobalRef(env, CLS_GSSException);
(*env)->DeleteGlobalRef(env, CLS_GSSNameElement);
(*env)->DeleteGlobalRef(env, CLS_GSSCredElement);
(*env)->DeleteGlobalRef(env, CLS_SunNativeProvider);
return;
}
const OM_uint32 JAVA_MAX = GSS_C_INDEFINITE/2;
/*
* Utility routine for converting the C unsigned integer time
* to Java signed integer time.
*/
jint getJavaTime(OM_uint32 ctime) {
jint result;
/* special handle values equals or more than JAVA_MAX */
if (ctime == GSS_C_INDEFINITE) {
result = JAVA_MAX;
} else if (ctime >= JAVA_MAX) {
result = JAVA_MAX-1;
} else {
result = ctime;
}
return result;
}
/*
* Utility routine for converting the Java signed integer time
* to C unsigned integer time.
*/
OM_uint32 getGSSTime(jint jtime) {
OM_uint32 result;
/* special handle values equal to JAVA_MAX */
if (jtime == (jint)JAVA_MAX) {
result = GSS_C_INDEFINITE;
} else {
result = jtime;
}
return result;
}
/*
* Utility routine for mapping the C error code to the
* Java one. The routine errors really should have
* shared the same values but unfortunately don't.
*/
jint getJavaErrorCode(int cNonCallingErr) {
int cRoutineErr, cSuppStatus;
/* map the routine errors */
cRoutineErr = GSS_ROUTINE_ERROR(cNonCallingErr) >> 16;
if (cRoutineErr != GSS_S_COMPLETE) {
return JAVA_ERROR_CODE[cRoutineErr-1];
}
/* map the supplementary infos */
cSuppStatus = GSS_SUPPLEMENTARY_INFO(cNonCallingErr);
if (cSuppStatus & GSS_S_DUPLICATE_TOKEN) {
return JAVA_DUPLICATE_TOKEN_CODE;
} else if (cSuppStatus & GSS_S_OLD_TOKEN) {
return JAVA_OLD_TOKEN_CODE;
} else if (cSuppStatus & GSS_S_UNSEQ_TOKEN) {
return JAVA_UNSEQ_TOKEN_CODE;
} else if (cSuppStatus & GSS_S_GAP_TOKEN) {
return JAVA_GAP_TOKEN_CODE;
}
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
* using the specified gss_buffer_t structure. The specified
* gss_buffer_t structure is always released.
*/
jstring getJavaString(JNIEnv *env, gss_buffer_t bytes) {
jstring result = NULL;
OM_uint32 minor;
int len;
jbyteArray jbytes;
if (bytes != NULL) {
/* constructs the String object with new String(byte[])
NOTE: do NOT include the trailing NULL */
len = bytes->length;
jbytes = (*env)->NewByteArray(env, len);
if (jbytes == NULL) {
goto finish;
}
(*env)->SetByteArrayRegion(env, jbytes, 0, len, (jbyte *) bytes->value);
if ((*env)->ExceptionCheck(env)) {
goto finish;
}
result = (*env)->NewObject(env, CLS_String, MID_String_ctor,
jbytes);
finish:
(*env)->DeleteLocalRef(env, jbytes);
(*ftab->releaseBuffer)(&minor, bytes);
return result;
} /* else fall through */
return NULL;
}
/*
* Utility routine for generate message for the specified minor
* status code.
*/
jstring getMinorMessage(JNIEnv *env, jobject jstub, OM_uint32 statusValue) {
OM_uint32 messageContext, minor, major;
gss_buffer_desc statusString;
gss_OID mech;
jstring msg;
messageContext = 0;
if (jstub != NULL) {
mech = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jstub, FID_GSSLibStub_pMech));
} else {
mech = GSS_C_NO_OID;
}
/* 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,
&messageContext, &statusString);
return getJavaString(env, &statusString);
}
/*
* Utility routine checking the specified major and minor
* status codes. GSSExceptions will be thrown if they are
* not GSS_S_COMPLETE (i.e. 0).
*/
void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major,
OM_uint32 minor, char* methodName) {
int callingErr, routineErr, supplementaryInfo;
jint jmajor, jminor;
char* msg;
jstring jmsg;
jthrowable gssEx;
if (major == GSS_S_COMPLETE) return;
callingErr = GSS_CALLING_ERROR(major);
routineErr = GSS_ROUTINE_ERROR(major);
supplementaryInfo = GSS_SUPPLEMENTARY_INFO(major);
TRACE3("%s Status major/minor = %x/%d", methodName, major, minor);
TRACE3("c/r/s = %d/%d/%d ", callingErr>>24, routineErr>>16,
supplementaryInfo);
jmajor = getJavaErrorCode(routineErr | supplementaryInfo);
jminor = minor;
if (jmajor != GSS_S_COMPLETE) {
jmsg = NULL;
if (minor != 0) {
jmsg = getMinorMessage(env, jstub, minor);
if ((*env)->ExceptionCheck(env)) {
return;
}
}
gssEx = (*env)->NewObject(env, CLS_GSSException,
MID_GSSException_ctor3,
jmajor, jminor, jmsg);
if (gssEx != NULL) {
(*env)->Throw(env, gssEx);
}
} else {
/* Error in calling the GSS api */
if (callingErr == GSS_S_CALL_INACCESSIBLE_READ) {
msg = "A required input parameter cannot be read";
} else if (callingErr == GSS_S_CALL_INACCESSIBLE_WRITE) {
msg = "A required output parameter cannot be write";
} else {
msg = "A parameter was malformed";
}
jmajor = 13; /* use GSSException.FAILURE for now */
jmsg = (*env)->NewStringUTF(env, msg);
if (jmsg == NULL) {
return;
}
gssEx = (*env)->NewObject(env, CLS_GSSException,
MID_GSSException_ctor3,
jmajor, jminor, jmsg);
if (gssEx != NULL) {
(*env)->Throw(env, gssEx);
}
}
}
/*
* Utility routine for initializing gss_buffer_t structure
* with the byte[] in the specified jbyteArray object.
* NOTE: must call resetGSSBuffer() to free up the resources
* inside the gss_buffer_t structure.
*/
void initGSSBuffer(JNIEnv *env, jbyteArray jbytes,
gss_buffer_t cbytes) {
int len;
void* value;
if (jbytes != NULL) {
len = (*env)->GetArrayLength(env, jbytes);
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 {
cbytes->length = 0;
cbytes->value = NULL;
}
}
/*
* Utility routine for freeing the bytes malloc'ed
* in initGSSBuffer() method.
* NOTE: used in conjunction with initGSSBuffer(...).
*/
void resetGSSBuffer(gss_buffer_t cbytes) {
if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER)) {
free(cbytes->value);
cbytes->length = 0;
cbytes->value = NULL;
}
}
/*
* Utility routine for creating a jbyteArray object using
* the byte[] value in specified gss_buffer_t structure.
* NOTE: the specified gss_buffer_t structure is always
* released.
*/
jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) {
jbyteArray result = NULL;
OM_uint32 minor; // don't care, just so it compiles
if (cbytes != NULL) {
if ((cbytes != GSS_C_NO_BUFFER) && (cbytes->length != 0)) {
result = (*env)->NewByteArray(env, cbytes->length);
if (result == NULL) {
goto finish;
}
(*env)->SetByteArrayRegion(env, result, 0, cbytes->length,
cbytes->value);
if ((*env)->ExceptionCheck(env)) {
result = NULL;
}
}
finish:
(*ftab->releaseBuffer)(&minor, cbytes);
return result;
}
return NULL;
}
/*
* Utility routine for creating a non-mech gss_OID using
* the specified org.ietf.jgss.Oid object.
* NOTE: must call deleteGSSOID(...) to free up the gss_OID.
*/
gss_OID newGSSOID(JNIEnv *env, jobject jOid) {
jbyteArray jbytes;
gss_OID cOid;
jthrowable gssEx;
if (jOid != NULL) {
jbytes = (*env)->CallObjectMethod(env, jOid, MID_Oid_getDER);
if ((*env)->ExceptionCheck(env)) {
return GSS_C_NO_OID;
}
cOid = malloc(sizeof(struct gss_OID_desc_struct));
if (cOid == NULL) {
throwOutOfMemoryError(env,NULL);
return GSS_C_NO_OID;
}
cOid->length = (*env)->GetArrayLength(env, jbytes) - 2;
cOid->elements = malloc(cOid->length);
if (cOid->elements == NULL) {
throwOutOfMemoryError(env,NULL);
goto cleanup;
}
(*env)->GetByteArrayRegion(env, jbytes, 2, cOid->length,
cOid->elements);
if ((*env)->ExceptionCheck(env)) {
goto cleanup;
}
return cOid;
} else {
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
* structure.
* NOTE: used in conjunction with newGSSOID(...).
*/
void deleteGSSOID(gss_OID oid) {
if (oid != GSS_C_NO_OID) {
free(oid->elements);
free(oid);
}
}
/*
* Utility routine for creating a org.ietf.jgss.Oid
* object using the specified gss_OID structure.
*/
jobject getJavaOID(JNIEnv *env, gss_OID cOid) {
int cLen;
char oidHdr[2];
jbyteArray jbytes;
jobject result = NULL;
if ((cOid == NULL) || (cOid == GSS_C_NO_OID)) {
return NULL;
}
cLen = cOid->length;
oidHdr[0] = 6;
oidHdr[1] = cLen;
jbytes = (*env)->NewByteArray(env, cLen+2);
if (jbytes == NULL) {
return NULL;
}
(*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
(*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);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
(*env)->DeleteLocalRef(env, jbytes);
return result;
}
/*
* Utility routine for creating a gss_OID_set structure
* using the specified gss_OID.
* NOTE: need to call deleteGSSOIDSet(...) afterwards
* to release the created gss_OID_set structure.
*/
gss_OID_set newGSSOIDSet(gss_OID oid) {
gss_OID_set oidSet;
OM_uint32 minor; // don't care; just so it compiles
if (oid->length != 6 ||
memcmp(oid->elements, SPNEGO_BYTES, 6) != 0) {
(*ftab->createEmptyOidSet)(&minor, &oidSet);
(*ftab->addOidSetMember)(&minor, oid, &oidSet);
return oidSet;
} else {
// Use all mechs for SPNEGO in order to work with
// various native GSS impls
return (ftab->mechs);
}
}
/*
* Utility routine for releasing a gss_OID_set structure.
* NOTE: used in conjunction with newGSSOIDSet(...).
*/
void deleteGSSOIDSet(gss_OID_set oidSet) {
OM_uint32 minor; /* don't care; just so it compiles */
if ((oidSet != ftab->mechs) &&
(oidSet != NULL) && (oidSet != GSS_C_NO_OID_SET)) {
(*ftab->releaseOidSet)(&minor, &oidSet);
}
}
/*
* Utility routine for creating a org.ietf.jgss.Oid[]
* using the specified gss_OID_set structure.
*/
jobjectArray getJavaOIDArray(JNIEnv *env, gss_OID_set cOidSet) {
int numOfOids = 0;
jobjectArray jOidSet;
jobject jOid;
int i;
jthrowable gssEx;
if (cOidSet != NULL && cOidSet != GSS_C_NO_OID_SET) {
numOfOids = cOidSet->count;
jOidSet = (*env)->NewObjectArray(env, numOfOids, CLS_Oid, NULL);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
for (i = 0; i < numOfOids; i++) {
jOid = getJavaOID(env, &(cOidSet->elements[i]));
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
(*env)->SetObjectArrayElement(env, jOidSet, i, jOid);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
(*env)->DeleteLocalRef(env, jOid);
}
return jOidSet;
}
return NULL;
}
int sameMech(gss_OID mech, gss_OID mech2) {
int result = JNI_FALSE; // default to not equal
if (mech->length == mech2->length) {
result = (memcmp(mech->elements, mech2->elements, mech->length) == 0);
}
return result;
}

View file

@ -0,0 +1,94 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <jni.h>
#include <stdlib.h>
#include <string.h>
#include "gssapi.h"
#ifndef _Included_NATIVE_Util
#define _Included_NATIVE_Util
#ifdef __cplusplus
extern "C" {
#endif
extern jint getJavaTime(OM_uint32);
extern OM_uint32 getGSSTime(jint);
extern void checkStatus(JNIEnv *, jobject, OM_uint32, OM_uint32, char*);
extern jint checkTime(OM_uint32);
extern void throwOutOfMemoryError(JNIEnv *, const char*);
extern void initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t);
extern void resetGSSBuffer(gss_buffer_t);
extern gss_OID newGSSOID(JNIEnv *, jobject);
extern void deleteGSSOID(gss_OID);
extern gss_OID_set newGSSOIDSet(gss_OID);
extern void deleteGSSOIDSet(gss_OID_set);
extern jbyteArray getJavaBuffer(JNIEnv *, gss_buffer_t);
extern jstring getJavaString(JNIEnv *, gss_buffer_t);
extern jobject getJavaOID(JNIEnv *, gss_OID);
extern jobjectArray getJavaOIDArray(JNIEnv *, gss_OID_set);
extern jstring getMinorMessage(JNIEnv *, jobject, OM_uint32);
extern int sameMech(gss_OID, gss_OID);
extern int JGSS_DEBUG;
extern jclass CLS_Object;
extern jclass CLS_GSSNameElement;
extern jclass CLS_GSSCredElement;
extern jclass CLS_NativeGSSContext;
extern jmethodID MID_MessageProp_getPrivacy;
extern jmethodID MID_MessageProp_getQOP;
extern jmethodID MID_MessageProp_setPrivacy;
extern jmethodID MID_MessageProp_setQOP;
extern jmethodID MID_MessageProp_setSupplementaryStates;
extern jmethodID MID_ChannelBinding_getInitiatorAddr;
extern jmethodID MID_ChannelBinding_getAcceptorAddr;
extern jmethodID MID_ChannelBinding_getAppData;
extern jmethodID MID_InetAddress_getAddr;
extern jmethodID MID_GSSNameElement_ctor;
extern jmethodID MID_GSSCredElement_ctor;
extern jmethodID MID_NativeGSSContext_ctor;
extern jfieldID FID_GSSLibStub_pMech;
extern jfieldID FID_NativeGSSContext_pContext;
extern jfieldID FID_NativeGSSContext_srcName;
extern jfieldID FID_NativeGSSContext_targetName;
extern jfieldID FID_NativeGSSContext_isInitiator;
extern jfieldID FID_NativeGSSContext_isEstablished;
extern jfieldID FID_NativeGSSContext_delegatedCred;
extern jfieldID FID_NativeGSSContext_flags;
extern jfieldID FID_NativeGSSContext_lifetime;
extern jfieldID FID_NativeGSSContext_actualMech;
#define TRACE0(s) { if (JGSS_DEBUG) { puts(s); fflush(stdout); }}
#define TRACE1(s, p1) { if (JGSS_DEBUG) { printf(s"\n", p1); fflush(stdout); }}
#define TRACE2(s, p1, p2) { if (JGSS_DEBUG) { printf(s"\n", p1, p2); fflush(stdout); }}
#define TRACE3(s, p1, p2, p3) { if (JGSS_DEBUG) { printf(s"\n", p1, p2, p3); fflush(stdout); }}
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,693 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* This is the gssapi.h prologue. */
/* It contains some choice pieces of autoconf.h */
#define GSS_SIZEOF_INT 4
#define GSS_SIZEOF_LONG 4
#define GSS_SIZEOF_SHORT 2
#ifndef _GSSAPI_H_
#define _GSSAPI_H_
#if defined(__MACH__) && defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_RT_MAC_CFM
# error "Use KfM 4.0 SDK headers for CFM compilation."
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#if TARGET_OS_MAC
# pragma pack(push,2)
#endif
/*
* First, include stddef.h to get size_t defined.
*/
#include <stddef.h>
/*
* POSIX says that sys/types.h is where size_t is defined.
*/
#include <sys/types.h>
typedef void * gss_name_t;
typedef void * gss_cred_id_t;
typedef void * gss_ctx_id_t;
/*
* The following type must be defined as the smallest natural unsigned integer
* supported by the platform that has at least 32 bits of precision.
*/
#if (GSS_SIZEOF_SHORT == 4)
typedef unsigned short gss_uint32;
typedef short gss_int32;
#elif (GSS_SIZEOF_INT == 4)
typedef unsigned int gss_uint32;
typedef int gss_int32;
#elif (GSS_SIZEOF_LONG == 4)
typedef unsigned long gss_uint32;
typedef long gss_int32;
#endif
typedef gss_uint32 OM_uint32;
typedef struct gss_OID_desc_struct {
OM_uint32 length;
void *elements;
} gss_OID_desc, *gss_OID;
typedef struct gss_OID_set_desc_struct {
size_t count;
gss_OID elements;
} gss_OID_set_desc, *gss_OID_set;
typedef struct gss_buffer_desc_struct {
size_t length;
void *value;
} gss_buffer_desc, *gss_buffer_t;
typedef struct gss_channel_bindings_struct {
OM_uint32 initiator_addrtype;
gss_buffer_desc initiator_address;
OM_uint32 acceptor_addrtype;
gss_buffer_desc acceptor_address;
gss_buffer_desc application_data;
} *gss_channel_bindings_t;
/*
* For now, define a QOP-type as an OM_uint32
*/
typedef OM_uint32 gss_qop_t;
typedef int gss_cred_usage_t;
/*
* Flag bits for context-level services.
*/
#define GSS_C_DELEG_FLAG 1
#define GSS_C_MUTUAL_FLAG 2
#define GSS_C_REPLAY_FLAG 4
#define GSS_C_SEQUENCE_FLAG 8
#define GSS_C_CONF_FLAG 16
#define GSS_C_INTEG_FLAG 32
#define GSS_C_ANON_FLAG 64
#define GSS_C_PROT_READY_FLAG 128
#define GSS_C_TRANS_FLAG 256
/*
* Credential usage options
*/
#define GSS_C_BOTH 0
#define GSS_C_INITIATE 1
#define GSS_C_ACCEPT 2
/*
* Status code types for gss_display_status
*/
#define GSS_C_GSS_CODE 1
#define GSS_C_MECH_CODE 2
/*
* The constant definitions for channel-bindings address families
*/
#define GSS_C_AF_UNSPEC 0
#define GSS_C_AF_LOCAL 1
#define GSS_C_AF_INET 2
#define GSS_C_AF_IMPLINK 3
#define GSS_C_AF_PUP 4
#define GSS_C_AF_CHAOS 5
#define GSS_C_AF_NS 6
#define GSS_C_AF_NBS 7
#define GSS_C_AF_ECMA 8
#define GSS_C_AF_DATAKIT 9
#define GSS_C_AF_CCITT 10
#define GSS_C_AF_SNA 11
#define GSS_C_AF_DECnet 12
#define GSS_C_AF_DLI 13
#define GSS_C_AF_LAT 14
#define GSS_C_AF_HYLINK 15
#define GSS_C_AF_APPLETALK 16
#define GSS_C_AF_BSC 17
#define GSS_C_AF_DSS 18
#define GSS_C_AF_OSI 19
#define GSS_C_AF_X25 21
#define GSS_C_AF_NULLADDR 255
/*
* Various Null values.
*/
#define GSS_C_NO_NAME ((gss_name_t) 0)
#define GSS_C_NO_BUFFER ((gss_buffer_t) 0)
#define GSS_C_NO_OID ((gss_OID) 0)
#define GSS_C_NO_OID_SET ((gss_OID_set) 0)
#define GSS_C_NO_CONTEXT ((gss_ctx_id_t) 0)
#define GSS_C_NO_CREDENTIAL ((gss_cred_id_t) 0)
#define GSS_C_NO_CHANNEL_BINDINGS ((gss_channel_bindings_t) 0)
#define GSS_C_EMPTY_BUFFER {0, NULL}
/*
* Some alternate names for a couple of the above values. These are defined
* for V1 compatibility.
*/
#define GSS_C_NULL_OID GSS_C_NO_OID
#define GSS_C_NULL_OID_SET GSS_C_NO_OID_SET
/*
* Define the default Quality of Protection for per-message services. Note
* that an implementation that offers multiple levels of QOP may either reserve
* a value (for example zero, as assumed here) to mean "default protection", or
* alternatively may simply equate GSS_C_QOP_DEFAULT to a specific explicit
* QOP value. However a value of 0 should always be interpreted by a GSSAPI
* implementation as a request for the default protection level.
*/
#define GSS_C_QOP_DEFAULT 0
/*
* Expiration time of 2^32-1 seconds means infinite lifetime for a
* credential or security context
*/
#define GSS_C_INDEFINITE ((OM_uint32) 0xfffffffful)
/* Major status codes */
#define GSS_S_COMPLETE 0
/*
* Some "helper" definitions to make the status code macros obvious.
*/
#define GSS_C_CALLING_ERROR_OFFSET 24
#define GSS_C_ROUTINE_ERROR_OFFSET 16
#define GSS_C_SUPPLEMENTARY_OFFSET 0
#define GSS_C_CALLING_ERROR_MASK ((OM_uint32) 0377ul)
#define GSS_C_ROUTINE_ERROR_MASK ((OM_uint32) 0377ul)
#define GSS_C_SUPPLEMENTARY_MASK ((OM_uint32) 0177777ul)
/*
* The macros that test status codes for error conditions. Note that the
* GSS_ERROR() macro has changed slightly from the V1 GSSAPI so that it now
* evaluates its argument only once.
*/
#define GSS_CALLING_ERROR(x) \
((x) & (GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET))
#define GSS_ROUTINE_ERROR(x) \
((x) & (GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET))
#define GSS_SUPPLEMENTARY_INFO(x) \
((x) & (GSS_C_SUPPLEMENTARY_MASK << GSS_C_SUPPLEMENTARY_OFFSET))
#define GSS_ERROR(x) \
((x) & ((GSS_C_CALLING_ERROR_MASK << GSS_C_CALLING_ERROR_OFFSET) | \
(GSS_C_ROUTINE_ERROR_MASK << GSS_C_ROUTINE_ERROR_OFFSET)))
/*
* Now the actual status code definitions
*/
/*
* Calling errors:
*/
#define GSS_S_CALL_INACCESSIBLE_READ \
(((OM_uint32) 1ul) << GSS_C_CALLING_ERROR_OFFSET)
#define GSS_S_CALL_INACCESSIBLE_WRITE \
(((OM_uint32) 2ul) << GSS_C_CALLING_ERROR_OFFSET)
#define GSS_S_CALL_BAD_STRUCTURE \
(((OM_uint32) 3ul) << GSS_C_CALLING_ERROR_OFFSET)
/*
* Routine errors:
*/
#define GSS_S_BAD_MECH (((OM_uint32) 1ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_BAD_NAME (((OM_uint32) 2ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_BAD_NAMETYPE (((OM_uint32) 3ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_BAD_BINDINGS (((OM_uint32) 4ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_BAD_STATUS (((OM_uint32) 5ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_BAD_SIG (((OM_uint32) 6ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_NO_CRED (((OM_uint32) 7ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_NO_CONTEXT (((OM_uint32) 8ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_DEFECTIVE_TOKEN (((OM_uint32) 9ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_DEFECTIVE_CREDENTIAL \
(((OM_uint32) 10ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_CREDENTIALS_EXPIRED \
(((OM_uint32) 11ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_CONTEXT_EXPIRED \
(((OM_uint32) 12ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_FAILURE (((OM_uint32) 13ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_BAD_QOP (((OM_uint32) 14ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_UNAUTHORIZED (((OM_uint32) 15ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_UNAVAILABLE (((OM_uint32) 16ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_DUPLICATE_ELEMENT \
(((OM_uint32) 17ul) << GSS_C_ROUTINE_ERROR_OFFSET)
#define GSS_S_NAME_NOT_MN \
(((OM_uint32) 18ul) << GSS_C_ROUTINE_ERROR_OFFSET)
/*
* Supplementary info bits:
*/
#define GSS_S_CONTINUE_NEEDED (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 0))
#define GSS_S_DUPLICATE_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 1))
#define GSS_S_OLD_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 2))
#define GSS_S_UNSEQ_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 3))
#define GSS_S_GAP_TOKEN (1 << (GSS_C_SUPPLEMENTARY_OFFSET + 4))
/*
* Finally, function prototypes for the GSSAPI routines.
*/
#if defined (_WIN32) && defined (_MSC_VER)
# ifdef GSS_DLL_FILE
# define GSS_DLLIMP __declspec(dllexport)
# else
# define GSS_DLLIMP __declspec(dllimport)
# endif
#else
# define GSS_DLLIMP
#endif
/* Reserved static storage for GSS_oids. Comments are quotes from RFC 2744.
*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x01"},
* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) user_name(1)}. The constant
* GSS_C_NT_USER_NAME should be initialized to point
* to that gss_OID_desc.
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_USER_NAME;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x02"},
* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
* The constant GSS_C_NT_MACHINE_UID_NAME should be
* initialized to point to that gss_OID_desc.
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_MACHINE_UID_NAME;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03"},
* corresponding to an object-identifier value of
* {iso(1) member-body(2) United States(840) mit(113554)
* infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
* The constant GSS_C_NT_STRING_UID_NAME should be
* initialized to point to that gss_OID_desc.
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_STRING_UID_NAME;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {6, (void *)"\x2b\x06\x01\x05\x06\x02"},
* corresponding to an object-identifier value of
* {iso(1) org(3) dod(6) internet(1) security(5)
* nametypes(6) gss-host-based-services(2)). The constant
* GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
* to that gss_OID_desc. This is a deprecated OID value, and
* implementations wishing to support hostbased-service names
* should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
* defined below, to identify such names;
* GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
* for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
* parameter, but should not be emitted by GSS-API
* implementations
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_HOSTBASED_SERVICE_X;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
* "\x01\x02\x01\x04"}, corresponding to an
* object-identifier value of {iso(1) member-body(2)
* Unites States(840) mit(113554) infosys(1) gssapi(2)
* generic(1) service_name(4)}. The constant
* GSS_C_NT_HOSTBASED_SERVICE should be initialized
* to point to that gss_OID_desc.
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_HOSTBASED_SERVICE;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {6, (void *)"\x2b\x06\01\x05\x06\x03"},
* corresponding to an object identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 3(gss-anonymous-name)}. The constant
* and GSS_C_NT_ANONYMOUS should be initialized to point
* to that gss_OID_desc.
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_ANONYMOUS;
/*
* The implementation must reserve static storage for a
* gss_OID_desc object containing the value
* {6, (void *)"\x2b\x06\x01\x05\x06\x04"},
* corresponding to an object-identifier value of
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
* 6(nametypes), 4(gss-api-exported-name)}. The constant
* GSS_C_NT_EXPORT_NAME should be initialized to point
* to that gss_OID_desc.
*/
GSS_DLLIMP extern gss_OID GSS_C_NT_EXPORT_NAME;
/* Function Prototypes */
OM_uint32 gss_acquire_cred(
OM_uint32 *, /* minor_status */
gss_name_t, /* desired_name */
OM_uint32, /* time_req */
gss_OID_set, /* desired_mechs */
gss_cred_usage_t, /* cred_usage */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 * /* time_rec */
);
OM_uint32 gss_release_cred(
OM_uint32 *, /* minor_status */
gss_cred_id_t * /* cred_handle */
);
OM_uint32 gss_init_sec_context(
OM_uint32 *, /* minor_status */
gss_cred_id_t, /* claimant_cred_handle */
gss_ctx_id_t *, /* context_handle */
gss_name_t, /* target_name */
gss_OID, /* mech_type (used to be const) */
OM_uint32, /* req_flags */
OM_uint32, /* time_req */
gss_channel_bindings_t, /* input_chan_bindings */
gss_buffer_t, /* input_token */
gss_OID *, /* actual_mech_type */
gss_buffer_t, /* output_token */
OM_uint32 *, /* ret_flags */
OM_uint32 * /* time_rec */
);
OM_uint32 gss_accept_sec_context(
OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
gss_cred_id_t, /* acceptor_cred_handle */
gss_buffer_t, /* input_token_buffer */
gss_channel_bindings_t, /* input_chan_bindings */
gss_name_t *, /* src_name */
gss_OID *, /* mech_type */
gss_buffer_t, /* output_token */
OM_uint32 *, /* ret_flags */
OM_uint32 *, /* time_rec */
gss_cred_id_t * /* delegated_cred_handle */
);
OM_uint32 gss_process_context_token(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t /* token_buffer */
);
OM_uint32 gss_delete_sec_context(
OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
gss_buffer_t /* output_token */
);
OM_uint32 gss_context_time(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
OM_uint32 * /* time_rec */
);
/* New for V2 */
OM_uint32 gss_get_mic(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_qop_t, /* qop_req */
gss_buffer_t, /* message_buffer */
gss_buffer_t /* message_token */
);
/* New for V2 */
OM_uint32 gss_verify_mic(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t, /* message_buffer */
gss_buffer_t, /* message_token */
gss_qop_t * /* qop_state */
);
/* New for V2 */
OM_uint32 gss_wrap(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
gss_qop_t, /* qop_req */
gss_buffer_t, /* input_message_buffer */
int *, /* conf_state */
gss_buffer_t /* output_message_buffer */
);
/* New for V2 */
OM_uint32 gss_unwrap(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_buffer_t, /* input_message_buffer */
gss_buffer_t, /* output_message_buffer */
int *, /* conf_state */
gss_qop_t * /* qop_state */
);
OM_uint32 gss_display_status(
OM_uint32 *, /* minor_status */
OM_uint32, /* status_value */
int, /* status_type */
gss_OID, /* mech_type (used to be const) */
OM_uint32 *, /* message_context */
gss_buffer_t /* status_string */
);
OM_uint32 gss_indicate_mechs(
OM_uint32 *, /* minor_status */
gss_OID_set * /* mech_set */
);
OM_uint32 gss_compare_name(
OM_uint32 *, /* minor_status */
gss_name_t, /* name1 */
gss_name_t, /* name2 */
int * /* name_equal */
);
OM_uint32 gss_display_name(
OM_uint32 *, /* minor_status */
gss_name_t, /* input_name */
gss_buffer_t, /* output_name_buffer */
gss_OID * /* output_name_type */
);
OM_uint32 gss_import_name(
OM_uint32 *, /* minor_status */
gss_buffer_t, /* input_name_buffer */
gss_OID, /* input_name_type(used to be const) */
gss_name_t * /* output_name */
);
OM_uint32 gss_release_name(
OM_uint32 *, /* minor_status */
gss_name_t * /* input_name */
);
OM_uint32 gss_release_buffer(
OM_uint32 *, /* minor_status */
gss_buffer_t /* buffer */
);
OM_uint32 gss_release_oid_set(
OM_uint32 *, /* minor_status */
gss_OID_set * /* set */
);
OM_uint32 gss_inquire_cred(
OM_uint32 *, /* minor_status */
gss_cred_id_t, /* cred_handle */
gss_name_t *, /* name */
OM_uint32 *, /* lifetime */
gss_cred_usage_t *, /* cred_usage */
gss_OID_set * /* mechanisms */
);
/* Last argument new for V2 */
OM_uint32 gss_inquire_context(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
gss_name_t *, /* src_name */
gss_name_t *, /* targ_name */
OM_uint32 *, /* lifetime_rec */
gss_OID *, /* mech_type */
OM_uint32 *, /* ctx_flags */
int *, /* locally_initiated */
int * /* open */
);
/* New for V2 */
OM_uint32 gss_wrap_size_limit(
OM_uint32 *, /* minor_status */
gss_ctx_id_t, /* context_handle */
int, /* conf_req_flag */
gss_qop_t, /* qop_req */
OM_uint32, /* req_output_size */
OM_uint32 * /* max_input_size */
);
/* New for V2 */
OM_uint32 gss_add_cred(
OM_uint32 *, /* minor_status */
gss_cred_id_t, /* input_cred_handle */
gss_name_t, /* desired_name */
gss_OID, /* desired_mech */
gss_cred_usage_t, /* cred_usage */
OM_uint32, /* initiator_time_req */
OM_uint32, /* acceptor_time_req */
gss_cred_id_t *, /* output_cred_handle */
gss_OID_set *, /* actual_mechs */
OM_uint32 *, /* initiator_time_rec */
OM_uint32 * /* acceptor_time_rec */
);
/* New for V2 */
OM_uint32 gss_inquire_cred_by_mech(
OM_uint32 *, /* minor_status */
gss_cred_id_t, /* cred_handle */
gss_OID, /* mech_type */
gss_name_t *, /* name */
OM_uint32 *, /* initiator_lifetime */
OM_uint32 *, /* acceptor_lifetime */
gss_cred_usage_t * /* cred_usage */
);
/* New for V2 */
OM_uint32 gss_export_sec_context(
OM_uint32 *, /* minor_status */
gss_ctx_id_t *, /* context_handle */
gss_buffer_t /* interprocess_token */
);
/* New for V2 */
OM_uint32 gss_import_sec_context(
OM_uint32 *, /* minor_status */
gss_buffer_t, /* interprocess_token */
gss_ctx_id_t * /* context_handle */
);
/* New for V2 */
OM_uint32 gss_release_oid(
OM_uint32 *, /* minor_status */
gss_OID * /* oid */
);
/* New for V2 */
OM_uint32 gss_create_empty_oid_set(
OM_uint32 *, /* minor_status */
gss_OID_set * /* oid_set */
);
/* New for V2 */
OM_uint32 gss_add_oid_set_member(
OM_uint32 *, /* minor_status */
gss_OID, /* member_oid */
gss_OID_set * /* oid_set */
);
/* New for V2 */
OM_uint32 gss_test_oid_set_member(
OM_uint32 *, /* minor_status */
gss_OID, /* member */
gss_OID_set, /* set */
int * /* present */
);
/* New for V2 */
OM_uint32 gss_str_to_oid(
OM_uint32 *, /* minor_status */
gss_buffer_t, /* oid_str */
gss_OID * /* oid */
);
/* New for V2 */
OM_uint32 gss_oid_to_str(
OM_uint32 *, /* minor_status */
gss_OID, /* oid */
gss_buffer_t /* oid_str */
);
/* New for V2 */
OM_uint32 gss_inquire_names_for_mech(
OM_uint32 *, /* minor_status */
gss_OID, /* mechanism */
gss_OID_set * /* name_types */
);
/* New for V2 */
OM_uint32 gss_export_name(
OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_buffer_t /* exported_name */
);
/* New for V2 */
OM_uint32 gss_duplicate_name(
OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_name_t * /* dest_name */
);
/* New for V2 */
OM_uint32 gss_canonicalize_name(
OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
const gss_OID, /* mech_type */
gss_name_t * /* output_name */
);
#if TARGET_OS_MAC
# pragma pack(pop)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _GSSAPI_H_ */