1 /* 2 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. 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 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 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 * 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. 24 */ 25 26 #include <jni.h> 27 #include <stdlib.h> 28 #include <string.h> 29 #include <inttypes.h> 30 #include "gssapi.h" 31 32 #ifndef _Included_NATIVE_Util 33 #define _Included_NATIVE_Util 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 extern jint getJavaTime(OM_uint32); 38 extern OM_uint32 getGSSTime(jint); 39 extern void checkStatus(JNIEnv *, jobject, OM_uint32, OM_uint32, char*); 40 extern jint checkTime(OM_uint32); 41 extern void throwOutOfMemoryError(JNIEnv *, const char*); 42 extern void initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t); 43 extern void resetGSSBuffer(gss_buffer_t); 44 45 extern gss_OID newGSSOID(JNIEnv *, jobject); 46 extern void deleteGSSOID(gss_OID); 47 extern gss_OID_set newGSSOIDSet(gss_OID); 48 extern void deleteGSSOIDSet(gss_OID_set); 49 50 extern jbyteArray getJavaBuffer(JNIEnv *, gss_buffer_t); 51 extern jstring getJavaString(JNIEnv *, gss_buffer_t); 52 extern jobject getJavaOID(JNIEnv *, gss_OID); 53 extern jobjectArray getJavaOIDArray(JNIEnv *, gss_OID_set); 54 55 extern jstring getMinorMessage(JNIEnv *, jobject, OM_uint32); 56 extern int sameMech(gss_OID, gss_OID); 57 58 extern int JGSS_DEBUG; 59 60 extern jclass CLS_Object; 61 extern jclass CLS_GSSNameElement; 62 extern jclass CLS_GSSCredElement; 63 extern jclass CLS_NativeGSSContext; 64 extern jmethodID MID_MessageProp_getPrivacy; 65 extern jmethodID MID_MessageProp_getQOP; 66 extern jmethodID MID_MessageProp_setPrivacy; 67 extern jmethodID MID_MessageProp_setQOP; 68 extern jmethodID MID_MessageProp_setSupplementaryStates; 69 extern jmethodID MID_ChannelBinding_getInitiatorAddr; 70 extern jmethodID MID_ChannelBinding_getAcceptorAddr; 71 extern jmethodID MID_ChannelBinding_getAppData; 72 extern jmethodID MID_InetAddress_getAddr; 73 extern jmethodID MID_GSSNameElement_ctor; 74 extern jmethodID MID_GSSCredElement_ctor; 75 extern jmethodID MID_NativeGSSContext_ctor; 76 extern jfieldID FID_GSSLibStub_pMech; 77 extern jfieldID FID_NativeGSSContext_pContext; 78 extern jfieldID FID_NativeGSSContext_srcName; 79 extern jfieldID FID_NativeGSSContext_targetName; 80 extern jfieldID FID_NativeGSSContext_isInitiator; 81 extern jfieldID FID_NativeGSSContext_isEstablished; 82 extern jfieldID FID_NativeGSSContext_delegatedCred; 83 extern jfieldID FID_NativeGSSContext_flags; 84 extern jfieldID FID_NativeGSSContext_lifetime; 85 extern jfieldID FID_NativeGSSContext_actualMech; 86 #define TRACE0(s) { if (JGSS_DEBUG) { printf("[GSSLibStub:%d] %s\n", __LINE__, s); fflush(stdout); }} 87 #define TRACE1(s, p1) { if (JGSS_DEBUG) { printf("[GSSLibStub:%d] "s"\n", __LINE__, p1); fflush(stdout); }} 88 #define TRACE2(s, p1, p2) { if (JGSS_DEBUG) { printf("[GSSLibStub:%d] "s"\n", __LINE__, p1, p2); fflush(stdout); }} 89 #define TRACE3(s, p1, p2, p3) { if (JGSS_DEBUG) { printf("[GSSLibStub:%d] "s"\n", __LINE__, p1, p2, p3); fflush(stdout); }} 90 91 92 #ifdef __cplusplus 93 } 94 #endif 95 #endif 96