author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57487 | 643978a35f6e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
2 |
* Copyright (c) 2000, 2019, 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.*; |
|
36 |
import java.io.IOException; |
|
37 |
import java.net.UnknownHostException; |
|
47005
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
38 |
import java.time.Instant; |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
39 |
import java.util.Arrays; |
2 | 40 |
|
41 |
/** |
|
42 |
* This class encapsulates a Kerberos TGS-REQ that is sent from the |
|
43 |
* client to the KDC. |
|
44 |
*/ |
|
7183 | 45 |
public class KrbTgsReq { |
2 | 46 |
|
47 |
private PrincipalName princName; |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
48 |
private PrincipalName clientAlias; |
2 | 49 |
private PrincipalName servName; |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
50 |
private PrincipalName serverAlias; |
2 | 51 |
private TGSReq tgsReqMessg; |
52 |
private KerberosTime ctime; |
|
53 |
private Ticket secondTicket = null; |
|
54 |
private boolean useSubkey = false; |
|
55 |
EncryptionKey tgsReqKey; |
|
56 |
||
57 |
private static final boolean DEBUG = Krb5.DEBUG; |
|
58 |
||
7183 | 59 |
private byte[] obuf; |
60 |
private byte[] ibuf; |
|
2 | 61 |
|
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
62 |
// Used in CredentialsUtil |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
63 |
public KrbTgsReq(KDCOptions options, Credentials asCreds, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
64 |
PrincipalName cname, PrincipalName clientAlias, |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
65 |
PrincipalName sname, PrincipalName serverAlias, |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
66 |
Ticket[] additionalTickets, PAData[] extraPAs) |
2 | 67 |
throws KrbException, IOException { |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
68 |
this(options, |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
69 |
asCreds, |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
70 |
cname, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
71 |
clientAlias, |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
72 |
sname, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
73 |
serverAlias, |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
74 |
null, // KerberosTime from |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
75 |
null, // KerberosTime till |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
76 |
null, // KerberosTime rtime |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
77 |
null, // int[] eTypes |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
78 |
null, // HostAddresses addresses |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
79 |
null, // AuthorizationData authorizationData |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
80 |
additionalTickets, |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
81 |
null, // EncryptionKey subKey |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
82 |
extraPAs); |
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
83 |
} |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
84 |
|
73 | 85 |
// Called by Credentials, KrbCred |
86 |
KrbTgsReq( |
|
87 |
KDCOptions options, |
|
88 |
Credentials asCreds, |
|
89 |
PrincipalName sname, |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
90 |
PrincipalName serverAlias, |
73 | 91 |
KerberosTime from, |
92 |
KerberosTime till, |
|
93 |
KerberosTime rtime, |
|
94 |
int[] eTypes, |
|
95 |
HostAddresses addresses, |
|
96 |
AuthorizationData authorizationData, |
|
97 |
Ticket[] additionalTickets, |
|
98 |
EncryptionKey subKey) throws KrbException, IOException { |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
99 |
this(options, asCreds, asCreds.getClient(), asCreds.getClientAlias(), |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
100 |
sname, serverAlias, from, till, rtime, eTypes, |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
101 |
addresses, authorizationData, additionalTickets, subKey, null); |
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
102 |
} |
2 | 103 |
|
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
104 |
private KrbTgsReq( |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
105 |
KDCOptions options, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
106 |
Credentials asCreds, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
107 |
PrincipalName cname, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
108 |
PrincipalName clientAlias, |
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
109 |
PrincipalName sname, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
110 |
PrincipalName serverAlias, |
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
111 |
KerberosTime from, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
112 |
KerberosTime till, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
113 |
KerberosTime rtime, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
114 |
int[] eTypes, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
115 |
HostAddresses addresses, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
116 |
AuthorizationData authorizationData, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
117 |
Ticket[] additionalTickets, |
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
118 |
EncryptionKey subKey, |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
119 |
PAData[] extraPAs) throws KrbException, IOException { |
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
120 |
|
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
121 |
princName = cname; |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
122 |
this.clientAlias = clientAlias; |
73 | 123 |
servName = sname; |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
124 |
this.serverAlias = serverAlias; |
16905 | 125 |
ctime = KerberosTime.now(); |
2 | 126 |
|
73 | 127 |
// check if they are valid arguments. The optional fields |
28670
bb9afe681988
8022582: Relax response flags checking in sun.security.krb5.KrbKdcRep.check.
weijun
parents:
27946
diff
changeset
|
128 |
// should be consistent with settings in KDCOptions. |
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
129 |
|
73 | 130 |
if (options.get(KDCOptions.FORWARDABLE) && |
131 |
(!(asCreds.flags.get(Krb5.TKT_OPTS_FORWARDABLE)))) { |
|
28670
bb9afe681988
8022582: Relax response flags checking in sun.security.krb5.KrbKdcRep.check.
weijun
parents:
27946
diff
changeset
|
132 |
options.set(KDCOptions.FORWARDABLE, false); |
73 | 133 |
} |
134 |
if (options.get(KDCOptions.FORWARDED)) { |
|
135 |
if (!(asCreds.flags.get(KDCOptions.FORWARDABLE))) |
|
136 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
137 |
} |
|
138 |
if (options.get(KDCOptions.PROXIABLE) && |
|
139 |
(!(asCreds.flags.get(Krb5.TKT_OPTS_PROXIABLE)))) { |
|
140 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
141 |
} |
|
142 |
if (options.get(KDCOptions.PROXY)) { |
|
143 |
if (!(asCreds.flags.get(KDCOptions.PROXIABLE))) |
|
144 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
145 |
} |
|
146 |
if (options.get(KDCOptions.ALLOW_POSTDATE) && |
|
147 |
(!(asCreds.flags.get(Krb5.TKT_OPTS_MAY_POSTDATE)))) { |
|
148 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
149 |
} |
|
150 |
if (options.get(KDCOptions.RENEWABLE) && |
|
151 |
(!(asCreds.flags.get(Krb5.TKT_OPTS_RENEWABLE)))) { |
|
152 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
153 |
} |
|
2 | 154 |
|
73 | 155 |
if (options.get(KDCOptions.POSTDATED)) { |
156 |
if (!(asCreds.flags.get(KDCOptions.POSTDATED))) |
|
157 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
158 |
} else { |
|
159 |
if (from != null) from = null; |
|
160 |
} |
|
161 |
if (options.get(KDCOptions.RENEWABLE)) { |
|
162 |
if (!(asCreds.flags.get(KDCOptions.RENEWABLE))) |
|
163 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
164 |
} else { |
|
165 |
if (rtime != null) rtime = null; |
|
166 |
} |
|
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
167 |
if (options.get(KDCOptions.ENC_TKT_IN_SKEY) || options.get(KDCOptions.CNAME_IN_ADDL_TKT)) { |
73 | 168 |
if (additionalTickets == null) |
169 |
throw new KrbException(Krb5.KRB_AP_ERR_REQ_OPTIONS); |
|
170 |
// in TGS_REQ there could be more than one additional |
|
171 |
// tickets, but in file-based credential cache, |
|
172 |
// there is only one additional ticket field. |
|
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
173 |
secondTicket = additionalTickets[0]; |
73 | 174 |
} else { |
175 |
if (additionalTickets != null) |
|
176 |
additionalTickets = null; |
|
177 |
} |
|
2 | 178 |
|
73 | 179 |
tgsReqMessg = createRequest( |
180 |
options, |
|
181 |
asCreds.ticket, |
|
182 |
asCreds.key, |
|
183 |
ctime, |
|
184 |
princName, |
|
185 |
servName, |
|
186 |
from, |
|
187 |
till, |
|
188 |
rtime, |
|
189 |
eTypes, |
|
190 |
addresses, |
|
191 |
authorizationData, |
|
192 |
additionalTickets, |
|
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
193 |
subKey, |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
194 |
extraPAs); |
73 | 195 |
obuf = tgsReqMessg.asn1Encode(); |
2 | 196 |
|
73 | 197 |
// XXX We need to revisit this to see if can't move it |
198 |
// up such that FORWARDED flag set in the options |
|
199 |
// is included in the marshaled request. |
|
200 |
/* |
|
201 |
* If this is based on a forwarded ticket, record that in the |
|
202 |
* options, because the returned TgsRep will contain the |
|
203 |
* FORWARDED flag set. |
|
204 |
*/ |
|
205 |
if (asCreds.flags.get(KDCOptions.FORWARDED)) |
|
206 |
options.set(KDCOptions.FORWARDED, true); |
|
2 | 207 |
|
208 |
||
73 | 209 |
} |
2 | 210 |
|
211 |
/** |
|
212 |
* Sends a TGS request to the realm of the target. |
|
213 |
* @throws KrbException |
|
214 |
* @throws IOException |
|
215 |
*/ |
|
7183 | 216 |
public void send() throws IOException, KrbException { |
2 | 217 |
String realmStr = null; |
218 |
if (servName != null) |
|
219 |
realmStr = servName.getRealmString(); |
|
7183 | 220 |
KdcComm comm = new KdcComm(realmStr); |
221 |
ibuf = comm.send(obuf); |
|
2 | 222 |
} |
223 |
||
224 |
public KrbTgsRep getReply() |
|
225 |
throws KrbException, IOException { |
|
226 |
return new KrbTgsRep(ibuf, this); |
|
227 |
} |
|
228 |
||
229 |
/** |
|
230 |
* Sends the request, waits for a reply, and returns the Credentials. |
|
231 |
* Used in Credentials, KrbCred, and internal/CredentialsUtil. |
|
232 |
*/ |
|
233 |
public Credentials sendAndGetCreds() throws IOException, KrbException { |
|
234 |
KrbTgsRep tgs_rep = null; |
|
235 |
String kdc = null; |
|
7183 | 236 |
send(); |
237 |
tgs_rep = getReply(); |
|
2 | 238 |
return tgs_rep.getCreds(); |
239 |
} |
|
240 |
||
241 |
KerberosTime getCtime() { |
|
242 |
return ctime; |
|
243 |
} |
|
244 |
||
245 |
private TGSReq createRequest( |
|
246 |
KDCOptions kdc_options, |
|
247 |
Ticket ticket, |
|
248 |
EncryptionKey key, |
|
249 |
KerberosTime ctime, |
|
250 |
PrincipalName cname, |
|
251 |
PrincipalName sname, |
|
252 |
KerberosTime from, |
|
253 |
KerberosTime till, |
|
254 |
KerberosTime rtime, |
|
255 |
int[] eTypes, |
|
256 |
HostAddresses addresses, |
|
257 |
AuthorizationData authorizationData, |
|
258 |
Ticket[] additionalTickets, |
|
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
259 |
EncryptionKey subKey, |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
260 |
PAData[] extraPAs) |
18168
f47169155ea0
8014310: JAAS/Krb5LoginModule using des encytypes failure with NPE after JDK-8012679
weijun
parents:
16905
diff
changeset
|
261 |
throws IOException, KrbException, UnknownHostException { |
2 | 262 |
KerberosTime req_till = null; |
263 |
if (till == null) { |
|
47005
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
264 |
String d = Config.getInstance().get("libdefaults", "ticket_lifetime"); |
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
265 |
if (d != null) { |
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
266 |
req_till = new KerberosTime(Instant.now().plusSeconds(Config.duration(d))); |
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
267 |
} else { |
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
268 |
req_till = new KerberosTime(0); // Choose KDC maximum allowed |
dbfaf076da58
8186576: KerberosTicket does not properly handle renewable tickets at the end of their lifetime
weijun
parents:
28670
diff
changeset
|
269 |
} |
2 | 270 |
} else { |
271 |
req_till = till; |
|
272 |
} |
|
273 |
||
274 |
/* |
|
275 |
* RFC 4120, Section 5.4.2. |
|
276 |
* For KRB_TGS_REP, the ciphertext is encrypted in the |
|
277 |
* sub-session key from the Authenticator, or if absent, |
|
278 |
* the session key from the ticket-granting ticket used |
|
279 |
* in the request. |
|
280 |
* |
|
281 |
* To support this, use tgsReqKey to remember which key to use. |
|
282 |
*/ |
|
283 |
tgsReqKey = key; |
|
284 |
||
285 |
int[] req_eTypes = null; |
|
286 |
if (eTypes == null) { |
|
287 |
req_eTypes = EType.getDefaults("default_tgs_enctypes"); |
|
288 |
} else { |
|
289 |
req_eTypes = eTypes; |
|
290 |
} |
|
291 |
||
292 |
EncryptionKey reqKey = null; |
|
293 |
EncryptedData encAuthorizationData = null; |
|
294 |
if (authorizationData != null) { |
|
295 |
byte[] ad = authorizationData.asn1Encode(); |
|
296 |
if (subKey != null) { |
|
297 |
reqKey = subKey; |
|
298 |
tgsReqKey = subKey; // Key to use to decrypt reply |
|
299 |
useSubkey = true; |
|
300 |
encAuthorizationData = new EncryptedData(reqKey, ad, |
|
301 |
KeyUsage.KU_TGS_REQ_AUTH_DATA_SUBKEY); |
|
302 |
} else |
|
303 |
encAuthorizationData = new EncryptedData(key, ad, |
|
304 |
KeyUsage.KU_TGS_REQ_AUTH_DATA_SESSKEY); |
|
305 |
} |
|
306 |
||
307 |
KDCReqBody reqBody = new KDCReqBody( |
|
308 |
kdc_options, |
|
309 |
cname, |
|
310 |
sname, |
|
311 |
from, |
|
312 |
req_till, |
|
313 |
rtime, |
|
314 |
Nonce.value(), |
|
315 |
req_eTypes, |
|
316 |
addresses, |
|
317 |
encAuthorizationData, |
|
318 |
additionalTickets); |
|
319 |
||
320 |
byte[] temp = reqBody.asn1Encode(Krb5.KRB_TGS_REQ); |
|
321 |
// if the checksum type is one of the keyed checksum types, |
|
322 |
// use session key. |
|
323 |
Checksum cksum; |
|
324 |
switch (Checksum.CKSUMTYPE_DEFAULT) { |
|
325 |
case Checksum.CKSUMTYPE_RSA_MD4_DES: |
|
326 |
case Checksum.CKSUMTYPE_DES_MAC: |
|
327 |
case Checksum.CKSUMTYPE_DES_MAC_K: |
|
328 |
case Checksum.CKSUMTYPE_RSA_MD4_DES_K: |
|
329 |
case Checksum.CKSUMTYPE_RSA_MD5_DES: |
|
330 |
case Checksum.CKSUMTYPE_HMAC_SHA1_DES3_KD: |
|
331 |
case Checksum.CKSUMTYPE_HMAC_MD5_ARCFOUR: |
|
332 |
case Checksum.CKSUMTYPE_HMAC_SHA1_96_AES128: |
|
333 |
case Checksum.CKSUMTYPE_HMAC_SHA1_96_AES256: |
|
48651
67abfee27e69
8014628: Support AES Encryption with HMAC-SHA2 for Kerberos 5
weijun
parents:
47216
diff
changeset
|
334 |
case Checksum.CKSUMTYPE_HMAC_SHA256_128_AES128: |
67abfee27e69
8014628: Support AES Encryption with HMAC-SHA2 for Kerberos 5
weijun
parents:
47216
diff
changeset
|
335 |
case Checksum.CKSUMTYPE_HMAC_SHA384_192_AES256: |
2 | 336 |
cksum = new Checksum(Checksum.CKSUMTYPE_DEFAULT, temp, key, |
337 |
KeyUsage.KU_PA_TGS_REQ_CKSUM); |
|
338 |
break; |
|
339 |
case Checksum.CKSUMTYPE_CRC32: |
|
340 |
case Checksum.CKSUMTYPE_RSA_MD4: |
|
341 |
case Checksum.CKSUMTYPE_RSA_MD5: |
|
342 |
default: |
|
343 |
cksum = new Checksum(Checksum.CKSUMTYPE_DEFAULT, temp); |
|
344 |
} |
|
345 |
||
346 |
// Usage will be KeyUsage.KU_PA_TGS_REQ_AUTHENTICATOR |
|
347 |
||
348 |
byte[] tgs_ap_req = new KrbApReq( |
|
349 |
new APOptions(), |
|
350 |
ticket, |
|
351 |
key, |
|
352 |
cname, |
|
353 |
cksum, |
|
354 |
ctime, |
|
355 |
reqKey, |
|
356 |
null, |
|
357 |
null).getMessage(); |
|
358 |
||
14413
e954df027393
6355584: Introduce constrained Kerberos delegation
weijun
parents:
14342
diff
changeset
|
359 |
PAData tgsPAData = new PAData(Krb5.PA_TGS_REQ, tgs_ap_req); |
55258
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
360 |
PAData[] pa; |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
361 |
if (extraPAs != null) { |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
362 |
pa = Arrays.copyOf(extraPAs, extraPAs.length + 1); |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
363 |
pa[extraPAs.length] = tgsPAData; |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
364 |
} else { |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
365 |
pa = new PAData[] {tgsPAData}; |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
366 |
} |
d65d3c37232c
8215032: Support Kerberos cross-realm referrals (RFC 6806)
mbalao
parents:
48651
diff
changeset
|
367 |
return new TGSReq(pa, reqBody); |
2 | 368 |
} |
369 |
||
370 |
TGSReq getMessage() { |
|
371 |
return tgsReqMessg; |
|
372 |
} |
|
373 |
||
374 |
Ticket getSecondTicket() { |
|
375 |
return secondTicket; |
|
376 |
} |
|
377 |
||
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
378 |
PrincipalName getClientAlias() { |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
379 |
return clientAlias; |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
380 |
} |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
381 |
|
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
382 |
PrincipalName getServerAlias() { |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
383 |
return serverAlias; |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
384 |
} |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
55258
diff
changeset
|
385 |
|
2 | 386 |
private static void debug(String message) { |
387 |
// System.err.println(">>> KrbTgsReq: " + message); |
|
388 |
} |
|
389 |
||
390 |
boolean usedSubkey() { |
|
391 |
return useSubkey; |
|
392 |
} |
|
393 |
||
394 |
} |