src/java.security.jgss/share/native/libj2gss/GSSLibStub.c
author weijun
Thu, 13 Jun 2019 10:06:07 +0800
changeset 55354 74f0622db875
parent 50244 317a8688db78
permissions -rw-r--r--
6722928: Support SSPI as a native GSS-API provider Reviewed-by: erikj, nwilliams, valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
55354
74f0622db875 6722928: Support SSPI as a native GSS-API provider
weijun
parents: 50244
diff changeset
     2
 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "sun_security_jgss_wrapper_GSSLibStub.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "NativeUtil.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "NativeFunc.h"
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
    29
#include "jlong.h"
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
    30
#include <jni.h>
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
    31
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
    32
/* Constants for indicating what type of info is needed for inquiries */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
const int TYPE_CRED_NAME = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
const int TYPE_CRED_TIME = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
const int TYPE_CRED_USAGE = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Method:    init
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    40
 * Signature: (Ljava/lang/String;Z)Z
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
Java_sun_security_jgss_wrapper_GSSLibStub_init(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                                               jclass jcls,
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    45
                                               jstring jlibName,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    46
                                               jboolean jDebug) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    const char *libName;
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    48
    int failed;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    char *error = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    51
    if (!jDebug) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    52
      JGSS_DEBUG = 0;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    53
    } else {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    54
      JGSS_DEBUG = 1;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    55
    }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    56
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    if (jlibName == NULL) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    58
        TRACE0("[GSSLibStub_init] GSS lib name is NULL");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    libName = (*env)->GetStringUTFChars(env, jlibName, NULL);
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
    63
    if (libName == NULL) {
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
    64
        return JNI_FALSE;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
    65
    }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
    66
    TRACE1("[GSSLibStub_init] libName=%s", libName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /* initialize global function table */
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    69
    failed = loadNative(libName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    (*env)->ReleaseStringUTFChars(env, jlibName, libName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    72
    if (!failed) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    } else {
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    75
        if (JGSS_DEBUG) {
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    76
#ifdef WIN32
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    77
            #define MAX_MSG_SIZE 256
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    78
            static CHAR szMsgBuf[MAX_MSG_SIZE];
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    79
            DWORD dwRes;
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    80
            DWORD dwError = GetLastError();
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    81
            dwRes = FormatMessage (
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    82
                    FORMAT_MESSAGE_FROM_SYSTEM,
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    83
                    NULL,
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    84
                    dwError,
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    85
                    0,
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    86
                    szMsgBuf,
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    87
                    MAX_MSG_SIZE,
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    88
                    NULL);
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    89
            if (0 == dwRes) {
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    90
                printf("GSS-API: Unknown failure %d\n", dwError);
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    91
            } else {
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    92
                printf("GSS-API: %s\n",szMsgBuf);
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    93
            }
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    94
#else
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    95
            char* error = dlerror();
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    96
            if (error) {
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    97
                TRACE0(error);
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    98
            }
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
    99
#endif
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   100
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * Method:    getMechPtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * Signature: ([B)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
Java_sun_security_jgss_wrapper_GSSLibStub_getMechPtr(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                                                     jclass jcls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                                                     jbyteArray jbytes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  gss_OID cOid;
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   115
  unsigned int i, len;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  jbyte* bytes;
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   117
  int found;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  if (jbytes != NULL) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   120
    found = 0;
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   121
    len = (unsigned int)((*env)->GetArrayLength(env, jbytes) - 2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    bytes = (*env)->GetByteArrayElements(env, jbytes, NULL);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   123
    if (bytes == NULL) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   124
      return ptr_to_jlong(NULL);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   125
    }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   126
    for (i = 0; i < ftab->mechs->count; i++) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   127
      cOid = &(ftab->mechs->elements[i]);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   128
      if (len == cOid->length &&
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   129
          (memcmp(cOid->elements, (bytes + 2), len) == 0)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   130
        // Found a match
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   131
        found = 1;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   132
        break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   135
    (*env)->ReleaseByteArrayElements(env, jbytes, bytes, 0);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   136
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   137
    if (found != 1) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      checkStatus(env, NULL, GSS_S_BAD_MECH, 0, "[GSSLibStub_getMechPtr]");
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   139
      return ptr_to_jlong(NULL);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   140
    } else {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   141
      return ptr_to_jlong(cOid);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   142
    }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   143
  } else {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   144
    return ptr_to_jlong(GSS_C_NO_OID);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   145
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   148
/*
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   149
 * Utility routine which releases the specified gss_channel_bindings_t
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   150
 * structure.
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   151
 */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   152
void deleteGSSCB(gss_channel_bindings_t cb) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   153
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   154
  if (cb == GSS_C_NO_CHANNEL_BINDINGS) return;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   155
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   156
  /* release initiator address */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   157
  if (cb->initiator_addrtype != GSS_C_AF_NULLADDR) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   158
    resetGSSBuffer(&(cb->initiator_address));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   159
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   160
  /* release acceptor address */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   161
  if (cb->acceptor_addrtype != GSS_C_AF_NULLADDR) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   162
    resetGSSBuffer(&(cb->acceptor_address));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   163
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   164
  /* release application data */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   165
  if (cb->application_data.length != 0) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   166
    resetGSSBuffer(&(cb->application_data));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   167
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   168
  free(cb);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   169
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * Utility routine which creates a gss_channel_bindings_t structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * using the specified org.ietf.jgss.ChannelBinding object.
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   174
 * NOTE: must call deleteGSSCB() to free up the resources.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 */
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   176
gss_channel_bindings_t newGSSCB(JNIEnv *env, jobject jcb) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  gss_channel_bindings_t cb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  jobject jinetAddr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  jbyteArray value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  if (jcb == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    return GSS_C_NO_CHANNEL_BINDINGS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  }
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   184
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
  cb = malloc(sizeof(struct gss_channel_bindings_struct));
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   186
  if (cb == NULL) {
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   187
    throwOutOfMemoryError(env,NULL);
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   188
    return NULL;
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   189
  }
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   190
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   191
  // initialize addrtype in CB first
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   192
  cb->initiator_addrtype = GSS_C_AF_NULLADDR;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   193
  cb->acceptor_addrtype = GSS_C_AF_NULLADDR;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   194
50244
317a8688db78 8194630: Uninitialized initiator_address in native GSS
valeriep
parents: 49682
diff changeset
   195
  // addresses needs to be initialized to empty
317a8688db78 8194630: Uninitialized initiator_address in native GSS
valeriep
parents: 49682
diff changeset
   196
  memset(&cb->initiator_address, 0, sizeof(cb->initiator_address));
317a8688db78 8194630: Uninitialized initiator_address in native GSS
valeriep
parents: 49682
diff changeset
   197
  memset(&cb->acceptor_address, 0, sizeof(cb->acceptor_address));
317a8688db78 8194630: Uninitialized initiator_address in native GSS
valeriep
parents: 49682
diff changeset
   198
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  /* set up initiator address */
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   200
  jinetAddr = (*env)->CallObjectMethod(env, jcb,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   201
      MID_ChannelBinding_getInitiatorAddr);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   202
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   203
    goto cleanup;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   204
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
  if (jinetAddr != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    value = (*env)->CallObjectMethod(env, jinetAddr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                     MID_InetAddress_getAddr);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   208
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   209
      goto cleanup;
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   210
    }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   211
    cb->initiator_addrtype = GSS_C_AF_INET;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   212
    initGSSBuffer(env, value, &(cb->initiator_address));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   213
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   214
      goto cleanup;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   215
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  /* set up acceptor address */
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   218
  jinetAddr = (*env)->CallObjectMethod(env, jcb,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   219
      MID_ChannelBinding_getAcceptorAddr);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   220
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   221
    goto cleanup;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   222
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
  if (jinetAddr != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    value = (*env)->CallObjectMethod(env, jinetAddr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                     MID_InetAddress_getAddr);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   226
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   227
      goto cleanup;
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   228
    }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   229
    cb->acceptor_addrtype = GSS_C_AF_INET;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   230
    initGSSBuffer(env, value, &(cb->acceptor_address));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   231
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   232
      goto cleanup;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   233
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
  /* set up application data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
  value = (*env)->CallObjectMethod(env, jcb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                                   MID_ChannelBinding_getAppData);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   238
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   239
    goto cleanup;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   240
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   241
  initGSSBuffer(env, value, &(cb->application_data));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   242
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   243
    goto cleanup;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
  return cb;
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   246
cleanup:
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   247
  deleteGSSCB(cb);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   248
  return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * Utility routine for storing the supplementary information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * into the specified org.ietf.jgss.MessageProp object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
void setSupplementaryInfo(JNIEnv *env, jobject jstub, jobject jprop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                          int suppInfo, int minor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
  jboolean isDuplicate, isOld, isUnseq, hasGap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
  jstring minorMsg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  if (suppInfo != GSS_S_COMPLETE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    isDuplicate = ((suppInfo & GSS_S_DUPLICATE_TOKEN) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    isOld = ((suppInfo & GSS_S_OLD_TOKEN) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    isUnseq = ((suppInfo & GSS_S_UNSEQ_TOKEN) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    hasGap = ((suppInfo & GSS_S_GAP_TOKEN) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    minorMsg = getMinorMessage(env, jstub, minor);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   266
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   267
      return;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   268
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setSupplementaryStates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                           isDuplicate, isOld, isUnseq, hasGap, minor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                           minorMsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
 * Method:    indicateMechs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
 * Signature: ()[Lorg/ietf/jgss/Oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
JNIEXPORT jobjectArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
Java_sun_security_jgss_wrapper_GSSLibStub_indicateMechs(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                                                        jclass jcls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
  if (ftab->mechs != NULL && ftab->mechs != GSS_C_NO_OID_SET) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    return getJavaOIDArray(env, ftab->mechs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
  } else return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 * Method:    inquireNamesForMech
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 * Signature: ()[Lorg/ietf/jgss/Oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
JNIEXPORT jobjectArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
Java_sun_security_jgss_wrapper_GSSLibStub_inquireNamesForMech(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                                                              jobject jobj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
  gss_OID mech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
  gss_OID_set nameTypes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
  jobjectArray result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
  if (ftab->inquireNamesForMech != NULL) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   304
    mech = (gss_OID)jlong_to_ptr((*env)->GetLongField(env, jobj, FID_GSSLibStub_pMech));
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   305
    nameTypes = GSS_C_NO_OID_SET;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   307
    /* gss_inquire_names_for_mech(...) => N/A */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   308
    major = (*ftab->inquireNamesForMech)(&minor, mech, &nameTypes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   310
    /* release intermediate buffers before checking status */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   311
    result = getJavaOIDArray(env, nameTypes);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   312
    deleteGSSOIDSet(nameTypes);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   313
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   314
      return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   315
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   317
    checkStatus(env, jobj, major, minor, "[GSSLibStub_inquireNamesForMech]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   318
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   319
      return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   320
    }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   321
    return result;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   322
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   323
  return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
 * Method:    releaseName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
Java_sun_security_jgss_wrapper_GSSLibStub_releaseName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                                      jlong pName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
  gss_name_t nameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   339
  nameHdl = (gss_name_t) jlong_to_ptr(pName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   341
  TRACE1("[GSSLibStub_releaseName] %ld", (long) pName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
  if (nameHdl != GSS_C_NO_NAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    /* gss_release_name(...) => GSS_S_BAD_NAME */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    major = (*ftab->releaseName)(&minor, &nameHdl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    checkStatus(env, jobj, major, minor, "[GSSLibStub_releaseName]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
 * Method:    importName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
 * Signature: ([BLorg/ietf/jgss/Oid;)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
Java_sun_security_jgss_wrapper_GSSLibStub_importName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                                                     jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                                                     jbyteArray jnameVal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                                                     jobject jnameType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
  gss_buffer_desc nameVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
  gss_OID nameType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
  gss_name_t nameHdl;
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   365
  nameHdl = GSS_C_NO_NAME;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   367
  TRACE0("[GSSLibStub_importName]");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   369
  initGSSBuffer(env, jnameVal, &nameVal);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   370
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   371
      return jlong_zero;
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   372
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   373
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
  nameType = newGSSOID(env, jnameType);
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   375
  if ((*env)->ExceptionCheck(env)) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   376
    resetGSSBuffer(&nameVal);
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   377
    return jlong_zero;
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   378
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
  /* gss_import_name(...) => GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     GSS_S_BAD_MECH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
  major = (*ftab->importName)(&minor, &nameVal, nameType, &nameHdl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   384
  TRACE1("[GSSLibStub_importName] %" PRIuPTR  "", (uintptr_t) nameHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
  /* release intermediate buffers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
  deleteGSSOID(nameType);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   388
  resetGSSBuffer(&nameVal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
  checkStatus(env, jobj, major, minor, "[GSSLibStub_importName]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   391
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   392
    return jlong_zero;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   393
  }
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   394
  return ptr_to_jlong(nameHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
 * Method:    compareName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
 * Signature: (JJ)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
Java_sun_security_jgss_wrapper_GSSLibStub_compareName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                                                      jlong pName1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                                                      jlong pName2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
  gss_name_t nameHdl1, nameHdl2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
  int isEqual;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
  isEqual = 0;
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   414
  nameHdl1 = (gss_name_t) jlong_to_ptr(pName1);
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   415
  nameHdl2 = (gss_name_t) jlong_to_ptr(pName2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   417
  TRACE2("[GSSLibStub_compareName] %ld %ld", (long)pName1, (long)pName2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
  if ((nameHdl1 != GSS_C_NO_NAME) && (nameHdl2 != GSS_C_NO_NAME)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /* gss_compare_name(...) => GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    major = (*ftab->compareName)(&minor, nameHdl1, nameHdl2, &isEqual);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    checkStatus(env, jobj, major, minor, "[GSSLibStub_compareName]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
  return (isEqual != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
 * Method:    canonicalizeName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
Java_sun_security_jgss_wrapper_GSSLibStub_canonicalizeName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                                                           jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                                                           jlong pName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  gss_name_t nameHdl, mnNameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
  gss_OID mech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   443
  nameHdl = (gss_name_t) jlong_to_ptr(pName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   444
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   445
  TRACE1("[GSSLibStub_canonicalizeName] %ld", (long) pName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
  if (nameHdl != GSS_C_NO_NAME) {
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   448
    mech = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jobj, FID_GSSLibStub_pMech));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    mnNameHdl = GSS_C_NO_NAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    /* gss_canonicalize_name(...) may return GSS_S_BAD_NAMETYPE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
       GSS_S_BAD_NAME, GSS_S_BAD_MECH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    major = (*ftab->canonicalizeName)(&minor, nameHdl, mech, &mnNameHdl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   455
    TRACE1("[GSSLibStub_canonicalizeName] MN=%" PRIuPTR "", (uintptr_t)mnNameHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    checkStatus(env, jobj, major, minor, "[GSSLibStub_canonicalizeName]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   458
    if ((*env)->ExceptionCheck(env)) {
29491
821faf99fb06 8074836: Resolve disabled warnings for libosxkrb5
weijun
parents: 25859
diff changeset
   459
      return ptr_to_jlong(GSS_C_NO_NAME);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   460
    }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   461
    return ptr_to_jlong(mnNameHdl);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   462
  }
29491
821faf99fb06 8074836: Resolve disabled warnings for libosxkrb5
weijun
parents: 25859
diff changeset
   463
  return ptr_to_jlong(GSS_C_NO_NAME);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
 * Method:    exportName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
 * Signature: (J)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
Java_sun_security_jgss_wrapper_GSSLibStub_exportName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                                     jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                                                     jlong pName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
  gss_name_t nameHdl, mNameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
  gss_buffer_desc outBuf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
  jbyteArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   480
  nameHdl = (gss_name_t) jlong_to_ptr(pName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   481
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   482
  TRACE1("[GSSLibStub_exportName] %ld", (long) pName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
  /* gss_export_name(...) => GSS_S_NAME_NOT_MN, GSS_S_BAD_NAMETYPE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     GSS_S_BAD_NAME */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
  major = (*ftab->exportName)(&minor, nameHdl, &outBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
  /* canonicalize the internal name to MN and retry */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
  if (major == GSS_S_NAME_NOT_MN) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   490
    /* release intermediate buffers before retrying */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   491
    (*ftab->releaseBuffer)(&minor, &outBuf);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   492
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   493
    TRACE0("[GSSLibStub_exportName] canonicalize and re-try");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   495
    mNameHdl = (gss_name_t)jlong_to_ptr(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        Java_sun_security_jgss_wrapper_GSSLibStub_canonicalizeName
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   497
                                        (env, jobj, pName));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    if ((*env)->ExceptionCheck(env)) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   499
        return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   501
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    major = (*ftab->exportName)(&minor, mNameHdl, &outBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    Java_sun_security_jgss_wrapper_GSSLibStub_releaseName
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   504
                                        (env, jobj, ptr_to_jlong(mNameHdl));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    if ((*env)->ExceptionCheck(env)) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   506
      /* release intermediate buffers */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   507
      (*ftab->releaseBuffer)(&minor, &outBuf);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
      return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   512
  /* release intermediate buffers before checking status */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
  jresult = getJavaBuffer(env, &outBuf);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   514
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   515
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   516
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
  checkStatus(env, jobj, major, minor, "[GSSLibStub_exportName]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   519
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   520
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   521
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
 * Method:    displayName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
 * Signature: (J)[Ljava/lang/Object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
JNIEXPORT jobjectArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
Java_sun_security_jgss_wrapper_GSSLibStub_displayName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                                      jlong pName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
  gss_name_t nameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
  gss_buffer_desc outNameBuf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
  gss_OID outNameType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
  jstring jname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
  jobject jtype;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
  jobjectArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   542
  nameHdl = (gss_name_t) jlong_to_ptr(pName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   543
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   544
  TRACE1("[GSSLibStub_displayName] %ld", (long) pName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
  if (nameHdl == GSS_C_NO_NAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    checkStatus(env, jobj, GSS_S_BAD_NAME, 0, "[GSSLibStub_displayName]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
  /* gss_display_name(...) => GSS_S_BAD_NAME */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
  major = (*ftab->displayName)(&minor, nameHdl, &outNameBuf, &outNameType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   554
  /* release intermediate buffers before checking status */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
  jname = getJavaString(env, &outNameBuf);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   556
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   557
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   558
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   559
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   560
  checkStatus(env, jobj, major, minor, "[GSSLibStub_displayName]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   561
  if ((*env)->ExceptionCheck(env)) {
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   562
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   563
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
  jtype = getJavaOID(env, outNameType);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   566
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   567
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   568
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   569
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
  jresult = (*env)->NewObjectArray(env, 2, CLS_Object, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
  if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
  (*env)->SetObjectArrayElement(env, jresult, 0, jname);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   577
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   578
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   579
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
  (*env)->SetObjectArrayElement(env, jresult, 1, jtype);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   581
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   582
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   583
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
 * Method:    acquireCred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
 * Signature: (JII)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
Java_sun_security_jgss_wrapper_GSSLibStub_acquireCred(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                                                      jlong pName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                                                      jint reqTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                                                      jint usage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
  gss_OID mech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
  gss_OID_set mechs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
  gss_cred_usage_t credUsage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
  gss_name_t nameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
  gss_cred_id_t credHdl;
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   606
  credHdl = GSS_C_NO_CREDENTIAL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   608
  TRACE0("[GSSLibStub_acquireCred]");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   610
  mech = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jobj, FID_GSSLibStub_pMech));
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   611
  mechs = newGSSOIDSet(mech);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
  credUsage = (gss_cred_usage_t) usage;
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   613
  nameHdl = (gss_name_t) jlong_to_ptr(pName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   615
  TRACE2("[GSSLibStub_acquireCred] pName=%ld, usage=%d", (long)pName, usage);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
  /* gss_acquire_cred(...) => GSS_S_BAD_MECH, GSS_S_BAD_NAMETYPE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     GSS_S_BAD_NAME, GSS_S_CREDENTIALS_EXPIRED, GSS_S_NO_CRED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
  major =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    (*ftab->acquireCred)(&minor, nameHdl, reqTime, mechs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                     credUsage, &credHdl, NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
  /* release intermediate buffers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
  deleteGSSOIDSet(mechs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   625
  TRACE1("[GSSLibStub_acquireCred] pCred=%" PRIuPTR "", (uintptr_t) credHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
  checkStatus(env, jobj, major, minor, "[GSSLibStub_acquireCred]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   628
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   629
    return jlong_zero;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   630
  }
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   631
  return ptr_to_jlong(credHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
 * Method:    releaseCred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
Java_sun_security_jgss_wrapper_GSSLibStub_releaseCred(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                                                      jlong pCred)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
  gss_cred_id_t credHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   647
  credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   649
  TRACE1("[GSSLibStub_releaseCred] %ld", (long int)pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
  if (credHdl != GSS_C_NO_CREDENTIAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    /* gss_release_cred(...) => GSS_S_NO_CRED(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    major = (*ftab->releaseCred)(&minor, &credHdl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    checkStatus(env, jobj, major, minor, "[GSSLibStub_releaseCred]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   656
    if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   657
      return jlong_zero;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   658
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
  }
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   660
  return ptr_to_jlong(credHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
 * Utility routine for obtaining info about a credential.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
void inquireCred(JNIEnv *env, jobject jobj, gss_cred_id_t pCred,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                 jint type, void *result) {
25216
291541db1e11 8048511: Uninitialised memory in jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c
weijun
parents: 23585
diff changeset
   668
  OM_uint32 minor=0, major=0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
  OM_uint32 routineErr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
  gss_cred_id_t credHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
  credHdl = pCred;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   674
  TRACE1("[gss_inquire_cred] %" PRIuPTR "", (uintptr_t) pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
  /* gss_inquire_cred(...) => GSS_S_DEFECTIVE_CREDENTIAL(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     GSS_S_CREDENTIALS_EXPIRED(!), GSS_S_NO_CRED(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
  if (type == TYPE_CRED_NAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    major = (*ftab->inquireCred)(&minor, credHdl, result, NULL, NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
  } else if (type == TYPE_CRED_TIME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    major = (*ftab->inquireCred)(&minor, credHdl, NULL, result, NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
  } else if (type == TYPE_CRED_USAGE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    major = (*ftab->inquireCred)(&minor, credHdl, NULL, NULL, result, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
  routineErr = GSS_ROUTINE_ERROR(major);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
  if (routineErr == GSS_S_CREDENTIALS_EXPIRED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    /* ignore GSS_S_CREDENTIALS_EXPIRED for query  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    major = GSS_CALLING_ERROR(major) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
      GSS_SUPPLEMENTARY_INFO(major);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
  } else if (routineErr == GSS_S_NO_CRED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    /* twik since Java API throws BAD_MECH instead of NO_CRED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    major = GSS_CALLING_ERROR(major) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
      GSS_S_BAD_MECH  | GSS_SUPPLEMENTARY_INFO(major);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
  checkStatus(env, jobj, major, minor, "[gss_inquire_cred]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
 * Method:    getCredName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
Java_sun_security_jgss_wrapper_GSSLibStub_getCredName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                                                      jlong pCred)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
  gss_name_t nameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
  gss_cred_id_t credHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   712
  credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   714
  TRACE1("[GSSLibStub_getCredName] %ld", (long int)pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
  nameHdl = GSS_C_NO_NAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
  inquireCred(env, jobj, credHdl, TYPE_CRED_NAME, &nameHdl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
  if ((*env)->ExceptionCheck(env)) {
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   720
    return jlong_zero;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   723
  TRACE1("[GSSLibStub_getCredName] pName=%" PRIuPTR "", (uintptr_t) nameHdl);
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   724
  return ptr_to_jlong(nameHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
 * Method:    getCredTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
 * Signature: (J)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
Java_sun_security_jgss_wrapper_GSSLibStub_getCredTime(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                                                      jlong pCred)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
  gss_cred_id_t credHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
  OM_uint32 lifetime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   740
  credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   742
  TRACE1("[GSSLibStub_getCredTime] %ld", (long int)pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
  lifetime = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
  inquireCred(env, jobj, credHdl, TYPE_CRED_TIME, &lifetime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
  if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
  return getJavaTime(lifetime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
 * Method:    getCredUsage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
 * Signature: (J)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
Java_sun_security_jgss_wrapper_GSSLibStub_getCredUsage(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                                                       jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                                                       jlong pCred)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
  gss_cred_usage_t usage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
  gss_cred_id_t credHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   766
  credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   768
  TRACE1("[GSSLibStub_getCredUsage] %ld", (long int)pCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
  inquireCred(env, jobj, credHdl, TYPE_CRED_USAGE, &usage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
  if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
  return (jint) usage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
 * Method:    importContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
 * Signature: ([B)Lsun/security/jgss/wrapper/NativeGSSContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
Java_sun_security_jgss_wrapper_GSSLibStub_importContext(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                                                        jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                                                        jbyteArray jctxtToken)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
  gss_buffer_desc ctxtToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
  gss_OID mech, mech2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   792
  TRACE0("[GSSLibStub_importContext]");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
  contextHdl = GSS_C_NO_CONTEXT;
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   795
  initGSSBuffer(env, jctxtToken, &ctxtToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   796
  if ((*env)->ExceptionCheck(env)) {
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   797
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   798
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
  /* gss_import_sec_context(...) => GSS_S_NO_CONTEXT, GSS_S_DEFECTIVE_TOKEN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     GSS_S_UNAVAILABLE, GSS_S_UNAUTHORIZED */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
  major = (*ftab->importSecContext)(&minor, &ctxtToken, &contextHdl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   804
  TRACE1("[GSSLibStub_importContext] pContext=%" PRIuPTR "", (uintptr_t) contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
  /* release intermediate buffers */
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   807
  resetGSSBuffer(&ctxtToken);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
  checkStatus(env, jobj, major, minor, "[GSSLibStub_importContext]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
  if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
  /* now that the context has been imported, proceed to find out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     its mech */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
  major = (*ftab->inquireContext)(&minor, contextHdl, NULL, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                              NULL, &mech, NULL, NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
  checkStatus(env, jobj, major, minor, "[GSSLibStub_importContext] getMech");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
  if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   826
  mech2 = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jobj,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   827
      FID_GSSLibStub_pMech));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   829
  if (sameMech(mech, mech2) == JNI_TRUE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /* mech match - return the context object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    return (*env)->NewObject(env, CLS_NativeGSSContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                                 MID_NativeGSSContext_ctor,
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   833
                                 ptr_to_jlong(contextHdl), jobj);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    /* mech mismatch - clean up then return null */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    major = (*ftab->deleteSecContext)(&minor, &contextHdl, GSS_C_NO_BUFFER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    checkStatus(env, jobj, major, minor,
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   838
        "[GSSLibStub_importContext] cleanup");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
}
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   842
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
 * Method:    initContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
 * Signature: (JJLorg/ietf/jgss/ChannelBinding;[BLsun/security/jgss/wrapper/NativeGSSContext;)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
Java_sun_security_jgss_wrapper_GSSLibStub_initContext(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                                                      jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                                                      jlong pCred,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                                                      jlong pName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                                                      jobject jcb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                                                      jbyteArray jinToken,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                                                      jobject jcontextSpi)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
  gss_cred_id_t credHdl ;
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   859
  gss_ctx_id_t contextHdl, contextHdlSave;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
  gss_name_t targetName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
  gss_OID mech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
  OM_uint32 flags, aFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
  OM_uint32 time, aTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
  gss_channel_bindings_t cb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
  gss_buffer_desc inToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
  gss_buffer_desc outToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
  jbyteArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
/* UNCOMMENT after SEAM bug#6287358 is backported to S10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
  gss_OID aMech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
  jobject jMech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
*/
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   872
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   873
  TRACE0("[GSSLibStub_initContext]");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   875
  credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   876
  contextHdl = contextHdlSave = (gss_ctx_id_t) jlong_to_ptr(
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   877
    (*env)->GetLongField(env, jcontextSpi, FID_NativeGSSContext_pContext));
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   878
  targetName = (gss_name_t) jlong_to_ptr(pName);
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   879
  mech = (gss_OID) jlong_to_ptr((*env)->GetLongField(env, jobj, FID_GSSLibStub_pMech));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
  flags = (OM_uint32) (*env)->GetIntField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                                          FID_NativeGSSContext_flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
  time = getGSSTime((*env)->GetIntField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                                        FID_NativeGSSContext_lifetime));
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   884
  cb = newGSSCB(env, jcb);
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   885
  if ((*env)->ExceptionCheck(env)) {
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   886
    return NULL;
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   887
  }
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
   888
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   889
  initGSSBuffer(env, jinToken, &inToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   890
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   891
    deleteGSSCB(cb);
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   892
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   893
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   895
  TRACE2( "[GSSLibStub_initContext] before: pCred=%" PRIuPTR ", pContext=%" PRIuPTR "",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   896
          (uintptr_t)credHdl, (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
  /* gss_init_sec_context(...) => GSS_S_CONTINUE_NEEDED(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     GSS_S_DEFECTIVE_TOKEN, GSS_S_NO_CRED, GSS_S_DEFECTIVE_CREDENTIAL(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     GSS_S_CREDENTIALS_EXPIRED, GSS_S_BAD_BINDINGS, GSS_S_BAD_MIC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     GSS_S_OLD_TOKEN, GSS_S_DUPLICATE_TOKEN, GSS_S_NO_CONTEXT(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     GSS_S_BAD_NAMETYPE, GSS_S_BAD_NAME(!), GSS_S_BAD_MECH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
  major = (*ftab->initSecContext)(&minor, credHdl,
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   904
                                 &contextHdl, targetName, mech,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   905
                                 flags, time, cb, &inToken, NULL /*aMech*/,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   906
                                 &outToken, &aFlags, &aTime);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   908
  TRACE2("[GSSLibStub_initContext] after: pContext=%" PRIuPTR ", outToken len=%ld",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   909
            (uintptr_t)contextHdl, (long)outToken.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   911
  // update context handle with the latest value if changed
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   912
  // this is to work with both MIT and Solaris. Former deletes half-built
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   913
  // context if error occurs
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   914
  if (contextHdl != contextHdlSave) {
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   915
    (*env)->SetLongField(env, jcontextSpi, FID_NativeGSSContext_pContext,
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   916
                         ptr_to_jlong(contextHdl));
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
   917
    TRACE1("[GSSLibStub_initContext] set pContext=%" PRIuPTR "", (uintptr_t)contextHdl);
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   918
  }
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   919
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
  if (GSS_ERROR(major) == GSS_S_COMPLETE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    /* update member values if needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    (*env)->SetIntField(env, jcontextSpi, FID_NativeGSSContext_flags, aFlags);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   923
    TRACE1("[GSSLibStub_initContext] set flags=0x%x", aFlags);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    if (major == GSS_S_COMPLETE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
      (*env)->SetIntField(env, jcontextSpi, FID_NativeGSSContext_lifetime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                          getJavaTime(aTime));
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   928
      TRACE0("[GSSLibStub_initContext] context established");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
      (*env)->SetBooleanField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                              FID_NativeGSSContext_isEstablished,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                              JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
/* UNCOMMENT after SEAM bug#6287358 is backported to S10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
      jMech = getJavaOID(env, aMech);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
      (*env)->SetObjectField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                             FID_NativeGSSContext_actualMech, jMech);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    } else if (major & GSS_S_CONTINUE_NEEDED) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   940
      TRACE0("[GSSLibStub_initContext] context not established");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
      major -= GSS_S_CONTINUE_NEEDED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   944
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   945
  /* release intermediate buffers before checking status */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   946
  deleteGSSCB(cb);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   947
  resetGSSBuffer(&inToken);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
  jresult = getJavaBuffer(env, &outToken);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   949
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   950
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   951
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
  checkStatus(env, jobj, major, minor, "[GSSLibStub_initContext]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   954
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   955
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   956
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
 * Method:    acceptContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
 * Signature: (JLorg/ietf/jgss/ChannelBinding;[BLsun/security/jgss/wrapper/NativeGSSContext;)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                                                        jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                                                        jlong pCred,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                                                        jobject jcb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                                                        jbyteArray jinToken,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                                                        jobject jcontextSpi)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
  OM_uint32 minor2, major2;
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   975
  gss_ctx_id_t contextHdl, contextHdlSave;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
  gss_cred_id_t credHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
  gss_buffer_desc inToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
  gss_channel_bindings_t cb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
  gss_name_t srcName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
  gss_buffer_desc outToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
  gss_OID aMech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
  OM_uint32 aFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
  OM_uint32 aTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
  gss_cred_id_t delCred;
55354
74f0622db875 6722928: Support SSPI as a native GSS-API provider
weijun
parents: 50244
diff changeset
   985
  jobject jsrcName = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
  jobject jdelCred;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
  jobject jMech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
  jboolean setTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
  gss_name_t targetName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
  jobject jtargetName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   992
  TRACE0("[GSSLibStub_acceptContext]");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
   994
  contextHdl = contextHdlSave = (gss_ctx_id_t)jlong_to_ptr(
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   995
    (*env)->GetLongField(env, jcontextSpi, FID_NativeGSSContext_pContext));
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
   996
  credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   997
  initGSSBuffer(env, jinToken, &inToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
   998
  if ((*env)->ExceptionCheck(env)) {
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
   999
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1000
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1001
  cb = newGSSCB(env, jcb);
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
  1002
  if ((*env)->ExceptionCheck(env)) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1003
    resetGSSBuffer(&inToken);
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
  1004
    return NULL;
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
  1005
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1006
  srcName = targetName = GSS_C_NO_NAME;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
  delCred = GSS_C_NO_CREDENTIAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
  setTarget = (credHdl == GSS_C_NO_CREDENTIAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
  aFlags = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1011
  TRACE2( "[GSSLibStub_acceptContext] before: pCred=%" PRIuPTR ", pContext=%" PRIuPTR "",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1012
          (uintptr_t) credHdl, (uintptr_t) contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
  /* gss_accept_sec_context(...) => GSS_S_CONTINUE_NEEDED(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     GSS_S_DEFECTIVE_TOKEN, GSS_S_DEFECTIVE_CREDENTIAL(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     GSS_S_NO_CRED, GSS_S_CREDENTIALS_EXPIRED, GSS_S_BAD_BINDINGS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     GSS_S_NO_CONTEXT(!), GSS_S_BAD_MIC, GSS_S_OLD_TOKEN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     GSS_S_DUPLICATE_TOKEN, GSS_S_BAD_MECH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
  major =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    (*ftab->acceptSecContext)(&minor, &contextHdl, credHdl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                           &inToken, cb, &srcName, &aMech, &outToken,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                           &aFlags, &aTime, &delCred);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1023
  /* release intermediate buffers before checking status */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1025
  deleteGSSCB(cb);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1026
  resetGSSBuffer(&inToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1027
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1028
  TRACE3("[GSSLibStub_acceptContext] after: pCred=%" PRIuPTR ", pContext=%" PRIuPTR ", pDelegCred=%" PRIuPTR "",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1029
        (uintptr_t)credHdl, (uintptr_t)contextHdl, (uintptr_t) delCred);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1031
  // update context handle with the latest value if changed
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1032
  // this is to work with both MIT and Solaris. Former deletes half-built
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1033
  // context if error occurs
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1034
  if (contextHdl != contextHdlSave) {
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1035
    (*env)->SetLongField(env, jcontextSpi, FID_NativeGSSContext_pContext,
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1036
                         ptr_to_jlong(contextHdl));
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1037
    TRACE1("[GSSLibStub_acceptContext] set pContext=%" PRIuPTR "", (uintptr_t)contextHdl);
48571
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1038
  }
cd23d1f99660 8186212: Improve GSS handling
valeriep
parents: 48049
diff changeset
  1039
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
  if (GSS_ERROR(major) == GSS_S_COMPLETE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    /* update member values if needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    // WORKAROUND for a Heimdal bug
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    if (delCred == GSS_C_NO_CREDENTIAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        aFlags &= 0xfffffffe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    (*env)->SetIntField(env, jcontextSpi, FID_NativeGSSContext_flags, aFlags);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1047
    TRACE1("[GSSLibStub_acceptContext] set flags=0x%x", aFlags);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1048
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    if (setTarget) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
      major2 = (*ftab->inquireContext)(&minor2, contextHdl, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                              &targetName, NULL, NULL, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                              NULL, NULL);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1053
      checkStatus(env, jobj, major2, minor2,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1054
                    "[GSSLibStub_acceptContext] inquire");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1055
      if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1056
         goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1057
      }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1058
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
      jtargetName = (*env)->NewObject(env, CLS_GSSNameElement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                                MID_GSSNameElement_ctor,
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1061
                                ptr_to_jlong(targetName), jobj);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1062
      if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1063
        goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1064
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1066
      TRACE1("[GSSLibStub_acceptContext] set targetName=%" PRIuPTR "",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1067
              (uintptr_t)targetName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1068
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
      (*env)->SetObjectField(env, jcontextSpi, FID_NativeGSSContext_targetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                             jtargetName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1071
      if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1072
        goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1073
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    if (srcName != GSS_C_NO_NAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
      jsrcName = (*env)->NewObject(env, CLS_GSSNameElement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                                   MID_GSSNameElement_ctor,
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1078
                                   ptr_to_jlong(srcName), jobj);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
      if ((*env)->ExceptionCheck(env)) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1080
        goto error;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
      }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1082
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1083
      TRACE1("[GSSLibStub_acceptContext] set srcName=%" PRIuPTR "", (uintptr_t)srcName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1084
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
      (*env)->SetObjectField(env, jcontextSpi, FID_NativeGSSContext_srcName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                             jsrcName);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1087
      if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1088
        goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1089
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    if (major == GSS_S_COMPLETE) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1092
      TRACE0("[GSSLibStub_acceptContext] context established");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
      (*env)->SetIntField(env, jcontextSpi, FID_NativeGSSContext_lifetime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                          getJavaTime(aTime));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
      (*env)->SetBooleanField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
                              FID_NativeGSSContext_isEstablished,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                              JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
      jMech = getJavaOID(env, aMech);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1100
      if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1101
        goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1102
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
      (*env)->SetObjectField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                             FID_NativeGSSContext_actualMech, jMech);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1105
      if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1106
        goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1107
      }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
      if (delCred != GSS_C_NO_CREDENTIAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        jdelCred = (*env)->NewObject(env, CLS_GSSCredElement,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                                     MID_GSSCredElement_ctor,
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1111
                                     ptr_to_jlong(delCred), jsrcName, jMech);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        if ((*env)->ExceptionCheck(env)) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1113
          goto error;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
        (*env)->SetObjectField(env, jcontextSpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                               FID_NativeGSSContext_delegatedCred,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                               jdelCred);
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1118
        TRACE1("[GSSLibStub_acceptContext] set delegatedCred=%" PRIuPTR "",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1119
                (uintptr_t) delCred);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1120
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1121
        if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1122
          goto error;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1123
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    } else if (major & GSS_S_CONTINUE_NEEDED) {
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1126
      TRACE0("[GSSLibStub_acceptContext] context not established");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
      if (aFlags & GSS_C_PROT_READY_FLAG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        (*env)->SetIntField(env, jcontextSpi, FID_NativeGSSContext_lifetime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                            getJavaTime(aTime));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
      major -= GSS_S_CONTINUE_NEEDED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1135
  return getJavaBuffer(env, &outToken);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1137
error:
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1138
  (*ftab->releaseBuffer)(&minor, &outToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1139
  if (srcName != GSS_C_NO_NAME) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1140
    (*ftab->releaseName)(&minor, &srcName);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1141
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1142
  if (targetName != GSS_C_NO_NAME) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1143
    (*ftab->releaseName)(&minor, &targetName);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1144
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1145
  if (delCred != GSS_C_NO_CREDENTIAL) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1146
    (*ftab->releaseCred) (&minor, &delCred);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1147
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1148
  return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
 * Method:    inquireContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
 * Signature: (J)[J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
JNIEXPORT jlongArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
Java_sun_security_jgss_wrapper_GSSLibStub_inquireContext(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                                                         jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                                                         jlong pContext)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
  gss_name_t srcName, targetName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
  OM_uint32 time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
  OM_uint32 flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
  int isInitiator, isEstablished;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
  jlong result[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
  jlongArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1170
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1172
  TRACE1("[GSSLibStub_inquireContext] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
  srcName = targetName = GSS_C_NO_NAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
  time = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
  flags = isInitiator = isEstablished = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
  /* gss_inquire_context(...) => GSS_S_NO_CONTEXT(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
  major = (*ftab->inquireContext)(&minor, contextHdl, &srcName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                              &targetName, &time, NULL, &flags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                              &isInitiator, &isEstablished);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
  /* update member values if needed */
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1183
  TRACE2("[GSSLibStub_inquireContext] srcName %" PRIuPTR ", targetName %" PRIuPTR "",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1184
      (uintptr_t)srcName, (uintptr_t)targetName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1186
  checkStatus(env, jobj, major, minor, "[GSSLibStub_inquireContext]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1187
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1188
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1189
  }
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1190
  result[0] = ptr_to_jlong(srcName);
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1191
  result[1] = ptr_to_jlong(targetName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
  result[2] = (jlong) isInitiator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
  result[3] = (jlong) isEstablished;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
  result[4] = (jlong) flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
  result[5] = (jlong) getJavaTime(time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
  jresult = (*env)->NewLongArray(env, 6);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1198
  if (jresult == NULL) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1199
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1200
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
  (*env)->SetLongArrayRegion(env, jresult, 0, 6, result);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1202
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1203
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1204
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
 * Method:    getContextMech
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
 * Signature: (J)Lorg/ietf/jgss/Oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
Java_sun_security_jgss_wrapper_GSSLibStub_getContextMech(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                                                         jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                                                         jlong pContext)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
  gss_OID mech;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1222
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1224
  TRACE1("[GSSLibStub_getContextMech] %ld", (long int)pContext);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
  major = (*ftab->inquireContext)(&minor, contextHdl, NULL, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                                NULL, &mech, NULL,  NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
  checkStatus(env, jobj, major, minor, "[GSSLibStub_getContextMech]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
  if ((*env)->ExceptionCheck(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
  return getJavaOID(env, mech);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
 * Method:    getContextName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
 * Signature: (JZ)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
Java_sun_security_jgss_wrapper_GSSLibStub_getContextName(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
  jobject jobj, jlong pContext, jboolean isSrc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
  gss_name_t nameHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1251
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1253
  TRACE2("[GSSLibStub_getContextName] %" PRIuPTR ", isSrc=%d",
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1254
          (uintptr_t)contextHdl, isSrc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
  nameHdl = GSS_C_NO_NAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
  if (isSrc == JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
    major = (*ftab->inquireContext)(&minor, contextHdl, &nameHdl, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                                NULL, NULL, NULL,  NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
    major = (*ftab->inquireContext)(&minor, contextHdl, NULL, &nameHdl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                                NULL, NULL, NULL,  NULL, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
  checkStatus(env, jobj, major, minor, "[GSSLibStub_inquireContextAll]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
  /* return immediately if an exception has occurred */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
  if ((*env)->ExceptionCheck(env)) {
16488
816b9df68a9f 8007607: security native code doesn't always use malloc, realloc, and calloc correctly
jzavgren
parents: 14517
diff changeset
  1268
    return jlong_zero;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1271
  TRACE1("[GSSLibStub_getContextName] pName=%" PRIuPTR "", (uintptr_t) nameHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1273
  return ptr_to_jlong(nameHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
 * Method:    getContextTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
 * Signature: (J)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
Java_sun_security_jgss_wrapper_GSSLibStub_getContextTime(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                                                         jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                                                         jlong pContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
  OM_uint32 time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1289
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1290
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1291
  TRACE1("[GSSLibStub_getContextTime] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
  if (contextHdl == GSS_C_NO_CONTEXT) return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
  /* gss_context_time(...) => GSS_S_CONTEXT_EXPIRED(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
     GSS_S_NO_CONTEXT(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
  major = (*ftab->contextTime)(&minor, contextHdl, &time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
  if (GSS_ROUTINE_ERROR(major) == GSS_S_CONTEXT_EXPIRED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
    major = GSS_CALLING_ERROR(major) | GSS_SUPPLEMENTARY_INFO(major);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
  checkStatus(env, jobj, major, minor, "[GSSLibStub_getContextTime]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1302
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1303
    return 0;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1304
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
  return getJavaTime(time);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
 * Method:    deleteContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
 * Signature: (J)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
Java_sun_security_jgss_wrapper_GSSLibStub_deleteContext(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
                                                        jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
                                                        jlong pContext)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1321
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1322
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1323
  TRACE1("[GSSLibStub_deleteContext] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1325
  if (contextHdl == GSS_C_NO_CONTEXT) return ptr_to_jlong(GSS_C_NO_CONTEXT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
  /* gss_delete_sec_context(...) => GSS_S_NO_CONTEXT(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
  major = (*ftab->deleteSecContext)(&minor, &contextHdl, GSS_C_NO_BUFFER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
  checkStatus(env, jobj, major, minor, "[GSSLibStub_deleteContext]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1331
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1332
    return jlong_zero;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1333
  }
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1334
  return (jlong) ptr_to_jlong(contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
 * Method:    wrapSizeLimit
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
 * Signature: (JIII)I
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
Java_sun_security_jgss_wrapper_GSSLibStub_wrapSizeLimit(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                                                        jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
                                                        jlong pContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                                                        jint reqFlag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
                                                        jint jqop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
                                                        jint joutSize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
  OM_uint32 outSize, maxInSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
  gss_qop_t qop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1355
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1356
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1357
  TRACE1("[GSSLibStub_wrapSizeLimit] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1359
  if (contextHdl == GSS_C_NO_CONTEXT) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1360
    // Twik per javadoc
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1361
    checkStatus(env, jobj, GSS_S_NO_CONTEXT, 0,
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1362
        "[GSSLibStub_wrapSizeLimit]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1363
    return 0;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1364
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
  qop = (gss_qop_t) jqop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
  outSize = (OM_uint32) joutSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
  /* gss_wrap_size_limit(...) => GSS_S_NO_CONTEXT(!), GSS_S_CONTEXT_EXPIRED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     GSS_S_BAD_QOP */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
  major = (*ftab->wrapSizeLimit)(&minor, contextHdl, reqFlag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
                              qop, outSize, &maxInSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
  checkStatus(env, jobj, major, minor, "[GSSLibStub_wrapSizeLimit]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1374
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1375
    return 0;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1376
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
  return (jint) maxInSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
 * Method:    exportContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
 * Signature: (J)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
Java_sun_security_jgss_wrapper_GSSLibStub_exportContext(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
                                                        jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
                                                        jlong pContext)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
  gss_buffer_desc interProcToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
  jbyteArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1395
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1396
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1397
  TRACE1("[GSSLibStub_exportContext] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
  if (contextHdl == GSS_C_NO_CONTEXT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
    // Twik per javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
    checkStatus(env, jobj, GSS_S_NO_CONTEXT, 0, "[GSSLibStub_exportContext]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
  /* gss_export_sec_context(...) => GSS_S_CONTEXT_EXPIRED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
     GSS_S_NO_CONTEXT, GSS_S_UNAVAILABLE */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
  major =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    (*ftab->exportSecContext)(&minor, &contextHdl, &interProcToken);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
  /* release intermediate buffers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
  jresult = getJavaBuffer(env, &interProcToken);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1411
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1412
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1413
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
  checkStatus(env, jobj, major, minor, "[GSSLibStub_exportContext]");
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1415
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1416
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1417
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1418
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
 * Method:    getMic
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
 * Signature: (JI[B)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
Java_sun_security_jgss_wrapper_GSSLibStub_getMic(JNIEnv *env, jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
                                                 jlong pContext, jint jqop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
                                                 jbyteArray jmsg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
  gss_qop_t qop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
  gss_buffer_desc msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
  gss_buffer_desc msgToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
  jbyteArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1439
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1440
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1441
  TRACE1("[GSSLibStub_getMic] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
  if (contextHdl == GSS_C_NO_CONTEXT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
    // Twik per javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
    checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0, "[GSSLibStub_getMic]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
  qop = (gss_qop_t) jqop;
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1449
  initGSSBuffer(env, jmsg, &msg);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1450
  if ((*env)->ExceptionCheck(env)) {
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1451
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1452
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
  /* gss_get_mic(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
     GSS_S_BAD_QOP */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
  major =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
    (*ftab->getMic)(&minor, contextHdl, qop, &msg, &msgToken);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
  /* release intermediate buffers */
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1460
  resetGSSBuffer(&msg);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
  jresult = getJavaBuffer(env, &msgToken);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1462
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1463
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1464
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1465
  checkStatus(env, jobj, major, minor, "[GSSLibStub_getMic]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1466
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1467
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1468
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
 * Method:    verifyMic
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
 * Signature: (J[B[BLorg/ietf/jgss/MessageProp;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
Java_sun_security_jgss_wrapper_GSSLibStub_verifyMic(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
                                                    jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
                                                    jlong pContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
                                                    jbyteArray jmsgToken,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
                                                    jbyteArray jmsg,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
                                                    jobject jprop)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
  gss_buffer_desc msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
  gss_buffer_desc msgToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
  gss_qop_t qop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1492
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1493
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1494
  TRACE1("[GSSLibStub_verifyMic] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
  if (contextHdl == GSS_C_NO_CONTEXT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
    // Twik per javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
    checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
        "[GSSLibStub_verifyMic]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
  }
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1502
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1503
  qop = (gss_qop_t) (*env)->CallIntMethod(env, jprop, MID_MessageProp_getQOP);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1504
  if ((*env)->ExceptionCheck(env)) { return; }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1505
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1506
  initGSSBuffer(env, jmsg, &msg);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1507
  if ((*env)->ExceptionCheck(env)) { return; }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1508
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1509
  initGSSBuffer(env, jmsgToken, &msgToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1510
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1511
    resetGSSBuffer(&msg);
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1512
    return;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1513
  }
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1514
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
  /* gss_verify_mic(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
     GSS_S_CONTEXT_EXPIRED, GSS_S_DUPLICATE_TOKEN(!), GSS_S_OLD_TOKEN(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
     GSS_S_UNSEQ_TOKEN(!), GSS_S_GAP_TOKEN(!), GSS_S_NO_CONTEXT(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
  major =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
    (*ftab->verifyMic)(&minor, contextHdl, &msg, &msgToken, &qop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
  /* release intermediate buffers */
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1522
  resetGSSBuffer(&msg);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1523
  resetGSSBuffer(&msgToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1524
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1525
  checkStatus(env, jobj, GSS_ERROR(major), minor, "[GSSLibStub_verifyMic]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1526
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1527
    return;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1528
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
  (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setQOP, qop);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1531
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1532
    return;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1533
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1534
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
  setSupplementaryInfo(env, jobj, jprop, GSS_SUPPLEMENTARY_INFO(major),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
                       minor);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1537
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1538
    return;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1539
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
 * Method:    wrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
 * Signature: (J[BLorg/ietf/jgss/MessageProp;)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
Java_sun_security_jgss_wrapper_GSSLibStub_wrap(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
                                               jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
                                               jlong pContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
                                               jbyteArray jmsg,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
                                               jobject jprop)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
  jboolean confFlag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
  gss_qop_t qop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
  gss_buffer_desc msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
  gss_buffer_desc msgToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
  int confState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
  jbyteArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1563
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1564
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1565
  TRACE1("[GSSLibStub_wrap] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
  if (contextHdl == GSS_C_NO_CONTEXT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
    // Twik per javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
    checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0, "[GSSLibStub_wrap]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
  confFlag =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
    (*env)->CallBooleanMethod(env, jprop, MID_MessageProp_getPrivacy);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1575
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1576
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1577
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1578
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
  qop = (gss_qop_t)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
    (*env)->CallIntMethod(env, jprop, MID_MessageProp_getQOP);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1581
  if ((*env)->ExceptionCheck(env)) {
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1582
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1583
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1584
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1585
  initGSSBuffer(env, jmsg, &msg);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1586
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1587
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1588
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1589
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
  /* gss_wrap(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
     GSS_S_BAD_QOP */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
  major = (*ftab->wrap)(&minor, contextHdl, confFlag, qop, &msg, &confState,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
                   &msgToken);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1595
  /* release intermediate buffers */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1596
  resetGSSBuffer(&msg);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1597
  jresult = getJavaBuffer(env, &msgToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1598
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1599
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1600
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1601
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1602
  checkStatus(env, jobj, major, minor, "[GSSLibStub_wrap]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1603
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1604
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1605
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1606
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
  (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setPrivacy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
                         (confState? JNI_TRUE:JNI_FALSE));
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1609
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1610
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1611
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
 * Class:     sun_security_jgss_wrapper_GSSLibStub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
 * Method:    unwrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
 * Signature: (J[BLorg/ietf/jgss/MessageProp;)[B
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
JNIEXPORT jbyteArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
Java_sun_security_jgss_wrapper_GSSLibStub_unwrap(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
                                                 jobject jobj,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
                                                 jlong pContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
                                                 jbyteArray jmsgToken,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
                                                 jobject jprop)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
  OM_uint32 minor, major;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
  gss_ctx_id_t contextHdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
  gss_buffer_desc msgToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
  gss_buffer_desc msg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
  int confState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
  gss_qop_t qop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
  jbyteArray jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
14414
f338be3ef659 8001579: Cleanup warnings in security native code
jzavgren
parents: 5506
diff changeset
  1635
  contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1636
49682
2918e1146106 8200468: Port the native GSS-API bridge to Windows
weijun
parents: 48571
diff changeset
  1637
  TRACE1("[GSSLibStub_unwrap] %" PRIuPTR "", (uintptr_t)contextHdl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
  if (contextHdl == GSS_C_NO_CONTEXT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
    // Twik per javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
    checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0, "[GSSLibStub_unwrap]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1644
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1645
  initGSSBuffer(env, jmsgToken, &msgToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1646
  if ((*env)->ExceptionCheck(env)) {
22940
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1647
    return NULL;
56b3ab8ec81c 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
michaelm
parents: 18175
diff changeset
  1648
  }
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1649
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
  confState = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
  qop = GSS_C_QOP_DEFAULT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
  /* gss_unwrap(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
     GSS_S_CONTEXT_EXPIRED, GSS_S_DUPLICATE_TOKEN(!), GSS_S_OLD_TOKEN(!),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
     GSS_S_UNSEQ_TOKEN(!), GSS_S_GAP_TOKEN(!), GSS_S_NO_CONTEXT(!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
  major =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
    (*ftab->unwrap)(&minor, contextHdl, &msgToken, &msg, &confState, &qop);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1657
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1658
  /* release intermediate buffers */
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1659
  resetGSSBuffer(&msgToken);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1660
  jresult = getJavaBuffer(env, &msg);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1661
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1662
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1663
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1664
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1665
  checkStatus(env, jobj, GSS_ERROR(major), minor, "[GSSLibStub_unwrap]");
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1666
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1667
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1668
  }
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1669
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
  /* update the message prop with relevant info */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
  (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setPrivacy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
                         (confState != 0));
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1673
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1674
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1675
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
  (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setQOP, qop);
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1677
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1678
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1679
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
  setSupplementaryInfo(env, jobj, jprop, GSS_SUPPLEMENTARY_INFO(major),
23585
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1681
                         minor);
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1682
  if ((*env)->ExceptionCheck(env)) {
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1683
    return NULL;
e4412d1b53d3 8031003: [Parfait] warnings from jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending
valeriep
parents: 23010
diff changeset
  1684
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
  return jresult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
}