author | vtewari |
Thu, 22 Nov 2018 13:25:44 +0530 | |
changeset 52651 | 526b2490c616 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
14681
diff
changeset
|
2 |
* Copyright (c) 2002, 2012, 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 |
#include <jni.h> |
|
27 |
#include <windows.h> |
|
28 |
#include <rpc.h> |
|
29 |
#include <winsock.h> |
|
30 |
#include <lm.h> |
|
31 |
||
32 |
#include <stdio.h> |
|
33 |
#include <stdarg.h> |
|
34 |
#include <stdlib.h> |
|
35 |
#include <string.h> |
|
36 |
#include <tchar.h> |
|
37 |
#include <fcntl.h> |
|
38 |
||
86
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
39 |
#include "jni_util.h" |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
40 |
|
2 | 41 |
#define SECURITY_WIN32 |
42 |
#include "sspi.h" |
|
43 |
||
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
44 |
static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle, JNIEnv *env, jobject status); |
2 | 45 |
|
46 |
static jfieldID ntlm_ctxHandleID; |
|
47 |
static jfieldID ntlm_crdHandleID; |
|
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
48 |
static jfieldID status_seqCompleteID; |
2 | 49 |
|
50 |
static HINSTANCE lib = NULL; |
|
51 |
||
4157
558590fb3b49
6893238: Move NTLM and SPNEGO implementations into separate packages
chegar
parents:
910
diff
changeset
|
52 |
JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_initFirst |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
53 |
(JNIEnv *env, jclass authseq_clazz, jclass status_clazz) |
2 | 54 |
{ |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
55 |
ntlm_ctxHandleID = (*env)->GetFieldID(env, authseq_clazz, "ctxHandle", "J"); |
23560
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
56 |
CHECK_NULL(ntlm_ctxHandleID); |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
57 |
ntlm_crdHandleID = (*env)->GetFieldID(env, authseq_clazz, "crdHandle", "J"); |
23560
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
58 |
CHECK_NULL(ntlm_crdHandleID); |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
59 |
status_seqCompleteID = (*env)->GetFieldID(env, status_clazz, "sequenceComplete", "Z"); |
2 | 60 |
} |
61 |
||
62 |
/* |
|
63 |
* Class: sun_net_www_protocol_http_NTLMAuthSequence |
|
64 |
* Method: getCredentialsHandle |
|
65 |
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J |
|
66 |
*/ |
|
67 |
||
4157
558590fb3b49
6893238: Move NTLM and SPNEGO implementations into separate packages
chegar
parents:
910
diff
changeset
|
68 |
JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_getCredentialsHandle |
2 | 69 |
(JNIEnv *env, jobject this, jstring user, jstring domain, jstring password) |
70 |
{ |
|
71 |
SEC_WINNT_AUTH_IDENTITY AuthId; |
|
72 |
SEC_WINNT_AUTH_IDENTITY * pAuthId; |
|
86
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
73 |
const CHAR *pUser = 0; |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
74 |
const CHAR *pDomain = 0; |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
75 |
const CHAR *pPassword = 0; |
2 | 76 |
CredHandle *pCred; |
77 |
TimeStamp ltime; |
|
78 |
jboolean isCopy; |
|
79 |
SECURITY_STATUS ss; |
|
80 |
||
81 |
if (user != 0) { |
|
86
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
82 |
pUser = JNU_GetStringPlatformChars(env, user, &isCopy); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
83 |
if (pUser == NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
84 |
return 0; // pending Exception |
2 | 85 |
} |
86 |
if (domain != 0) { |
|
86
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
87 |
pDomain = JNU_GetStringPlatformChars(env, domain, &isCopy); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
88 |
if (pDomain == NULL) { |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
89 |
if (pUser != NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
90 |
JNU_ReleaseStringPlatformChars(env, user, pUser); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
91 |
return 0; // pending Exception |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
92 |
} |
2 | 93 |
} |
94 |
if (password != 0) { |
|
86
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
95 |
pPassword = JNU_GetStringPlatformChars(env, password, &isCopy); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
96 |
if (pPassword == NULL) { |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
97 |
if(pUser != NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
98 |
JNU_ReleaseStringPlatformChars(env, user, pUser); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
99 |
if(pDomain != NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
100 |
JNU_ReleaseStringPlatformChars(env, domain, pDomain); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
101 |
return 0; // pending Exception |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
102 |
} |
2 | 103 |
} |
104 |
pCred = (CredHandle *)malloc(sizeof (CredHandle)); |
|
23560
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
105 |
if (pCred == NULL) { |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
106 |
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
107 |
if (pUser != NULL) |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
108 |
JNU_ReleaseStringPlatformChars(env, user, pUser); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
109 |
if (pPassword != NULL) |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
110 |
JNU_ReleaseStringPlatformChars(env, password, pPassword); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
111 |
if (pDomain != NULL) |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
112 |
JNU_ReleaseStringPlatformChars(env, domain, pDomain); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
113 |
return NULL; |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
114 |
} |
2 | 115 |
|
116 |
if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) { |
|
117 |
pAuthId = &AuthId; |
|
118 |
||
119 |
memset( &AuthId, 0, sizeof( AuthId )); |
|
120 |
||
121 |
if ( pUser != NULL ) { |
|
122 |
AuthId.User = (unsigned char *) pUser; |
|
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
123 |
AuthId.UserLength = (unsigned long) strlen( pUser ); |
2 | 124 |
} |
125 |
||
126 |
if ( pPassword != NULL ) { |
|
127 |
AuthId.Password = (unsigned char *) pPassword; |
|
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
128 |
AuthId.PasswordLength = (unsigned long) strlen( pPassword ); |
2 | 129 |
} |
130 |
||
131 |
if ( pDomain != NULL ) { |
|
132 |
AuthId.Domain = (unsigned char *) pDomain; |
|
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
133 |
AuthId.DomainLength = (unsigned long) strlen( pDomain ); |
2 | 134 |
} |
135 |
||
136 |
AuthId.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; |
|
137 |
} else { |
|
138 |
pAuthId = NULL; |
|
139 |
} |
|
140 |
||
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
141 |
ss = AcquireCredentialsHandleA( |
2 | 142 |
NULL, "NTLM", SECPKG_CRED_OUTBOUND, |
143 |
NULL, pAuthId, NULL, NULL, |
|
144 |
pCred, <ime |
|
145 |
); |
|
146 |
||
86
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
147 |
/* Release resources held by JNU_GetStringPlatformChars */ |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
148 |
if (pUser != NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
149 |
JNU_ReleaseStringPlatformChars(env, user, pUser); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
150 |
if (pPassword != NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
151 |
JNU_ReleaseStringPlatformChars(env, password, pPassword); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
152 |
if (pDomain != NULL) |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
153 |
JNU_ReleaseStringPlatformChars(env, domain, pDomain); |
a9644392a939
6628661: NTLM-authentication doesn't work with non-ASCII letters
chegar
parents:
72
diff
changeset
|
154 |
|
2 | 155 |
if (ss == 0) { |
156 |
return (jlong) pCred; |
|
157 |
} else { |
|
158 |
return 0; |
|
159 |
} |
|
160 |
} |
|
161 |
||
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
162 |
|
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
163 |
/* |
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
164 |
* Class: sun_net_www_protocol_http_ntlm_NTLMAuthSequence |
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
165 |
* Method: getNextToken |
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
166 |
* Signature: (J[BLsun/net/www/protocol/http/ntlm/NTLMAuthSequence/Status;)[B |
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
167 |
*/ |
4157
558590fb3b49
6893238: Move NTLM and SPNEGO implementations into separate packages
chegar
parents:
910
diff
changeset
|
168 |
JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_getNextToken |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
169 |
(JNIEnv *env, jobject this, jlong crdHandle, jbyteArray lastToken, jobject status) |
2 | 170 |
{ |
171 |
||
172 |
VOID *pInput = 0; |
|
173 |
DWORD inputLen; |
|
13033
365efcc2d50c
7176784: Windows authentication not working on some computers
chegar
parents:
9003
diff
changeset
|
174 |
CHAR buffOut[1024]; |
2 | 175 |
jboolean isCopy; |
176 |
SECURITY_STATUS ss; |
|
177 |
SecBufferDesc OutBuffDesc; |
|
178 |
SecBuffer OutSecBuff; |
|
179 |
SecBufferDesc InBuffDesc; |
|
180 |
SecBuffer InSecBuff; |
|
181 |
ULONG ContextAttributes; |
|
182 |
CredHandle *pCred = (CredHandle *)crdHandle; |
|
183 |
CtxtHandle *pCtx; |
|
184 |
CtxtHandle *newContext; |
|
185 |
TimeStamp ltime; |
|
186 |
jbyteArray result; |
|
187 |
||
188 |
||
189 |
pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID); |
|
190 |
if (pCtx == 0) { /* first call */ |
|
191 |
newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle)); |
|
23560
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
192 |
if (newContext != NULL) { |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
193 |
(*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
194 |
} else { |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
195 |
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
196 |
return NULL; |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
197 |
} |
2 | 198 |
} else { |
199 |
newContext = pCtx; |
|
200 |
} |
|
201 |
||
202 |
OutBuffDesc.ulVersion = 0; |
|
203 |
OutBuffDesc.cBuffers = 1; |
|
204 |
OutBuffDesc.pBuffers = &OutSecBuff; |
|
205 |
||
13033
365efcc2d50c
7176784: Windows authentication not working on some computers
chegar
parents:
9003
diff
changeset
|
206 |
OutSecBuff.cbBuffer = 1024; |
2 | 207 |
OutSecBuff.BufferType = SECBUFFER_TOKEN; |
208 |
OutSecBuff.pvBuffer = buffOut; |
|
209 |
||
210 |
/* |
|
211 |
* Prepare our Input buffer - Note the server is expecting the client's |
|
212 |
* negotiation packet on the first call |
|
213 |
*/ |
|
214 |
||
215 |
if (lastToken != 0) |
|
216 |
{ |
|
217 |
pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy); |
|
23560
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
218 |
CHECK_NULL_RETURN(pInput, NULL); |
2 | 219 |
inputLen = (*env)->GetArrayLength(env, lastToken); |
220 |
||
221 |
InBuffDesc.ulVersion = 0; |
|
222 |
InBuffDesc.cBuffers = 1; |
|
223 |
InBuffDesc.pBuffers = &InSecBuff; |
|
224 |
||
225 |
InSecBuff.cbBuffer = inputLen; |
|
226 |
InSecBuff.BufferType = SECBUFFER_TOKEN; |
|
227 |
InSecBuff.pvBuffer = pInput; |
|
228 |
} |
|
229 |
||
230 |
/* |
|
231 |
* will return success when its done but we still |
|
232 |
* need to send the out buffer if there are bytes to send |
|
233 |
*/ |
|
234 |
||
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
235 |
ss = InitializeSecurityContextA( |
2 | 236 |
pCred, pCtx, NULL, 0, 0, SECURITY_NATIVE_DREP, |
237 |
lastToken ? &InBuffDesc : NULL, 0, newContext, &OutBuffDesc, |
|
238 |
&ContextAttributes, <ime |
|
239 |
); |
|
240 |
||
241 |
if (pInput != 0) { |
|
242 |
(*env)->ReleaseByteArrayElements(env, lastToken, pInput, JNI_ABORT); |
|
243 |
} |
|
244 |
||
245 |
if (ss < 0) { |
|
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
246 |
endSequence (pCred, pCtx, env, status); |
2 | 247 |
return 0; |
248 |
} |
|
249 |
||
250 |
if ((ss == SEC_I_COMPLETE_NEEDED) || (ss == SEC_I_COMPLETE_AND_CONTINUE) ) { |
|
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
251 |
ss = CompleteAuthToken( pCtx, &OutBuffDesc ); |
2 | 252 |
|
253 |
if (ss < 0) { |
|
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
254 |
endSequence (pCred, pCtx, env, status); |
2 | 255 |
return 0; |
256 |
} |
|
257 |
} |
|
258 |
||
259 |
if ( OutSecBuff.cbBuffer > 0 ) { |
|
260 |
jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer); |
|
23560
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
261 |
if (ret != NULL) { |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
262 |
(*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer, |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
263 |
OutSecBuff.pvBuffer); |
80b1514e7eac
8036600: JNI exception pending in src/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
msheppar
parents:
23010
diff
changeset
|
264 |
} |
2 | 265 |
if (lastToken != 0) // 2nd stage |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
266 |
endSequence (pCred, pCtx, env, status); |
2 | 267 |
result = ret; |
268 |
} |
|
269 |
||
270 |
if ((ss != SEC_I_CONTINUE_NEEDED) && (ss == SEC_I_COMPLETE_AND_CONTINUE)) { |
|
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
271 |
endSequence (pCred, pCtx, env, status); |
2 | 272 |
} |
273 |
||
274 |
return result; |
|
275 |
} |
|
276 |
||
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
277 |
static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle, JNIEnv *env, jobject status) { |
2 | 278 |
if (credHand != 0) { |
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
279 |
FreeCredentialsHandle(credHand); |
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
280 |
free(credHand); |
2 | 281 |
} |
282 |
||
283 |
if (ctxHandle != 0) { |
|
9003
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
284 |
DeleteSecurityContext(ctxHandle); |
e1b0f0099915
7030256: Cleanup/Remove code supporting old Windows versions (98, NT, 2000, etc)
chegar
parents:
5506
diff
changeset
|
285 |
free(ctxHandle); |
2 | 286 |
} |
14681
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
287 |
|
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
288 |
/* Sequence is complete so set flag */ |
523a842a7ac1
7200720: crash in net.dll during NTLM authentication
michaelm
parents:
14342
diff
changeset
|
289 |
(*env)->SetBooleanField(env, status, status_seqCompleteID, JNI_TRUE); |
2 | 290 |
} |