src/java.security.jgss/windows/native/libw2k_lsa_auth/NativeCreds.c
author ihse
Fri, 08 Jun 2018 18:11:32 +0200
changeset 50471 f0aeede1b855
parent 47216 71c04702a3d5
child 53326 0060e9d7c450
permissions -rw-r--r--
8204572: SetupJdkLibrary should setup SRC and -I flags automatically Reviewed-by: erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
50471
f0aeede1b855 8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2018, 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: 2591
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: 2591
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: 2591
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2591
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2591
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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * ===========================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 2000 All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * ===========================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#define UNICODE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define _UNICODE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <windows.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <stdio.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define SECURITY_WIN32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include <security.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include <ntsecapi.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include <dsgetdc.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include <lmcons.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include <lmapibuf.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include <jni.h>
33653
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 30322
diff changeset
    45
#include "jni_util.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include <winsock.h>
50471
f0aeede1b855 8204572: SetupJdkLibrary should setup SRC and -I flags automatically
ihse
parents: 47216
diff changeset
    47
#include "sun_security_krb5_Credentials.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#undef LSA_SUCCESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define LSA_SUCCESS(Status) ((Status) >= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define EXIT_FAILURE -1 // mdu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Library-wide static references
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
jclass derValueClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
jclass ticketClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
jclass principalNameClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
jclass encryptionKeyClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
jclass ticketFlagsClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
jclass kerberosTimeClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
jclass javaLangStringClass = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
jmethodID derValueConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
jmethodID ticketConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
jmethodID principalNameConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
jmethodID encryptionKeyConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
jmethodID ticketFlagsConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
jmethodID kerberosTimeConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
jmethodID krbcredsConstructor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Function prototypes for internal routines
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 */
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
    77
BOOL native_debug = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
BOOL PackageConnectLookup(PHANDLE,PULONG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
NTSTATUS ConstructTicketRequest(UNICODE_STRING DomainName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                PKERB_RETRIEVE_TKT_REQUEST *outRequest,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                ULONG *outSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
DWORD ConcatenateUnicodeStrings(UNICODE_STRING *pTarget,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                UNICODE_STRING Source1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                                UNICODE_STRING Source2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
VOID ShowNTError(LPSTR,NTSTATUS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
VOID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
InitUnicodeString(
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    93
    PUNICODE_STRING DestinationString,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    PCWSTR SourceString OPTIONAL
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
    95
);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
//mdu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
jobject BuildPrincipal(JNIEnv *env, PKERB_EXTERNAL_NAME principalName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                UNICODE_STRING domainName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
jobject BuildEncryptionKey(JNIEnv *env, PKERB_CRYPTO_KEY cryptoKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
jobject BuildTicketFlags(JNIEnv *env, PULONG flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
jobject BuildKerberosTime(JNIEnv *env, PLARGE_INTEGER kerbtime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * Class:     sun_security_krb5_KrbCreds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * Method:    JNI_OnLoad
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
33653
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 30322
diff changeset
   112
JNIEXPORT jint JNICALL DEF_JNI_OnLoad(
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   113
        JavaVM  *jvm,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   114
        void    *reserved) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   116
    jclass cls;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   117
    JNIEnv *env;
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   118
    jfieldID fldDEBUG;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   120
    if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   121
        return JNI_EVERSION; /* JNI version not supported */
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   122
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   124
    cls = (*env)->FindClass(env,"sun/security/krb5/internal/Krb5");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   125
    if (cls == NULL) {
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   126
        printf("LSA: Couldn't find Krb5\n");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   127
        return JNI_ERR;
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   128
    }
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   129
    fldDEBUG = (*env)->GetStaticFieldID(env, cls, "DEBUG", "Z");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   130
    if (fldDEBUG == NULL) {
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   131
        printf("LSA: Krb5 has no DEBUG field\n");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   132
        return JNI_ERR;
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   133
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   134
    native_debug = (*env)->GetStaticBooleanField(env, cls, fldDEBUG);
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   135
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   136
    cls = (*env)->FindClass(env,"sun/security/krb5/internal/Ticket");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   138
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   139
        printf("LSA: Couldn't find Ticket\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   140
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   141
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   142
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   143
        printf("LSA: Found Ticket\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   144
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   146
    ticketClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   147
    if (ticketClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   148
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   149
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   150
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   151
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   152
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   154
    cls = (*env)->FindClass(env, "sun/security/krb5/PrincipalName");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   156
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   157
        printf("LSA: Couldn't find PrincipalName\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   158
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   159
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   160
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   161
        printf("LSA: Found PrincipalName\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   162
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   164
    principalNameClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   165
    if (principalNameClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   166
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   167
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   168
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   169
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   170
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   172
    cls = (*env)->FindClass(env,"sun/security/util/DerValue");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   174
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   175
        printf("LSA: Couldn't find DerValue\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   176
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   177
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   178
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   179
        printf("LSA: Found DerValue\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   180
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   182
    derValueClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   183
    if (derValueClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   184
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   185
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   186
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   187
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   188
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   190
    cls = (*env)->FindClass(env,"sun/security/krb5/EncryptionKey");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   192
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   193
        printf("LSA: Couldn't find EncryptionKey\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   194
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   195
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   196
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   197
        printf("LSA: Found EncryptionKey\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   198
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   200
    encryptionKeyClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   201
    if (encryptionKeyClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   202
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   203
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   204
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   205
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   206
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   208
    cls = (*env)->FindClass(env,"sun/security/krb5/internal/TicketFlags");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   210
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   211
        printf("LSA: Couldn't find TicketFlags\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   212
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   213
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   214
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   215
        printf("LSA: Found TicketFlags\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   216
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   218
    ticketFlagsClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   219
    if (ticketFlagsClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   220
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   221
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   222
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   223
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   224
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   226
    cls = (*env)->FindClass(env,"sun/security/krb5/internal/KerberosTime");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   228
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   229
        printf("LSA: Couldn't find KerberosTime\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   230
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   231
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   232
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   233
        printf("LSA: Found KerberosTime\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   234
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   236
    kerberosTimeClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   237
    if (kerberosTimeClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   238
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   239
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   240
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   241
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   242
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   244
    cls = (*env)->FindClass(env,"java/lang/String");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   246
    if (cls == NULL) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   247
        printf("LSA: Couldn't find String\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   248
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   249
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   250
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   251
        printf("LSA: Found String\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   252
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   254
    javaLangStringClass = (*env)->NewWeakGlobalRef(env,cls);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   255
    if (javaLangStringClass == NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   256
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   257
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   258
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   259
        printf("LSA: Made NewWeakGlobalRef\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   260
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   262
    derValueConstructor = (*env)->GetMethodID(env, derValueClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   263
                                            "<init>", "([B)V");
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   264
    if (derValueConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   265
        printf("LSA: Couldn't find DerValue constructor\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   266
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   267
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   268
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   269
        printf("LSA: Found DerValue constructor\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   270
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   272
    ticketConstructor = (*env)->GetMethodID(env, ticketClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   273
                            "<init>", "(Lsun/security/util/DerValue;)V");
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   274
    if (ticketConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   275
        printf("LSA: Couldn't find Ticket constructor\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   276
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   277
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   278
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   279
        printf("LSA: Found Ticket constructor\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   280
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   282
    principalNameConstructor = (*env)->GetMethodID(env, principalNameClass,
13247
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 8781
diff changeset
   283
                        "<init>", "([Ljava/lang/String;Ljava/lang/String;)V");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   284
    if (principalNameConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   285
        printf("LSA: Couldn't find PrincipalName constructor\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   286
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   287
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   288
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   289
        printf("LSA: Found PrincipalName constructor\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   290
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   292
    encryptionKeyConstructor = (*env)->GetMethodID(env, encryptionKeyClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   293
                                            "<init>", "(I[B)V");
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   294
    if (encryptionKeyConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   295
        printf("LSA: Couldn't find EncryptionKey constructor\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   296
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   297
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   298
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   299
        printf("LSA: Found EncryptionKey constructor\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   300
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   302
    ticketFlagsConstructor = (*env)->GetMethodID(env, ticketFlagsClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   303
                                            "<init>", "(I[B)V");
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   304
    if (ticketFlagsConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   305
        printf("LSA: Couldn't find TicketFlags constructor\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   306
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   307
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   308
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   309
        printf("LSA: Found TicketFlags constructor\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   310
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   312
    kerberosTimeConstructor = (*env)->GetMethodID(env, kerberosTimeClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   313
                                    "<init>", "(Ljava/lang/String;)V");
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   314
    if (kerberosTimeConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   315
        printf("LSA: Couldn't find KerberosTime constructor\n");
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   316
        return JNI_ERR;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   317
    }
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   318
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   319
        printf("LSA: Found KerberosTime constructor\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   320
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   322
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   323
        printf("LSA: Finished OnLoad processing\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   324
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   326
    return JNI_VERSION_1_2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
 * Class:     sun_security_jgss_KrbCreds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
 * Method:    JNI_OnUnload
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
33653
c1ee09fe3274 8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents: 30322
diff changeset
   334
JNIEXPORT void JNICALL DEF_JNI_OnUnload(
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   335
        JavaVM  *jvm,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   336
        void    *reserved) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   338
    JNIEnv *env;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   340
    if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   341
        return; /* Nothing else we can do */
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   342
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   344
    if (ticketClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   345
        (*env)->DeleteWeakGlobalRef(env,ticketClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   346
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   347
    if (derValueClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   348
        (*env)->DeleteWeakGlobalRef(env,derValueClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   349
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   350
    if (principalNameClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   351
        (*env)->DeleteWeakGlobalRef(env,principalNameClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   352
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   353
    if (encryptionKeyClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   354
        (*env)->DeleteWeakGlobalRef(env,encryptionKeyClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   355
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   356
    if (ticketFlagsClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   357
        (*env)->DeleteWeakGlobalRef(env,ticketFlagsClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   358
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   359
    if (kerberosTimeClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   360
        (*env)->DeleteWeakGlobalRef(env,kerberosTimeClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   361
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   362
    if (javaLangStringClass != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   363
        (*env)->DeleteWeakGlobalRef(env,javaLangStringClass);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   364
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   366
    return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * Class:     sun_security_krb5_Credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * Method:    acquireDefaultNativeCreds
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   372
 * Signature: ([I])Lsun/security/krb5/Credentials;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
JNIEXPORT jobject JNICALL Java_sun_security_krb5_Credentials_acquireDefaultNativeCreds(
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   375
        JNIEnv *env,
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   376
        jclass krbcredsClass,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   377
        jintArray jetypes) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   379
    KERB_QUERY_TKT_CACHE_REQUEST CacheRequest;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   380
    PKERB_RETRIEVE_TKT_RESPONSE TktCacheResponse = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   381
    PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   382
    PKERB_RETRIEVE_TKT_RESPONSE pTicketResponse = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   383
    NTSTATUS Status, SubStatus;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   384
    ULONG requestSize = 0;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   385
    ULONG responseSize = 0;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   386
    ULONG rspSize = 0;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   387
    HANDLE LogonHandle = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   388
    ULONG PackageId;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   389
    jobject ticket, clientPrincipal, targetPrincipal, encryptionKey;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   390
    jobject ticketFlags, startTime, endTime, krbCreds = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   391
    jobject authTime, renewTillTime, hostAddresses = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   392
    KERB_EXTERNAL_TICKET *msticket;
22269
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   393
    int found = 0;
30322
c08d5c975168 8078495: End time checking for native TGT is wrong
weijun
parents: 25859
diff changeset
   394
    FILETIME Now, EndTime;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   396
    int i, netypes;
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   397
    jint *etypes = NULL;
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   398
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   399
    while (TRUE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        if (krbcredsConstructor == 0) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   402
            krbcredsConstructor = (*env)->GetMethodID(env, krbcredsClass, "<init>",
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   403
                    "(Lsun/security/krb5/internal/Ticket;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   404
                    "Lsun/security/krb5/PrincipalName;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   405
                    "Lsun/security/krb5/PrincipalName;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   406
                    "Lsun/security/krb5/EncryptionKey;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   407
                    "Lsun/security/krb5/internal/TicketFlags;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   408
                    "Lsun/security/krb5/internal/KerberosTime;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   409
                    "Lsun/security/krb5/internal/KerberosTime;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   410
                    "Lsun/security/krb5/internal/KerberosTime;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   411
                    "Lsun/security/krb5/internal/KerberosTime;"
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   412
                    "Lsun/security/krb5/internal/HostAddresses;)V");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            if (krbcredsConstructor == 0) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   414
                printf("LSA: Couldn't find sun.security.krb5.Credentials constructor\n");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   419
        if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   420
            printf("LSA: Found KrbCreds constructor\n");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   421
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        // Get the logon handle and package ID from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        // Kerberos package
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        if (!PackageConnectLookup(&LogonHandle, &PackageId))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   430
        if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   431
            printf("LSA: Got handle to Kerberos package\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   432
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        // Get the MS TGT from cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        CacheRequest.MessageType = KerbRetrieveTicketMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        CacheRequest.LogonId.LowPart = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        CacheRequest.LogonId.HighPart = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        Status = LsaCallAuthenticationPackage(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                        LogonHandle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                        PackageId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        &CacheRequest,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                        sizeof(CacheRequest),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        &TktCacheResponse,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                        &rspSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                        &SubStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   449
        if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   450
            printf("LSA: Response size is %d\n", rspSize);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   451
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        if (!LSA_SUCCESS(Status) || !LSA_SUCCESS(SubStatus)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            if (!LSA_SUCCESS(Status)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                ShowNTError("LsaCallAuthenticationPackage", Status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                ShowNTError("Protocol status", SubStatus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        // got the native MS TGT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        msticket = &(TktCacheResponse->Ticket);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   465
        netypes = (*env)->GetArrayLength(env, jetypes);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   466
        etypes = (jint *) (*env)->GetIntArrayElements(env, jetypes, NULL);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   467
23030
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   468
        if (etypes == NULL) {
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   469
            break;
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   470
        }
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   471
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        // check TGT validity
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   473
        if (native_debug) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   474
            printf("LSA: TICKET SessionKey KeyType is %d\n", msticket->SessionKey.KeyType);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   477
        if ((msticket->TicketFlags & KERB_TICKET_FLAGS_invalid) == 0) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   478
            GetSystemTimeAsFileTime(&Now);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   479
            EndTime.dwLowDateTime = msticket->EndTime.LowPart;
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   480
            EndTime.dwHighDateTime = msticket->EndTime.HighPart;
30322
c08d5c975168 8078495: End time checking for native TGT is wrong
weijun
parents: 25859
diff changeset
   481
            if (CompareFileTime(&Now, &EndTime) < 0) {
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   482
                for (i=0; i<netypes; i++) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   483
                    if (etypes[i] == msticket->SessionKey.KeyType) {
22269
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   484
                        found = 1;
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   485
                        if (native_debug) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   486
                            printf("LSA: Valid etype found: %d\n", etypes[i]);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   487
                        }
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   488
                        break;
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   489
                    }
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   490
                }
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   491
            }
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   492
        }
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   493
22269
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   494
        if (!found) {
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   495
            if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   496
                printf("LSA: MS TGT in cache is invalid/not supported; request new ticket\n");
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   497
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            // use domain to request Ticket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            Status = ConstructTicketRequest(msticket->TargetDomainName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                                &pTicketRequest, &requestSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            if (!LSA_SUCCESS(Status)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                ShowNTError("ConstructTicketRequest status", Status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            pTicketRequest->MessageType = KerbRetrieveEncodedTicketMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            pTicketRequest->CacheOptions = KERB_RETRIEVE_TICKET_DONT_USE_CACHE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   510
            for (i=0; i<netypes; i++) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   511
                pTicketRequest->EncryptionType = etypes[i];
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   512
                Status = LsaCallAuthenticationPackage(
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   513
                            LogonHandle,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   514
                            PackageId,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   515
                            pTicketRequest,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   516
                            requestSize,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   517
                            &pTicketResponse,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   518
                            &responseSize,
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   519
                            &SubStatus
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   520
                            );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   522
                if (native_debug) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   523
                    printf("LSA: Response size is %d for %d\n", responseSize, etypes[i]);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   524
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   526
                if (!LSA_SUCCESS(Status) || !LSA_SUCCESS(SubStatus)) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   527
                    if (!LSA_SUCCESS(Status)) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   528
                        ShowNTError("LsaCallAuthenticationPackage", Status);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   529
                    } else {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   530
                        ShowNTError("Protocol status", SubStatus);
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   531
                    }
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   532
                    continue;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                }
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   534
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   535
                // got the native MS Kerberos TGT
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   536
                msticket = &(pTicketResponse->Ticket);
22269
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   537
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   538
                if (msticket->SessionKey.KeyType != etypes[i]) {
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   539
                    if (native_debug) {
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   540
                        printf("LSA: Response etype is %d for %d. Retry.\n", msticket->SessionKey.KeyType, etypes[i]);
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   541
                    }
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   542
                    continue;
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   543
                }
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   544
                found = 1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            }
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   547
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   549
        if (etypes != NULL) {
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   550
            (*env)->ReleaseIntArrayElements(env, jetypes, etypes, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   553
        /*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   555
        typedef struct _KERB_RETRIEVE_TKT_RESPONSE {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   556
            KERB_EXTERNAL_TICKET Ticket;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   557
        } KERB_RETRIEVE_TKT_RESPONSE, *PKERB_RETRIEVE_TKT_RESPONSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   559
        typedef struct _KERB_EXTERNAL_TICKET {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   560
            PKERB_EXTERNAL_NAME ServiceName;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   561
            PKERB_EXTERNAL_NAME TargetName;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   562
            PKERB_EXTERNAL_NAME ClientName;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   563
            UNICODE_STRING DomainName;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   564
            UNICODE_STRING TargetDomainName;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   565
            UNICODE_STRING AltTargetDomainName;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   566
            KERB_CRYPTO_KEY SessionKey;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   567
            ULONG TicketFlags;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   568
            ULONG Flags;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   569
            LARGE_INTEGER KeyExpirationTime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   570
            LARGE_INTEGER StartTime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   571
            LARGE_INTEGER EndTime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   572
            LARGE_INTEGER RenewUntil;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   573
            LARGE_INTEGER TimeSkew;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   574
            ULONG EncodedTicketSize;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   575
            PUCHAR EncodedTicket; <========== Here's the good stuff
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   576
        } KERB_EXTERNAL_TICKET, *PKERB_EXTERNAL_TICKET;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   578
        typedef struct _KERB_EXTERNAL_NAME {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   579
            SHORT NameType;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   580
            USHORT NameCount;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   581
            UNICODE_STRING Names[ANYSIZE_ARRAY];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   582
        } KERB_EXTERNAL_NAME, *PKERB_EXTERNAL_NAME;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   584
        typedef struct _LSA_UNICODE_STRING {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   585
            USHORT Length;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   586
            USHORT MaximumLength;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   587
            PWSTR  Buffer;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   588
        } LSA_UNICODE_STRING, *PLSA_UNICODE_STRING;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   590
        typedef LSA_UNICODE_STRING UNICODE_STRING, *PUNICODE_STRING;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   592
        typedef struct KERB_CRYPTO_KEY {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   593
            LONG KeyType;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   594
            ULONG Length;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   595
            PUCHAR Value;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   596
        } KERB_CRYPTO_KEY, *PKERB_CRYPTO_KEY;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   598
        */
22269
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   599
        if (!found) {
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   600
            break;
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   601
        }
852e4737460a 8031046: Native Windows ccache might still get unsupported ticket
weijun
parents: 21278
diff changeset
   602
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        // Build a com.sun.security.krb5.Ticket
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        ticket = BuildTicket(env, msticket->EncodedTicket,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                                msticket->EncodedTicketSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        if (ticket == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   607
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        // OK, have a Ticket, now need to get the client name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        clientPrincipal = BuildPrincipal(env, msticket->ClientName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                                msticket->TargetDomainName); // mdu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        if (clientPrincipal == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   613
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        // and the "name" of tgt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        targetPrincipal = BuildPrincipal(env, msticket->ServiceName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                        msticket->DomainName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        if (targetPrincipal == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   620
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        // Get the encryption key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        encryptionKey = BuildEncryptionKey(env, &(msticket->SessionKey));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        if (encryptionKey == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   626
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        // and the ticket flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        ticketFlags = BuildTicketFlags(env, &(msticket->TicketFlags));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        if (ticketFlags == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   632
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        // Get the start time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        startTime = BuildKerberosTime(env, &(msticket->StartTime));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        if (startTime == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   638
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
         * mdu: No point storing the eky expiration time in the auth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
         * time field. Set it to be same as startTime. Looks like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
         * windows does not have post-dated tickets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        authTime = startTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        // and the end time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        endTime = BuildKerberosTime(env, &(msticket->EndTime));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        if (endTime == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   651
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        // Get the renew till time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        renewTillTime = BuildKerberosTime(env, &(msticket->RenewUntil));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        if (renewTillTime == NULL) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   657
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        // and now go build a KrbCreds object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        krbCreds = (*env)->NewObject(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                krbcredsClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                krbcredsConstructor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                ticket,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                clientPrincipal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                targetPrincipal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                encryptionKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                ticketFlags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                authTime, // mdu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                startTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                endTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                renewTillTime, //mdu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                hostAddresses);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        break;
19373
4bb12c72a46f 8016594: Native Windows ccache still reads DES tickets
weijun
parents: 14342
diff changeset
   677
    } // end of WHILE. This WHILE will never loop.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   679
    // clean up resources
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   680
    if (TktCacheResponse != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   681
        LsaFreeReturnBuffer(TktCacheResponse);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   682
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   683
    if (pTicketRequest) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   684
        LocalFree(pTicketRequest);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   685
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   686
    if (pTicketResponse != NULL) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   687
        LsaFreeReturnBuffer(pTicketResponse);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   688
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   690
    return krbCreds;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
static NTSTATUS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
ConstructTicketRequest(UNICODE_STRING DomainName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                PKERB_RETRIEVE_TKT_REQUEST *outRequest, ULONG *outSize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
{
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   697
    NTSTATUS Status;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   698
    UNICODE_STRING TargetPrefix;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   699
    USHORT TargetSize;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   700
    ULONG RequestSize;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   701
    ULONG Length;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   702
    PKERB_RETRIEVE_TKT_REQUEST pTicketRequest = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   704
    *outRequest = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   705
    *outSize = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   707
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   708
    // Set up the "krbtgt/" target prefix into a UNICODE_STRING so we
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   709
    // can easily concatenate it later.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   710
    //
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   712
    TargetPrefix.Buffer = L"krbtgt/";
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   713
    Length = (ULONG)wcslen(TargetPrefix.Buffer) * sizeof(WCHAR);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   714
    TargetPrefix.Length = (USHORT)Length;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   715
    TargetPrefix.MaximumLength = TargetPrefix.Length;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   717
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   718
    // We will need to concatenate the "krbtgt/" prefix and the
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   719
    // Logon Session's DnsDomainName into our request's target name.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   720
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   721
    // Therefore, first compute the necessary buffer size for that.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   722
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   723
    // Note that we might theoretically have integer overflow.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   724
    //
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   726
    TargetSize = TargetPrefix.Length + DomainName.Length;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   728
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   729
    // The ticket request buffer needs to be a single buffer.  That buffer
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   730
    // needs to include the buffer for the target name.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   731
    //
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   733
    RequestSize = sizeof (*pTicketRequest) + TargetSize;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   735
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   736
    // Allocate the request buffer and make sure it's zero-filled.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   737
    //
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   739
    pTicketRequest = (PKERB_RETRIEVE_TKT_REQUEST)
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   740
                    LocalAlloc(LMEM_ZEROINIT, RequestSize);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   741
    if (!pTicketRequest)
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   742
        return GetLastError();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   744
    //
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19373
diff changeset
   745
    // Concatenate the target prefix with the previous response's
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   746
    // target domain.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   747
    //
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   749
    pTicketRequest->TargetName.Length = 0;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   750
    pTicketRequest->TargetName.MaximumLength = TargetSize;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   751
    pTicketRequest->TargetName.Buffer = (PWSTR) (pTicketRequest + 1);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   752
    Status = ConcatenateUnicodeStrings(&(pTicketRequest->TargetName),
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   753
                                    TargetPrefix,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   754
                                    DomainName);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   755
    *outRequest = pTicketRequest;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   756
    *outSize    = RequestSize;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   757
    return Status;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
DWORD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
ConcatenateUnicodeStrings(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    UNICODE_STRING *pTarget,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    UNICODE_STRING Source1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    UNICODE_STRING Source2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
{
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   767
    //
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   768
    // The buffers for Source1 and Source2 cannot overlap pTarget's
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   769
    // buffer.  Source1.Length + Source2.Length must be <= 0xFFFF,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   770
    // otherwise we overflow...
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   771
    //
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   773
    USHORT TotalSize = Source1.Length + Source2.Length;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   774
    PBYTE buffer = (PBYTE) pTarget->Buffer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   776
    if (TotalSize > pTarget->MaximumLength)
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   777
        return ERROR_INSUFFICIENT_BUFFER;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   779
    pTarget->Length = TotalSize;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   780
    memcpy(buffer, Source1.Buffer, Source1.Length);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   781
    memcpy(buffer + Source1.Length, Source2.Buffer, Source2.Length);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   782
    return ERROR_SUCCESS;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
BOOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
PackageConnectLookup(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    HANDLE *pLogonHandle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    ULONG *pPackageId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    LSA_STRING Name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    NTSTATUS Status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    Status = LsaConnectUntrusted(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                pLogonHandle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    if (!LSA_SUCCESS(Status))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        ShowNTError("LsaConnectUntrusted", Status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    Name.Buffer = MICROSOFT_KERBEROS_NAME_A;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    Name.Length = (USHORT)strlen(Name.Buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    Name.MaximumLength = Name.Length + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    Status = LsaLookupAuthenticationPackage(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                *pLogonHandle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                &Name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                pPackageId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    if (!LSA_SUCCESS(Status))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        ShowNTError("LsaLookupAuthenticationPackage", Status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
VOID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
ShowLastError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        LPSTR szAPI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        DWORD dwError
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
{
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   830
    #define MAX_MSG_SIZE 256
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   832
    static WCHAR szMsgBuf[MAX_MSG_SIZE];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   833
    DWORD dwRes;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   835
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   836
        printf("LSA: Error calling function %s: %lu\n", szAPI, dwError);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   837
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   839
    dwRes = FormatMessage (
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   840
            FORMAT_MESSAGE_FROM_SYSTEM,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   841
            NULL,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   842
            dwError,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   843
            0,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   844
            szMsgBuf,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   845
            MAX_MSG_SIZE,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   846
            NULL);
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   847
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   848
        if (0 == dwRes) {
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   849
            printf("LSA: FormatMessage failed with %d\n", GetLastError());
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   850
            // ExitProcess(EXIT_FAILURE);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   851
        } else {
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   852
            printf("LSA: %S",szMsgBuf);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   853
        }
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   854
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
VOID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
ShowNTError(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        LPSTR szAPI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        NTSTATUS Status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    // Convert the NTSTATUS to Winerror. Then call ShowLastError().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    ShowLastError(szAPI, LsaNtStatusToWinError(Status));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
VOID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
InitUnicodeString(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        PUNICODE_STRING DestinationString,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    PCWSTR SourceString OPTIONAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    ULONG Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    DestinationString->Buffer = (PWSTR)SourceString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    if (SourceString != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        Length = (ULONG)wcslen( SourceString ) * sizeof( WCHAR );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        DestinationString->Length = (USHORT)Length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        DestinationString->MaximumLength = (USHORT)(Length + sizeof(UNICODE_NULL));
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   882
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        DestinationString->MaximumLength = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        DestinationString->Length = 0;
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   886
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   891
    /* To build a Ticket, we first need to build a DerValue out of the EncodedTicket.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   892
     * But before we can do that, we need to make a byte array out of the ET.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   893
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   895
    jobject derValue, ticket;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   896
    jbyteArray ary;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   898
    ary = (*env)->NewByteArray(env,encodedTicketSize);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   899
    if ((*env)->ExceptionOccurred(env)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   900
        return (jobject) NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   901
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   903
    (*env)->SetByteArrayRegion(env, ary, (jsize) 0, encodedTicketSize,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   904
                                    (jbyte *)encodedTicket);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   905
    if ((*env)->ExceptionOccurred(env)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   906
        (*env)->DeleteLocalRef(env, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   907
        return (jobject) NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   908
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   910
    derValue = (*env)->NewObject(env, derValueClass, derValueConstructor, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   911
    if ((*env)->ExceptionOccurred(env)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        (*env)->DeleteLocalRef(env, ary);
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   913
        return (jobject) NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   914
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   915
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   916
    (*env)->DeleteLocalRef(env, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   917
    ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, derValue);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   918
    if ((*env)->ExceptionOccurred(env)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        (*env)->DeleteLocalRef(env, derValue);
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   920
        return (jobject) NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   921
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   922
    (*env)->DeleteLocalRef(env, derValue);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   923
    return ticket;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
// mdu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
jobject BuildPrincipal(JNIEnv *env, PKERB_EXTERNAL_NAME principalName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                                UNICODE_STRING domainName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   930
    /*
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   931
     * To build the Principal, we need to get the names out of
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   932
     * this goofy MS structure
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   933
     */
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   934
    jobject principal = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   935
    jobject realmStr = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   936
    jobjectArray stringArray;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   937
    jstring tempString;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   938
    int nameCount,i;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   939
    PUNICODE_STRING scanner;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   940
    WCHAR *realm;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   941
    ULONG realmLen;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   943
    realm = (WCHAR *) LocalAlloc(LMEM_ZEROINIT,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   944
            ((domainName.Length)*sizeof(WCHAR) + sizeof(UNICODE_NULL)));
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   945
    wcsncpy(realm, domainName.Buffer, domainName.Length/sizeof(WCHAR));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   947
    if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   948
        printf("LSA: Principal domain is %S\n", realm);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   949
        printf("LSA: Name type is %x\n", principalName->NameType);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   950
        printf("LSA: Name count is %x\n", principalName->NameCount);
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   951
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   953
    nameCount = principalName->NameCount;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   954
    stringArray = (*env)->NewObjectArray(env, nameCount,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   955
                            javaLangStringClass, NULL);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   956
    if (stringArray == NULL) {
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
   957
        if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   958
            printf("LSA: Can't allocate String array for Principal\n");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
   959
        }
23030
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   960
        goto cleanup;
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   961
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   963
    for (i=0; i<nameCount; i++) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   964
        // get the principal name
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   965
        scanner = &(principalName->Names[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   967
        // OK, got a Char array, so construct a String
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   968
        tempString = (*env)->NewString(env, (const jchar*)scanner->Buffer,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   969
                            scanner->Length/sizeof(WCHAR));
23030
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   970
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   971
        if (tempString == NULL) {
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   972
            goto cleanup;
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   973
        }
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   974
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   975
        // Set the String into the StringArray
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   976
        (*env)->SetObjectArrayElement(env, stringArray, i, tempString);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
23030
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   978
        if ((*env)->ExceptionCheck(env)) {
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   979
            goto cleanup;
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   980
        }
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   981
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   982
        // Do I have to worry about storage reclamation here?
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   983
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   984
    // now set the realm in the principal
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   985
    realmLen = (ULONG)wcslen((PWCHAR)realm);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   986
    realmStr = (*env)->NewString(env, (PWCHAR)realm, (USHORT)realmLen);
13247
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 8781
diff changeset
   987
23030
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   988
    if (realmStr == NULL) {
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   989
        goto cleanup;
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   990
    }
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   991
13247
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 8781
diff changeset
   992
    principal = (*env)->NewObject(env, principalNameClass,
74902cfeb9c6 6966259: Make PrincipalName and Realm immutable
weijun
parents: 8781
diff changeset
   993
                    principalNameConstructor, stringArray, realmStr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
23030
51178fbafe9c 8035759: [parfait] JNI exception pending in jdk/src/windows/native/sun/security/krb5/NativeCreds.c
weijun
parents: 23010
diff changeset
   995
cleanup:
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   996
    // free local resources
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   997
    LocalFree(realm);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
   999
    return principal;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
jobject BuildEncryptionKey(JNIEnv *env, PKERB_CRYPTO_KEY cryptoKey) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1003
    // First, need to build a byte array
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1004
    jbyteArray ary;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1005
    jobject encryptionKey = NULL;
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1006
    unsigned int i;
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1007
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1008
    for (i=0; i<cryptoKey->Length; i++) {
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1009
        if (cryptoKey->Value[i]) break;
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1010
    }
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1011
    if (i == cryptoKey->Length) {
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
  1012
        if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1013
            printf("LSA: Session key all zero. Stop.\n");
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1014
        }
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1015
        return NULL;
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1016
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1018
    ary = (*env)->NewByteArray(env,cryptoKey->Length);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1019
    (*env)->SetByteArrayRegion(env, ary, (jsize) 0, cryptoKey->Length,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1020
                                    (jbyte *)cryptoKey->Value);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1021
    if ((*env)->ExceptionOccurred(env)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1022
        (*env)->DeleteLocalRef(env, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1023
    } else {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1024
        encryptionKey = (*env)->NewObject(env, encryptionKeyClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1025
                encryptionKeyConstructor, cryptoKey->KeyType, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1026
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1028
    return encryptionKey;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
jobject BuildTicketFlags(JNIEnv *env, PULONG flags) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1032
    jobject ticketFlags = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1033
    jbyteArray ary;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1034
    /*
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1035
     * mdu: Convert the bytes to nework byte order before copying
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1036
     * them to a Java byte array.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1037
     */
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1038
    ULONG nlflags = htonl(*flags);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1040
    ary = (*env)->NewByteArray(env, sizeof(*flags));
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1041
    (*env)->SetByteArrayRegion(env, ary, (jsize) 0, sizeof(*flags),
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1042
                                    (jbyte *)&nlflags);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1043
    if ((*env)->ExceptionOccurred(env)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1044
        (*env)->DeleteLocalRef(env, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1045
    } else {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1046
        ticketFlags = (*env)->NewObject(env, ticketFlagsClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1047
                ticketFlagsConstructor, sizeof(*flags)*8, ary);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1048
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1050
    return ticketFlags;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
jobject BuildKerberosTime(JNIEnv *env, PLARGE_INTEGER kerbtime) {
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1054
    jobject kerberosTime = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1055
    jstring stringTime = NULL;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1056
    SYSTEMTIME systemTime;
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1057
    WCHAR timeString[16];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1058
    WCHAR month[3];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1059
    WCHAR day[3];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1060
    WCHAR hour[3];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1061
    WCHAR minute[3];
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1062
    WCHAR second[3];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1064
    if (FileTimeToSystemTime((FILETIME *)kerbtime, &systemTime)) {
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1065
        // XXX Cannot use %02.2ld, because the leading 0 is ignored for integers.
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1066
        // So, print them to strings, and then print them to the master string with a
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1067
        // format pattern that makes it two digits and prefix with a 0 if necessary.
8781
1ecbd60a9024 6990848: JGSS/windows security code native code compiler warnings
weijun
parents: 5506
diff changeset
  1068
        swprintf( (wchar_t *)month, 3, L"%2.2d", systemTime.wMonth);
1ecbd60a9024 6990848: JGSS/windows security code native code compiler warnings
weijun
parents: 5506
diff changeset
  1069
        swprintf( (wchar_t *)day, 3, L"%2.2d", systemTime.wDay);
1ecbd60a9024 6990848: JGSS/windows security code native code compiler warnings
weijun
parents: 5506
diff changeset
  1070
        swprintf( (wchar_t *)hour, 3, L"%2.2d", systemTime.wHour);
1ecbd60a9024 6990848: JGSS/windows security code native code compiler warnings
weijun
parents: 5506
diff changeset
  1071
        swprintf( (wchar_t *)minute, 3, L"%2.2d", systemTime.wMinute);
1ecbd60a9024 6990848: JGSS/windows security code native code compiler warnings
weijun
parents: 5506
diff changeset
  1072
        swprintf( (wchar_t *)second, 3, L"%2.2d", systemTime.wSecond);
1ecbd60a9024 6990848: JGSS/windows security code native code compiler warnings
weijun
parents: 5506
diff changeset
  1073
        swprintf( (wchar_t *)timeString, 16,
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1074
                L"%ld%02.2s%02.2s%02.2s%02.2s%02.2sZ",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                systemTime.wYear,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                month,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                day,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                hour,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                minute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                second );
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
  1081
        if (native_debug) {
2588
ec64fd74aa69 6587676: Krb5LoginModule failure if useTicketCache=true on Vista
weijun
parents: 715
diff changeset
  1082
            printf("LSA: %S\n", (wchar_t *)timeString);
2591
6ef824d6d5c2 6830658: Changeset ec64fd74aa69 breaks the fastdebug build in NativeCreds.c
weijun
parents: 2588
diff changeset
  1083
        }
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1084
        stringTime = (*env)->NewString(env, timeString,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1085
                (sizeof(timeString)/sizeof(WCHAR))-1);
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1086
        if (stringTime != NULL) { // everything's OK so far
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1087
            kerberosTime = (*env)->NewObject(env, kerberosTimeClass,
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1088
                    kerberosTimeConstructor, stringTime);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        }
73
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1090
    }
cf334423502b 6641312: Fix krb5 codes indentation problems
weijun
parents: 2
diff changeset
  1091
    return kerberosTime;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
}