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