author | weijun |
Thu, 24 Jun 2010 14:26:35 +0800 | |
changeset 5975 | 076cd013e5e4 |
parent 5802 | ea99d72d3c19 |
child 7183 | d8ccc1c73358 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5627 | 2 |
* Copyright (c) 2000, 2010, 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. 1999 All Rights Reserved. |
|
29 |
* Copyright 1997 The Open Group Research Institute. All rights reserved. |
|
30 |
*/ |
|
31 |
||
32 |
package sun.security.krb5; |
|
33 |
||
34 |
import sun.security.krb5.internal.*; |
|
35 |
import sun.security.krb5.internal.crypto.EType; |
|
36 |
import sun.security.krb5.internal.crypto.Nonce; |
|
37 |
import sun.security.krb5.internal.crypto.KeyUsage; |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
38 |
import sun.security.util.*; |
2 | 39 |
import java.io.IOException; |
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
40 |
import java.io.ByteArrayInputStream; |
2 | 41 |
import java.net.UnknownHostException; |
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
42 |
import java.util.StringTokenizer; |
2 | 43 |
|
44 |
/** |
|
45 |
* This class encapsulates the KRB-AS-REQ message that the client |
|
46 |
* sends to the KDC. |
|
47 |
*/ |
|
48 |
public class KrbAsReq extends KrbKdcReq { |
|
49 |
private PrincipalName princName; |
|
50 |
private ASReq asReqMessg; |
|
51 |
||
52 |
private boolean DEBUG = Krb5.DEBUG; |
|
53 |
private static KDCOptions defaultKDCOptions = new KDCOptions(); |
|
54 |
||
55 |
// pre-auth info |
|
56 |
private boolean PA_ENC_TIMESTAMP_REQUIRED = false; |
|
57 |
private boolean pa_exists = false; |
|
58 |
private int pa_etype = 0; |
|
3949
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
59 |
private String pa_salt = null; |
2 | 60 |
private byte[] pa_s2kparams = null; |
61 |
||
62 |
// default is address-less tickets |
|
63 |
private boolean KDC_EMPTY_ADDRESSES_ALLOWED = true; |
|
64 |
||
65 |
/** |
|
66 |
* Creates a KRB-AS-REQ to send to the default KDC |
|
67 |
* @throws KrbException |
|
68 |
* @throws IOException |
|
69 |
*/ |
|
70 |
// Called by Credentials |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
71 |
KrbAsReq(PrincipalName principal, EncryptionKey[] keys) |
2 | 72 |
throws KrbException, IOException { |
73 |
this(keys, // for pre-authentication |
|
74 |
false, 0, null, null, // pre-auth values |
|
75 |
defaultKDCOptions, |
|
76 |
principal, |
|
77 |
null, // PrincipalName sname |
|
78 |
null, // KerberosTime from |
|
79 |
null, // KerberosTime till |
|
80 |
null, // KerberosTime rtime |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
81 |
null, // int[] eTypes |
2 | 82 |
null, // HostAddresses addresses |
83 |
null); // Ticket[] additionalTickets |
|
84 |
} |
|
85 |
||
86 |
/** |
|
87 |
* Creates a KRB-AS-REQ to send to the default KDC |
|
88 |
* with pre-authentication values |
|
89 |
*/ |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
90 |
KrbAsReq(PrincipalName principal, EncryptionKey[] keys, |
3949
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
91 |
boolean pa_exists, int etype, String salt, byte[] s2kparams) |
2 | 92 |
throws KrbException, IOException { |
93 |
this(keys, // for pre-authentication |
|
94 |
pa_exists, etype, salt, s2kparams, // pre-auth values |
|
95 |
defaultKDCOptions, |
|
96 |
principal, |
|
97 |
null, // PrincipalName sname |
|
98 |
null, // KerberosTime from |
|
99 |
null, // KerberosTime till |
|
100 |
null, // KerberosTime rtime |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
101 |
null, // int[] eTypes |
2 | 102 |
null, // HostAddresses addresses |
103 |
null); // Ticket[] additionalTickets |
|
104 |
} |
|
105 |
||
106 |
private static int[] getETypesFromKeys(EncryptionKey[] keys) { |
|
107 |
int[] types = new int[keys.length]; |
|
108 |
for (int i = 0; i < keys.length; i++) { |
|
109 |
types[i] = keys[i].getEType(); |
|
110 |
} |
|
111 |
return types; |
|
112 |
} |
|
113 |
||
114 |
// update with pre-auth info |
|
3949
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
115 |
public void updatePA(int etype, String salt, byte[] params, PrincipalName name) { |
2 | 116 |
// set the pre-auth values |
117 |
pa_exists = true; |
|
118 |
pa_etype = etype; |
|
119 |
pa_salt = salt; |
|
120 |
pa_s2kparams = params; |
|
121 |
||
122 |
// update salt in PrincipalName |
|
3949
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
123 |
if (salt != null && salt.length() > 0) { |
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
124 |
name.setSalt(salt); |
2 | 125 |
if (DEBUG) { |
126 |
System.out.println("Updated salt from pre-auth = " + name.getSalt()); |
|
127 |
} |
|
128 |
} |
|
129 |
PA_ENC_TIMESTAMP_REQUIRED = true; |
|
130 |
} |
|
131 |
||
132 |
// Used by Kinit |
|
133 |
public KrbAsReq( |
|
134 |
char[] password, |
|
135 |
KDCOptions options, |
|
136 |
PrincipalName cname, |
|
137 |
PrincipalName sname, |
|
138 |
KerberosTime from, |
|
139 |
KerberosTime till, |
|
140 |
KerberosTime rtime, |
|
141 |
int[] eTypes, |
|
142 |
HostAddresses addresses, |
|
143 |
Ticket[] additionalTickets) |
|
144 |
throws KrbException, IOException { |
|
145 |
this(password, |
|
146 |
false, 0, null, null, // pre-auth values |
|
147 |
options, |
|
148 |
cname, |
|
149 |
sname, // PrincipalName sname |
|
150 |
from, // KerberosTime from |
|
151 |
till, // KerberosTime till |
|
152 |
rtime, // KerberosTime rtime |
|
153 |
eTypes, // int[] eTypes |
|
154 |
addresses, // HostAddresses addresses |
|
155 |
additionalTickets); // Ticket[] additionalTickets |
|
156 |
} |
|
157 |
||
158 |
// Used by Kinit |
|
159 |
public KrbAsReq( |
|
160 |
char[] password, |
|
161 |
boolean pa_exists, |
|
162 |
int etype, |
|
3949
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
163 |
String salt, |
2 | 164 |
byte[] s2kparams, |
165 |
KDCOptions options, |
|
166 |
PrincipalName cname, |
|
167 |
PrincipalName sname, |
|
168 |
KerberosTime from, |
|
169 |
KerberosTime till, |
|
170 |
KerberosTime rtime, |
|
171 |
int[] eTypes, |
|
172 |
HostAddresses addresses, |
|
173 |
Ticket[] additionalTickets) |
|
174 |
throws KrbException, IOException { |
|
175 |
||
176 |
EncryptionKey[] keys = null; |
|
177 |
||
178 |
// update with preauth info |
|
179 |
if (pa_exists) { |
|
180 |
updatePA(etype, salt, s2kparams, cname); |
|
181 |
} |
|
182 |
||
183 |
if (password != null) { |
|
184 |
keys = EncryptionKey.acquireSecretKeys(password, cname.getSalt(), pa_exists, |
|
185 |
pa_etype, pa_s2kparams); |
|
186 |
} |
|
187 |
if (DEBUG) { |
|
188 |
System.out.println(">>>KrbAsReq salt is " + cname.getSalt()); |
|
189 |
} |
|
190 |
||
191 |
try { |
|
192 |
init( |
|
193 |
keys, |
|
194 |
options, |
|
195 |
cname, |
|
196 |
sname, |
|
197 |
from, |
|
198 |
till, |
|
199 |
rtime, |
|
200 |
eTypes, |
|
201 |
addresses, |
|
202 |
additionalTickets); |
|
203 |
} |
|
204 |
finally { |
|
205 |
/* |
|
206 |
* Its ok to destroy the key here because we created it and are |
|
207 |
* now done with it. |
|
208 |
*/ |
|
209 |
if (keys != null) { |
|
210 |
for (int i = 0; i < keys.length; i++) { |
|
211 |
keys[i].destroy(); |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
// Used in Kinit |
|
218 |
public KrbAsReq( |
|
219 |
EncryptionKey[] keys, |
|
220 |
KDCOptions options, |
|
221 |
PrincipalName cname, |
|
222 |
PrincipalName sname, |
|
223 |
KerberosTime from, |
|
224 |
KerberosTime till, |
|
225 |
KerberosTime rtime, |
|
226 |
int[] eTypes, |
|
227 |
HostAddresses addresses, |
|
228 |
Ticket[] additionalTickets) |
|
229 |
throws KrbException, IOException { |
|
230 |
this(keys, |
|
231 |
false, 0, null, null, // pre-auth values |
|
232 |
options, |
|
233 |
cname, |
|
234 |
sname, // PrincipalName sname |
|
235 |
from, // KerberosTime from |
|
236 |
till, // KerberosTime till |
|
237 |
rtime, // KerberosTime rtime |
|
238 |
eTypes, // int[] eTypes |
|
239 |
addresses, // HostAddresses addresses |
|
240 |
additionalTickets); // Ticket[] additionalTickets |
|
241 |
} |
|
242 |
||
243 |
// Used by Kinit |
|
244 |
public KrbAsReq( |
|
245 |
EncryptionKey[] keys, |
|
246 |
boolean pa_exists, |
|
247 |
int etype, |
|
3949
00603a93b589
6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents:
2
diff
changeset
|
248 |
String salt, |
2 | 249 |
byte[] s2kparams, |
250 |
KDCOptions options, |
|
251 |
PrincipalName cname, |
|
252 |
PrincipalName sname, |
|
253 |
KerberosTime from, |
|
254 |
KerberosTime till, |
|
255 |
KerberosTime rtime, |
|
256 |
int[] eTypes, |
|
257 |
HostAddresses addresses, |
|
258 |
Ticket[] additionalTickets) |
|
259 |
throws KrbException, IOException { |
|
260 |
||
261 |
// update with preauth info |
|
262 |
if (pa_exists) { |
|
263 |
// update pre-auth info |
|
264 |
updatePA(etype, salt, s2kparams, cname); |
|
265 |
||
266 |
if (DEBUG) { |
|
267 |
System.out.println(">>>KrbAsReq salt is " + cname.getSalt()); |
|
268 |
} |
|
269 |
} |
|
270 |
||
271 |
init( |
|
272 |
keys, |
|
273 |
options, |
|
274 |
cname, |
|
275 |
sname, |
|
276 |
from, |
|
277 |
till, |
|
278 |
rtime, |
|
279 |
eTypes, |
|
280 |
addresses, |
|
281 |
additionalTickets); |
|
282 |
} |
|
283 |
||
284 |
/* |
|
285 |
private KrbAsReq(KDCOptions options, |
|
286 |
PrincipalName cname, |
|
287 |
PrincipalName sname, |
|
288 |
KerberosTime from, |
|
289 |
KerberosTime till, |
|
290 |
KerberosTime rtime, |
|
291 |
int[] eTypes, |
|
292 |
HostAddresses addresses, |
|
293 |
Ticket[] additionalTickets) |
|
294 |
throws KrbException, IOException { |
|
295 |
init(null, |
|
296 |
options, |
|
297 |
cname, |
|
298 |
sname, |
|
299 |
from, |
|
300 |
till, |
|
301 |
rtime, |
|
302 |
eTypes, |
|
303 |
addresses, |
|
304 |
additionalTickets); |
|
305 |
} |
|
306 |
*/ |
|
307 |
||
308 |
private void init(EncryptionKey[] keys, |
|
309 |
KDCOptions options, |
|
310 |
PrincipalName cname, |
|
311 |
PrincipalName sname, |
|
312 |
KerberosTime from, |
|
313 |
KerberosTime till, |
|
314 |
KerberosTime rtime, |
|
315 |
int[] eTypes, |
|
316 |
HostAddresses addresses, |
|
317 |
Ticket[] additionalTickets ) |
|
318 |
throws KrbException, IOException { |
|
319 |
||
320 |
// check if they are valid arguments. The optional fields should be |
|
321 |
// consistent with settings in KDCOptions. Mar 17 2000 |
|
322 |
if (options.get(KDCOptions.FORWARDED) || |
|
323 |
options.get(KDCOptions.PROXY) || |
|
324 |
options.get(KDCOptions.ENC_TKT_IN_SKEY) || |
|
325 |
options.get(KDCOptions.RENEW) || |
|
326 |
options.get(KDCOptions.VALIDATE)) { |
|
327 |
// this option is only specified in a request to the |
|
328 |
// ticket-granting server |
|
329 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
330 |
} |
|
331 |
if (options.get(KDCOptions.POSTDATED)) { |
|
332 |
// if (from == null) |
|
333 |
// throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
334 |
} else { |
|
335 |
if (from != null) from = null; |
|
336 |
} |
|
337 |
if (options.get(KDCOptions.RENEWABLE)) { |
|
338 |
// if (rtime == null) |
|
339 |
// throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
340 |
} else { |
|
341 |
if (rtime != null) rtime = null; |
|
342 |
} |
|
343 |
||
344 |
princName = cname; |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
345 |
int[] tktETypes = EType.getDefaults("default_tkt_enctypes", keys); |
2 | 346 |
PAData[] paData = null; |
347 |
if (PA_ENC_TIMESTAMP_REQUIRED) { |
|
5774
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
348 |
EncryptionKey key = null; |
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
349 |
if (pa_etype != EncryptedData.ETYPE_NULL) { |
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
350 |
if (DEBUG) { |
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
351 |
System.out.println("Pre-Authenticaton: find key for etype = " + pa_etype); |
5774
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
352 |
} |
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
353 |
key = EncryptionKey.findKey(pa_etype, keys); |
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
354 |
} else { |
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
355 |
if (tktETypes.length > 0) { |
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
356 |
key = EncryptionKey.findKey(tktETypes[0], keys); |
5774
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
357 |
} |
4b9857e483c1
6951366: kerberos login failure on win2008 with AD set to win2000 compat mode
weijun
parents:
5627
diff
changeset
|
358 |
} |
2 | 359 |
if (DEBUG) { |
360 |
System.out.println("AS-REQ: Add PA_ENC_TIMESTAMP now"); |
|
361 |
} |
|
362 |
PAEncTSEnc ts = new PAEncTSEnc(); |
|
363 |
byte[] temp = ts.asn1Encode(); |
|
364 |
if (key != null) { |
|
365 |
// Use first key in list |
|
366 |
EncryptedData encTs = new EncryptedData(key, temp, |
|
367 |
KeyUsage.KU_PA_ENC_TS); |
|
368 |
paData = new PAData[1]; |
|
369 |
paData[0] = new PAData( Krb5.PA_ENC_TIMESTAMP, |
|
370 |
encTs.asn1Encode()); |
|
371 |
} |
|
372 |
} |
|
373 |
||
374 |
if (DEBUG) { |
|
375 |
System.out.println(">>> KrbAsReq calling createMessage"); |
|
376 |
} |
|
377 |
||
378 |
if (eTypes == null) { |
|
5802
ea99d72d3c19
6959292: regression: cannot login if session key and preauth does not use the same etype
weijun
parents:
5774
diff
changeset
|
379 |
eTypes = tktETypes; |
2 | 380 |
} |
381 |
||
382 |
// check to use addresses in tickets |
|
383 |
if (Config.getInstance().useAddresses()) { |
|
384 |
KDC_EMPTY_ADDRESSES_ALLOWED = false; |
|
385 |
} |
|
386 |
// get the local InetAddress if required |
|
387 |
if (addresses == null && !KDC_EMPTY_ADDRESSES_ALLOWED) { |
|
388 |
addresses = HostAddresses.getLocalAddresses(); |
|
389 |
} |
|
390 |
||
391 |
asReqMessg = createMessage( |
|
392 |
paData, |
|
393 |
options, |
|
394 |
cname, |
|
395 |
cname.getRealm(), |
|
396 |
sname, |
|
397 |
from, |
|
398 |
till, |
|
399 |
rtime, |
|
400 |
eTypes, |
|
401 |
addresses, |
|
402 |
additionalTickets); |
|
403 |
obuf = asReqMessg.asn1Encode(); |
|
404 |
} |
|
405 |
||
406 |
/** |
|
407 |
* Returns an AS-REP message corresponding to the AS-REQ that |
|
408 |
* was sent. |
|
409 |
* @param password The password that will be used to derive the |
|
410 |
* secret key that will decrypt the AS-REP from the KDC. |
|
411 |
* @exception KrbException if an error occurs while reading the data. |
|
412 |
* @exception IOException if an I/O error occurs while reading encoded data. |
|
413 |
*/ |
|
414 |
public KrbAsRep getReply(char[] password) |
|
415 |
throws KrbException, IOException { |
|
416 |
||
417 |
if (password == null) |
|
418 |
throw new KrbException(Krb5.API_INVALID_ARG); |
|
419 |
KrbAsRep temp = null; |
|
420 |
EncryptionKey[] keys = null; |
|
421 |
try { |
|
422 |
keys = EncryptionKey.acquireSecretKeys(password, |
|
423 |
princName.getSalt(), pa_exists, pa_etype, pa_s2kparams); |
|
424 |
temp = getReply(keys); |
|
425 |
} finally { |
|
426 |
/* |
|
427 |
* Its ok to destroy the key here because we created it and are |
|
428 |
* now done with it. |
|
429 |
*/ |
|
430 |
if (keys != null) { |
|
431 |
for (int i = 0; i < keys.length; i++) { |
|
432 |
keys[i].destroy(); |
|
433 |
} |
|
434 |
} |
|
435 |
} |
|
436 |
return temp; |
|
437 |
} |
|
438 |
||
439 |
/** |
|
440 |
* Sends an AS request to the realm of the client. |
|
441 |
* returns the KDC hostname that the request was sent to |
|
442 |
*/ |
|
443 |
||
444 |
public String send() |
|
445 |
throws IOException, KrbException |
|
446 |
{ |
|
447 |
String realmStr = null; |
|
448 |
if (princName != null) |
|
449 |
realmStr = princName.getRealmString(); |
|
450 |
||
451 |
return (send(realmStr)); |
|
452 |
} |
|
453 |
||
454 |
/** |
|
455 |
* Returns an AS-REP message corresponding to the AS-REQ that |
|
456 |
* was sent. |
|
457 |
* @param keys The secret keys that will decrypt the AS-REP from |
|
458 |
* the KDC; key selected depends on etype used to encrypt data. |
|
459 |
* @exception KrbException if an error occurs while reading the data. |
|
460 |
* @exception IOException if an I/O error occurs while reading encoded |
|
461 |
* data. |
|
462 |
* |
|
463 |
*/ |
|
464 |
public KrbAsRep getReply(EncryptionKey[] keys) |
|
465 |
throws KrbException,IOException { |
|
466 |
return new KrbAsRep(ibuf, keys, this); |
|
467 |
} |
|
468 |
||
469 |
private ASReq createMessage( |
|
470 |
PAData[] paData, |
|
471 |
KDCOptions kdc_options, |
|
472 |
PrincipalName cname, |
|
473 |
Realm crealm, |
|
474 |
PrincipalName sname, |
|
475 |
KerberosTime from, |
|
476 |
KerberosTime till, |
|
477 |
KerberosTime rtime, |
|
478 |
int[] eTypes, |
|
479 |
HostAddresses addresses, |
|
480 |
Ticket[] additionalTickets |
|
481 |
) throws Asn1Exception, KrbApErrException, |
|
482 |
RealmException, UnknownHostException, IOException { |
|
483 |
||
484 |
if (DEBUG) { |
|
485 |
System.out.println(">>> KrbAsReq in createMessage"); |
|
486 |
} |
|
487 |
||
488 |
PrincipalName req_sname = null; |
|
489 |
if (sname == null) { |
|
490 |
if (crealm == null) { |
|
491 |
throw new RealmException(Krb5.REALM_NULL, |
|
492 |
"default realm not specified "); |
|
493 |
} |
|
494 |
req_sname = new PrincipalName( |
|
495 |
"krbtgt" + |
|
496 |
PrincipalName.NAME_COMPONENT_SEPARATOR + |
|
497 |
crealm.toString(), |
|
498 |
PrincipalName.KRB_NT_SRV_INST); |
|
499 |
} else |
|
500 |
req_sname = sname; |
|
501 |
||
502 |
KerberosTime req_till = null; |
|
503 |
if (till == null) { |
|
504 |
req_till = new KerberosTime(); |
|
505 |
} else { |
|
506 |
req_till = till; |
|
507 |
} |
|
508 |
||
509 |
KDCReqBody kdc_req_body = new KDCReqBody(kdc_options, |
|
510 |
cname, |
|
511 |
crealm, |
|
512 |
req_sname, |
|
513 |
from, |
|
514 |
req_till, |
|
515 |
rtime, |
|
516 |
Nonce.value(), |
|
517 |
eTypes, |
|
518 |
addresses, |
|
519 |
null, |
|
520 |
additionalTickets); |
|
521 |
||
522 |
return new ASReq( |
|
523 |
paData, |
|
524 |
kdc_req_body); |
|
525 |
} |
|
526 |
||
527 |
ASReq getMessage() { |
|
528 |
return asReqMessg; |
|
529 |
} |
|
530 |
} |