author | martin |
Thu, 30 Oct 2014 07:31:41 -0700 | |
changeset 28059 | e576535359cc |
parent 27771 | 360714d431ab |
child 34687 | d302ed125dc9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
18830 | 2 |
* Copyright (c) 2000, 2013, 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 |
package javax.security.auth.kerberos; |
|
27 |
||
28 |
import java.io.*; |
|
29 |
import java.util.Date; |
|
30 |
import java.util.Arrays; |
|
31 |
import java.net.InetAddress; |
|
32 |
import javax.crypto.SecretKey; |
|
33 |
import javax.security.auth.Refreshable; |
|
34 |
import javax.security.auth.Destroyable; |
|
35 |
import javax.security.auth.RefreshFailedException; |
|
36 |
import javax.security.auth.DestroyFailedException; |
|
37 |
import sun.misc.HexDumpEncoder; |
|
38 |
||
39 |
/** |
|
40 |
* This class encapsulates a Kerberos ticket and associated |
|
41 |
* information as viewed from the client's point of view. It captures all |
|
42 |
* information that the Key Distribution Center (KDC) sends to the client |
|
43 |
* in the reply message KDC-REP defined in the Kerberos Protocol |
|
44 |
* Specification (<a href=http://www.ietf.org/rfc/rfc4120.txt>RFC 4120</a>). |
|
45 |
* <p> |
|
46 |
* All Kerberos JAAS login modules that authenticate a user to a KDC should |
|
47 |
* use this class. Where available, the login module might even read this |
|
48 |
* information from a ticket cache in the operating system instead of |
|
49 |
* directly communicating with the KDC. During the commit phase of the JAAS |
|
50 |
* authentication process, the JAAS login module should instantiate this |
|
51 |
* class and store the instance in the private credential set of a |
|
52 |
* {@link javax.security.auth.Subject Subject}.<p> |
|
53 |
* |
|
54 |
* It might be necessary for the application to be granted a |
|
55 |
* {@link javax.security.auth.PrivateCredentialPermission |
|
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
56 |
* PrivateCredentialPermission} if it needs to access a {@code KerberosTicket} |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
57 |
* instance from a {@code Subject}. This permission is not needed when the |
2 | 58 |
* application depends on the default JGSS Kerberos mechanism to access the |
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
59 |
* {@code KerberosTicket}. In that case, however, the application will need an |
2 | 60 |
* appropriate |
61 |
* {@link javax.security.auth.kerberos.ServicePermission ServicePermission}. |
|
62 |
* <p> |
|
63 |
* Note that this class is applicable to both ticket granting tickets and |
|
64 |
* other regular service tickets. A ticket granting ticket is just a |
|
65 |
* special case of a more generalized service ticket. |
|
66 |
* |
|
67 |
* @see javax.security.auth.Subject |
|
68 |
* @see javax.security.auth.PrivateCredentialPermission |
|
69 |
* @see javax.security.auth.login.LoginContext |
|
70 |
* @see org.ietf.jgss.GSSCredential |
|
71 |
* @see org.ietf.jgss.GSSManager |
|
72 |
* |
|
73 |
* @author Mayank Upadhyay |
|
74 |
* @since 1.4 |
|
75 |
*/ |
|
76 |
public class KerberosTicket implements Destroyable, Refreshable, |
|
77 |
java.io.Serializable { |
|
78 |
||
79 |
private static final long serialVersionUID = 7395334370157380539L; |
|
80 |
||
81 |
// XXX Make these flag indices public |
|
82 |
private static final int FORWARDABLE_TICKET_FLAG = 1; |
|
83 |
private static final int FORWARDED_TICKET_FLAG = 2; |
|
84 |
private static final int PROXIABLE_TICKET_FLAG = 3; |
|
85 |
private static final int PROXY_TICKET_FLAG = 4; |
|
86 |
private static final int POSTDATED_TICKET_FLAG = 6; |
|
87 |
private static final int RENEWABLE_TICKET_FLAG = 8; |
|
88 |
private static final int INITIAL_TICKET_FLAG = 9; |
|
89 |
||
90 |
private static final int NUM_FLAGS = 32; |
|
91 |
||
92 |
/** |
|
93 |
* |
|
94 |
* ASN.1 DER Encoding of the Ticket as defined in the |
|
95 |
* Kerberos Protocol Specification RFC4120. |
|
96 |
* |
|
97 |
* @serial |
|
98 |
*/ |
|
99 |
||
100 |
private byte[] asn1Encoding; |
|
101 |
||
102 |
/** |
|
18830 | 103 |
*{@code KeyImpl} is serialized by writing out the ASN1 Encoded bytes |
2 | 104 |
* of the encryption key. The ASN1 encoding is defined in RFC4120 and as |
105 |
* follows: |
|
106 |
* <pre> |
|
107 |
* EncryptionKey ::= SEQUENCE { |
|
108 |
* keytype [0] Int32 -- actually encryption type --, |
|
109 |
* keyvalue [1] OCTET STRING |
|
110 |
* } |
|
111 |
* </pre> |
|
112 |
* |
|
113 |
* @serial |
|
114 |
*/ |
|
115 |
||
116 |
private KeyImpl sessionKey; |
|
117 |
||
118 |
/** |
|
119 |
* |
|
120 |
* Ticket Flags as defined in the Kerberos Protocol Specification RFC4120. |
|
121 |
* |
|
122 |
* @serial |
|
123 |
*/ |
|
124 |
||
125 |
private boolean[] flags; |
|
126 |
||
127 |
/** |
|
128 |
* |
|
129 |
* Time of initial authentication |
|
130 |
* |
|
131 |
* @serial |
|
132 |
*/ |
|
133 |
||
134 |
private Date authTime; |
|
135 |
||
136 |
/** |
|
137 |
* |
|
138 |
* Time after which the ticket is valid. |
|
139 |
* @serial |
|
140 |
*/ |
|
141 |
private Date startTime; |
|
142 |
||
143 |
/** |
|
144 |
* |
|
145 |
* Time after which the ticket will not be honored. (its expiration time). |
|
146 |
* |
|
147 |
* @serial |
|
148 |
*/ |
|
149 |
||
150 |
private Date endTime; |
|
151 |
||
152 |
/** |
|
153 |
* |
|
154 |
* For renewable Tickets it indicates the maximum endtime that may be |
|
155 |
* included in a renewal. It can be thought of as the absolute expiration |
|
156 |
* time for the ticket, including all renewals. This field may be null |
|
157 |
* for tickets that are not renewable. |
|
158 |
* |
|
159 |
* @serial |
|
160 |
*/ |
|
161 |
||
162 |
private Date renewTill; |
|
163 |
||
164 |
/** |
|
165 |
* |
|
166 |
* Client that owns the service ticket |
|
167 |
* |
|
168 |
* @serial |
|
169 |
*/ |
|
170 |
||
171 |
private KerberosPrincipal client; |
|
172 |
||
173 |
/** |
|
174 |
* |
|
175 |
* The service for which the ticket was issued. |
|
176 |
* |
|
177 |
* @serial |
|
178 |
*/ |
|
179 |
||
180 |
private KerberosPrincipal server; |
|
181 |
||
182 |
/** |
|
183 |
* |
|
184 |
* The addresses from where the ticket may be used by the client. |
|
185 |
* This field may be null when the ticket is usable from any address. |
|
186 |
* |
|
187 |
* @serial |
|
188 |
*/ |
|
189 |
||
190 |
||
191 |
private InetAddress[] clientAddresses; |
|
192 |
||
193 |
private transient boolean destroyed = false; |
|
194 |
||
195 |
/** |
|
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
196 |
* Constructs a {@code KerberosTicket} using credentials information that a |
2 | 197 |
* client either receives from a KDC or reads from a cache. |
198 |
* |
|
199 |
* @param asn1Encoding the ASN.1 encoding of the ticket as defined by |
|
200 |
* the Kerberos protocol specification. |
|
201 |
* @param client the client that owns this service |
|
202 |
* ticket |
|
203 |
* @param server the service that this ticket is for |
|
204 |
* @param sessionKey the raw bytes for the session key that must be |
|
205 |
* used to encrypt the authenticator that will be sent to the server |
|
206 |
* @param keyType the key type for the session key as defined by the |
|
207 |
* Kerberos protocol specification. |
|
208 |
* @param flags the ticket flags. Each element in this array indicates |
|
209 |
* the value for the corresponding bit in the ASN.1 BitString that |
|
210 |
* represents the ticket flags. If the number of elements in this array |
|
211 |
* is less than the number of flags used by the Kerberos protocol, |
|
212 |
* then the missing flags will be filled in with false. |
|
213 |
* @param authTime the time of initial authentication for the client |
|
214 |
* @param startTime the time after which the ticket will be valid. This |
|
215 |
* may be null in which case the value of authTime is treated as the |
|
216 |
* startTime. |
|
217 |
* @param endTime the time after which the ticket will no longer be |
|
218 |
* valid |
|
219 |
* @param renewTill an absolute expiration time for the ticket, |
|
220 |
* including all renewal that might be possible. This field may be null |
|
221 |
* for tickets that are not renewable. |
|
222 |
* @param clientAddresses the addresses from where the ticket may be |
|
223 |
* used by the client. This field may be null when the ticket is usable |
|
224 |
* from any address. |
|
225 |
*/ |
|
226 |
public KerberosTicket(byte[] asn1Encoding, |
|
227 |
KerberosPrincipal client, |
|
228 |
KerberosPrincipal server, |
|
229 |
byte[] sessionKey, |
|
230 |
int keyType, |
|
231 |
boolean[] flags, |
|
232 |
Date authTime, |
|
233 |
Date startTime, |
|
234 |
Date endTime, |
|
235 |
Date renewTill, |
|
236 |
InetAddress[] clientAddresses) { |
|
237 |
||
238 |
init(asn1Encoding, client, server, sessionKey, keyType, flags, |
|
239 |
authTime, startTime, endTime, renewTill, clientAddresses); |
|
240 |
} |
|
241 |
||
242 |
private void init(byte[] asn1Encoding, |
|
243 |
KerberosPrincipal client, |
|
244 |
KerberosPrincipal server, |
|
245 |
byte[] sessionKey, |
|
246 |
int keyType, |
|
247 |
boolean[] flags, |
|
248 |
Date authTime, |
|
249 |
Date startTime, |
|
250 |
Date endTime, |
|
251 |
Date renewTill, |
|
252 |
InetAddress[] clientAddresses) { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
253 |
if (sessionKey == null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
254 |
throw new IllegalArgumentException("Session key for ticket" |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
255 |
+ " cannot be null"); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
256 |
} |
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
257 |
init(asn1Encoding, client, server, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
258 |
new KeyImpl(sessionKey, keyType), flags, authTime, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
259 |
startTime, endTime, renewTill, clientAddresses); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
260 |
} |
2 | 261 |
|
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
262 |
private void init(byte[] asn1Encoding, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
263 |
KerberosPrincipal client, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
264 |
KerberosPrincipal server, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
265 |
KeyImpl sessionKey, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
266 |
boolean[] flags, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
267 |
Date authTime, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
268 |
Date startTime, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
269 |
Date endTime, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
270 |
Date renewTill, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
271 |
InetAddress[] clientAddresses) { |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
272 |
if (asn1Encoding == null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
273 |
throw new IllegalArgumentException("ASN.1 encoding of ticket" |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
274 |
+ " cannot be null"); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
275 |
} |
2 | 276 |
this.asn1Encoding = asn1Encoding.clone(); |
277 |
||
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
278 |
if (client == null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
279 |
throw new IllegalArgumentException("Client name in ticket" |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
280 |
+ " cannot be null"); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
281 |
} |
2 | 282 |
this.client = client; |
283 |
||
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
284 |
if (server == null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
285 |
throw new IllegalArgumentException("Server name in ticket" |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
286 |
+ " cannot be null"); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
287 |
} |
2 | 288 |
this.server = server; |
289 |
||
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
290 |
// Caller needs to make sure `sessionKey` will not be null |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
291 |
this.sessionKey = sessionKey; |
2 | 292 |
|
293 |
if (flags != null) { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
294 |
if (flags.length >= NUM_FLAGS) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
295 |
this.flags = flags.clone(); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
296 |
} else { |
2 | 297 |
this.flags = new boolean[NUM_FLAGS]; |
298 |
// Fill in whatever we have |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
299 |
for (int i = 0; i < flags.length; i++) { |
2 | 300 |
this.flags[i] = flags[i]; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
301 |
} |
2 | 302 |
} |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
303 |
} else { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
304 |
this.flags = new boolean[NUM_FLAGS]; |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
305 |
} |
2 | 306 |
|
307 |
if (this.flags[RENEWABLE_TICKET_FLAG]) { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
308 |
if (renewTill == null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
309 |
throw new IllegalArgumentException("The renewable period " |
2 | 310 |
+ "end time cannot be null for renewable tickets."); |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
311 |
} |
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
312 |
this.renewTill = new Date(renewTill.getTime()); |
2 | 313 |
} |
314 |
||
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
315 |
if (authTime != null) { |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
316 |
this.authTime = new Date(authTime.getTime()); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
317 |
} |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
318 |
if (startTime != null) { |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
319 |
this.startTime = new Date(startTime.getTime()); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
320 |
} else { |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
321 |
this.startTime = this.authTime; |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
322 |
} |
2 | 323 |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
324 |
if (endTime == null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
325 |
throw new IllegalArgumentException("End time for ticket validity" |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
326 |
+ " cannot be null"); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
327 |
} |
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
328 |
this.endTime = new Date(endTime.getTime()); |
2 | 329 |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
330 |
if (clientAddresses != null) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
331 |
this.clientAddresses = clientAddresses.clone(); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
332 |
} |
2 | 333 |
} |
334 |
||
335 |
/** |
|
336 |
* Returns the client principal associated with this ticket. |
|
337 |
* |
|
338 |
* @return the client principal. |
|
339 |
*/ |
|
340 |
public final KerberosPrincipal getClient() { |
|
341 |
return client; |
|
342 |
} |
|
343 |
||
344 |
/** |
|
345 |
* Returns the service principal associated with this ticket. |
|
346 |
* |
|
347 |
* @return the service principal. |
|
348 |
*/ |
|
349 |
public final KerberosPrincipal getServer() { |
|
350 |
return server; |
|
351 |
} |
|
352 |
||
353 |
/** |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
354 |
* Returns the session key associated with this ticket. The return value |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
355 |
* is always a {@link EncryptionKey} object. |
2 | 356 |
* |
357 |
* @return the session key. |
|
358 |
*/ |
|
359 |
public final SecretKey getSessionKey() { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
360 |
if (destroyed) { |
2 | 361 |
throw new IllegalStateException("This ticket is no longer valid"); |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
362 |
} |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
363 |
return new EncryptionKey( |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
364 |
sessionKey.getEncoded(), sessionKey.getKeyType()); |
2 | 365 |
} |
366 |
||
367 |
/** |
|
368 |
* Returns the key type of the session key associated with this |
|
369 |
* ticket as defined by the Kerberos Protocol Specification. |
|
370 |
* |
|
371 |
* @return the key type of the session key associated with this |
|
372 |
* ticket. |
|
373 |
* |
|
374 |
* @see #getSessionKey() |
|
375 |
*/ |
|
376 |
public final int getSessionKeyType() { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
377 |
if (destroyed) { |
2 | 378 |
throw new IllegalStateException("This ticket is no longer valid"); |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
379 |
} |
2 | 380 |
return sessionKey.getKeyType(); |
381 |
} |
|
382 |
||
383 |
/** |
|
384 |
* Determines if this ticket is forwardable. |
|
385 |
* |
|
386 |
* @return true if this ticket is forwardable, false if not. |
|
387 |
*/ |
|
388 |
public final boolean isForwardable() { |
|
389 |
return flags[FORWARDABLE_TICKET_FLAG]; |
|
390 |
} |
|
391 |
||
392 |
/** |
|
393 |
* Determines if this ticket had been forwarded or was issued based on |
|
394 |
* authentication involving a forwarded ticket-granting ticket. |
|
395 |
* |
|
396 |
* @return true if this ticket had been forwarded or was issued based on |
|
397 |
* authentication involving a forwarded ticket-granting ticket, |
|
398 |
* false otherwise. |
|
399 |
*/ |
|
400 |
public final boolean isForwarded() { |
|
401 |
return flags[FORWARDED_TICKET_FLAG]; |
|
402 |
} |
|
403 |
||
404 |
/** |
|
405 |
* Determines if this ticket is proxiable. |
|
406 |
* |
|
407 |
* @return true if this ticket is proxiable, false if not. |
|
408 |
*/ |
|
409 |
public final boolean isProxiable() { |
|
410 |
return flags[PROXIABLE_TICKET_FLAG]; |
|
411 |
} |
|
412 |
||
413 |
/** |
|
414 |
* Determines is this ticket is a proxy-ticket. |
|
415 |
* |
|
416 |
* @return true if this ticket is a proxy-ticket, false if not. |
|
417 |
*/ |
|
418 |
public final boolean isProxy() { |
|
419 |
return flags[PROXY_TICKET_FLAG]; |
|
420 |
} |
|
421 |
||
422 |
||
423 |
/** |
|
424 |
* Determines is this ticket is post-dated. |
|
425 |
* |
|
426 |
* @return true if this ticket is post-dated, false if not. |
|
427 |
*/ |
|
428 |
public final boolean isPostdated() { |
|
429 |
return flags[POSTDATED_TICKET_FLAG]; |
|
430 |
} |
|
431 |
||
432 |
/** |
|
433 |
* Determines is this ticket is renewable. If so, the {@link #refresh() |
|
434 |
* refresh} method can be called, assuming the validity period for |
|
435 |
* renewing is not already over. |
|
436 |
* |
|
437 |
* @return true if this ticket is renewable, false if not. |
|
438 |
*/ |
|
439 |
public final boolean isRenewable() { |
|
440 |
return flags[RENEWABLE_TICKET_FLAG]; |
|
441 |
} |
|
442 |
||
443 |
/** |
|
444 |
* Determines if this ticket was issued using the Kerberos AS-Exchange |
|
445 |
* protocol, and not issued based on some ticket-granting ticket. |
|
446 |
* |
|
447 |
* @return true if this ticket was issued using the Kerberos AS-Exchange |
|
448 |
* protocol, false if not. |
|
449 |
*/ |
|
450 |
public final boolean isInitial() { |
|
451 |
return flags[INITIAL_TICKET_FLAG]; |
|
452 |
} |
|
453 |
||
454 |
/** |
|
455 |
* Returns the flags associated with this ticket. Each element in the |
|
456 |
* returned array indicates the value for the corresponding bit in the |
|
457 |
* ASN.1 BitString that represents the ticket flags. |
|
458 |
* |
|
459 |
* @return the flags associated with this ticket. |
|
460 |
*/ |
|
461 |
public final boolean[] getFlags() { |
|
51 | 462 |
return (flags == null? null: flags.clone()); |
2 | 463 |
} |
464 |
||
465 |
/** |
|
466 |
* Returns the time that the client was authenticated. |
|
467 |
* |
|
468 |
* @return the time that the client was authenticated |
|
469 |
* or null if not set. |
|
470 |
*/ |
|
471 |
public final java.util.Date getAuthTime() { |
|
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
472 |
return (authTime == null) ? null : (Date)authTime.clone(); |
2 | 473 |
} |
474 |
||
475 |
/** |
|
476 |
* Returns the start time for this ticket's validity period. |
|
477 |
* |
|
478 |
* @return the start time for this ticket's validity period |
|
479 |
* or null if not set. |
|
480 |
*/ |
|
481 |
public final java.util.Date getStartTime() { |
|
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
482 |
return (startTime == null) ? null : (Date)startTime.clone(); |
2 | 483 |
} |
484 |
||
485 |
/** |
|
486 |
* Returns the expiration time for this ticket's validity period. |
|
487 |
* |
|
488 |
* @return the expiration time for this ticket's validity period. |
|
489 |
*/ |
|
490 |
public final java.util.Date getEndTime() { |
|
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
491 |
return (Date) endTime.clone(); |
2 | 492 |
} |
493 |
||
494 |
/** |
|
495 |
* Returns the latest expiration time for this ticket, including all |
|
496 |
* renewals. This will return a null value for non-renewable tickets. |
|
497 |
* |
|
498 |
* @return the latest expiration time for this ticket. |
|
499 |
*/ |
|
500 |
public final java.util.Date getRenewTill() { |
|
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
501 |
return (renewTill == null) ? null: (Date)renewTill.clone(); |
2 | 502 |
} |
503 |
||
504 |
/** |
|
505 |
* Returns a list of addresses from where the ticket can be used. |
|
506 |
* |
|
507 |
* @return ths list of addresses or null, if the field was not |
|
508 |
* provided. |
|
509 |
*/ |
|
510 |
public final java.net.InetAddress[] getClientAddresses() { |
|
51 | 511 |
return (clientAddresses == null) ? null: clientAddresses.clone(); |
2 | 512 |
} |
513 |
||
514 |
/** |
|
515 |
* Returns an ASN.1 encoding of the entire ticket. |
|
516 |
* |
|
517 |
* @return an ASN.1 encoding of the entire ticket. |
|
518 |
*/ |
|
519 |
public final byte[] getEncoded() { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
520 |
if (destroyed) { |
2 | 521 |
throw new IllegalStateException("This ticket is no longer valid"); |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
522 |
} |
51 | 523 |
return asn1Encoding.clone(); |
2 | 524 |
} |
525 |
||
526 |
/** Determines if this ticket is still current. */ |
|
527 |
public boolean isCurrent() { |
|
528 |
return (System.currentTimeMillis() <= getEndTime().getTime()); |
|
529 |
} |
|
530 |
||
531 |
/** |
|
532 |
* Extends the validity period of this ticket. The ticket will contain |
|
533 |
* a new session key if the refresh operation succeeds. The refresh |
|
534 |
* operation will fail if the ticket is not renewable or the latest |
|
535 |
* allowable renew time has passed. Any other error returned by the |
|
536 |
* KDC will also cause this method to fail. |
|
537 |
* |
|
28059
e576535359cc
8067377: My hobby: caning, then then canning, the the can-can
martin
parents:
27771
diff
changeset
|
538 |
* Note: This method is not synchronized with the accessor |
2 | 539 |
* methods of this object. Hence callers need to be aware of multiple |
540 |
* threads that might access this and try to renew it at the same |
|
541 |
* time. |
|
542 |
* |
|
543 |
* @throws RefreshFailedException if the ticket is not renewable, or |
|
544 |
* the latest allowable renew time has passed, or the KDC returns some |
|
545 |
* error. |
|
546 |
* |
|
547 |
* @see #isRenewable() |
|
548 |
* @see #getRenewTill() |
|
549 |
*/ |
|
550 |
public void refresh() throws RefreshFailedException { |
|
551 |
||
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
552 |
if (destroyed) { |
2 | 553 |
throw new RefreshFailedException("A destroyed ticket " |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
554 |
+ "cannot be renewd."); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
555 |
} |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
556 |
if (!isRenewable()) { |
2 | 557 |
throw new RefreshFailedException("This ticket is not renewable"); |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
558 |
} |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
559 |
if (System.currentTimeMillis() > getRenewTill().getTime()) { |
2 | 560 |
throw new RefreshFailedException("This ticket is past " |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
561 |
+ "its last renewal time."); |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
562 |
} |
2 | 563 |
Throwable e = null; |
564 |
sun.security.krb5.Credentials krb5Creds = null; |
|
565 |
||
566 |
try { |
|
567 |
krb5Creds = new sun.security.krb5.Credentials(asn1Encoding, |
|
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
568 |
client.getName(), |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
569 |
server.getName(), |
2 | 570 |
sessionKey.getEncoded(), |
571 |
sessionKey.getKeyType(), |
|
572 |
flags, |
|
573 |
authTime, |
|
574 |
startTime, |
|
575 |
endTime, |
|
576 |
renewTill, |
|
577 |
clientAddresses); |
|
578 |
krb5Creds = krb5Creds.renew(); |
|
579 |
} catch (sun.security.krb5.KrbException krbException) { |
|
580 |
e = krbException; |
|
581 |
} catch (java.io.IOException ioException) { |
|
582 |
e = ioException; |
|
583 |
} |
|
584 |
||
585 |
if (e != null) { |
|
586 |
RefreshFailedException rfException |
|
587 |
= new RefreshFailedException("Failed to renew Kerberos Ticket " |
|
588 |
+ "for client " + client |
|
589 |
+ " and server " + server |
|
590 |
+ " - " + e.getMessage()); |
|
591 |
rfException.initCause(e); |
|
592 |
throw rfException; |
|
593 |
} |
|
594 |
||
595 |
/* |
|
596 |
* In case multiple threads try to refresh it at the same time. |
|
597 |
*/ |
|
598 |
synchronized (this) { |
|
599 |
try { |
|
600 |
this.destroy(); |
|
601 |
} catch (DestroyFailedException dfException) { |
|
602 |
// Squelch it since we don't care about the old ticket. |
|
603 |
} |
|
604 |
init(krb5Creds.getEncoded(), |
|
605 |
new KerberosPrincipal(krb5Creds.getClient().getName()), |
|
606 |
new KerberosPrincipal(krb5Creds.getServer().getName(), |
|
607 |
KerberosPrincipal.KRB_NT_SRV_INST), |
|
608 |
krb5Creds.getSessionKey().getBytes(), |
|
609 |
krb5Creds.getSessionKey().getEType(), |
|
610 |
krb5Creds.getFlags(), |
|
611 |
krb5Creds.getAuthTime(), |
|
612 |
krb5Creds.getStartTime(), |
|
613 |
krb5Creds.getEndTime(), |
|
614 |
krb5Creds.getRenewTill(), |
|
615 |
krb5Creds.getClientAddresses()); |
|
616 |
destroyed = false; |
|
617 |
} |
|
618 |
} |
|
619 |
||
620 |
/** |
|
621 |
* Destroys the ticket and destroys any sensitive information stored in |
|
622 |
* it. |
|
623 |
*/ |
|
624 |
public void destroy() throws DestroyFailedException { |
|
625 |
if (!destroyed) { |
|
626 |
Arrays.fill(asn1Encoding, (byte) 0); |
|
627 |
client = null; |
|
628 |
server = null; |
|
629 |
sessionKey.destroy(); |
|
630 |
flags = null; |
|
631 |
authTime = null; |
|
632 |
startTime = null; |
|
633 |
endTime = null; |
|
634 |
renewTill = null; |
|
635 |
clientAddresses = null; |
|
636 |
destroyed = true; |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
/** |
|
641 |
* Determines if this ticket has been destroyed. |
|
642 |
*/ |
|
643 |
public boolean isDestroyed() { |
|
644 |
return destroyed; |
|
645 |
} |
|
646 |
||
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
647 |
/** |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
648 |
* Returns an informative textual representation of this {@code KerberosTicket}. |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
649 |
* |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
650 |
* @return an informative textual representation of this {@code KerberosTicket}. |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
651 |
*/ |
2 | 652 |
public String toString() { |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
653 |
if (destroyed) { |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
654 |
return "Destroyed KerberosTicket"; |
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
655 |
} |
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
18830
diff
changeset
|
656 |
StringBuilder caddrString = new StringBuilder(); |
2 | 657 |
if (clientAddresses != null) { |
658 |
for (int i = 0; i < clientAddresses.length; i++) { |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
18830
diff
changeset
|
659 |
caddrString.append("clientAddresses[" + i + "] = " + |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
18830
diff
changeset
|
660 |
clientAddresses[i].toString()); |
2 | 661 |
} |
662 |
} |
|
663 |
return ("Ticket (hex) = " + "\n" + |
|
664 |
(new HexDumpEncoder()).encodeBuffer(asn1Encoding) + "\n" + |
|
665 |
"Client Principal = " + client.toString() + "\n" + |
|
666 |
"Server Principal = " + server.toString() + "\n" + |
|
667 |
"Session Key = " + sessionKey.toString() + "\n" + |
|
668 |
"Forwardable Ticket " + flags[FORWARDABLE_TICKET_FLAG] + "\n" + |
|
669 |
"Forwarded Ticket " + flags[FORWARDED_TICKET_FLAG] + "\n" + |
|
670 |
"Proxiable Ticket " + flags[PROXIABLE_TICKET_FLAG] + "\n" + |
|
671 |
"Proxy Ticket " + flags[PROXY_TICKET_FLAG] + "\n" + |
|
672 |
"Postdated Ticket " + flags[POSTDATED_TICKET_FLAG] + "\n" + |
|
673 |
"Renewable Ticket " + flags[RENEWABLE_TICKET_FLAG] + "\n" + |
|
674 |
"Initial Ticket " + flags[RENEWABLE_TICKET_FLAG] + "\n" + |
|
675 |
"Auth Time = " + String.valueOf(authTime) + "\n" + |
|
676 |
"Start Time = " + String.valueOf(startTime) + "\n" + |
|
677 |
"End Time = " + endTime.toString() + "\n" + |
|
678 |
"Renew Till = " + String.valueOf(renewTill) + "\n" + |
|
679 |
"Client Addresses " + |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
18830
diff
changeset
|
680 |
(clientAddresses == null ? " Null " : caddrString.toString() + |
2 | 681 |
"\n")); |
682 |
} |
|
683 |
||
684 |
/** |
|
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
685 |
* Returns a hash code for this {@code KerberosTicket}. |
2 | 686 |
* |
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
687 |
* @return a hash code for this {@code KerberosTicket}. |
2 | 688 |
* @since 1.6 |
689 |
*/ |
|
690 |
public int hashCode() { |
|
691 |
int result = 17; |
|
692 |
if (isDestroyed()) { |
|
693 |
return result; |
|
694 |
} |
|
695 |
result = result * 37 + Arrays.hashCode(getEncoded()); |
|
696 |
result = result * 37 + endTime.hashCode(); |
|
697 |
result = result * 37 + client.hashCode(); |
|
698 |
result = result * 37 + server.hashCode(); |
|
699 |
result = result * 37 + sessionKey.hashCode(); |
|
700 |
||
701 |
// authTime may be null |
|
702 |
if (authTime != null) { |
|
703 |
result = result * 37 + authTime.hashCode(); |
|
704 |
} |
|
705 |
||
706 |
// startTime may be null |
|
707 |
if (startTime != null) { |
|
708 |
result = result * 37 + startTime.hashCode(); |
|
709 |
} |
|
710 |
||
711 |
// renewTill may be null |
|
712 |
if (renewTill != null) { |
|
713 |
result = result * 37 + renewTill.hashCode(); |
|
714 |
} |
|
715 |
||
716 |
// clientAddress may be null, the array's hashCode is 0 |
|
717 |
result = result * 37 + Arrays.hashCode(clientAddresses); |
|
718 |
return result * 37 + Arrays.hashCode(flags); |
|
719 |
} |
|
720 |
||
721 |
/** |
|
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
722 |
* Compares the specified object with this {@code KerberosTicket} for equality. |
2 | 723 |
* Returns true if the given object is also a |
18830 | 724 |
* {@code KerberosTicket} and the two |
725 |
* {@code KerberosTicket} instances are equivalent. |
|
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
726 |
* A destroyed {@code KerberosTicket} object is only equal to itself. |
2 | 727 |
* |
27771
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
728 |
* @param other the object to compare to |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
729 |
* @return true if the specified object is equal to this {@code KerberosTicket}, |
360714d431ab
8061253: Spec cleanup for some security-related classes
weijun
parents:
25859
diff
changeset
|
730 |
* false otherwise. |
2 | 731 |
* @since 1.6 |
732 |
*/ |
|
733 |
public boolean equals(Object other) { |
|
734 |
||
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
735 |
if (other == this) { |
2 | 736 |
return true; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
737 |
} |
2 | 738 |
|
739 |
if (! (other instanceof KerberosTicket)) { |
|
740 |
return false; |
|
741 |
} |
|
742 |
||
743 |
KerberosTicket otherTicket = ((KerberosTicket) other); |
|
744 |
if (isDestroyed() || otherTicket.isDestroyed()) { |
|
745 |
return false; |
|
746 |
} |
|
747 |
||
748 |
if (!Arrays.equals(getEncoded(), otherTicket.getEncoded()) || |
|
749 |
!endTime.equals(otherTicket.getEndTime()) || |
|
750 |
!server.equals(otherTicket.getServer()) || |
|
751 |
!client.equals(otherTicket.getClient()) || |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
752 |
!sessionKey.equals(otherTicket.sessionKey) || |
2 | 753 |
!Arrays.equals(clientAddresses, otherTicket.getClientAddresses()) || |
754 |
!Arrays.equals(flags, otherTicket.getFlags())) { |
|
755 |
return false; |
|
756 |
} |
|
757 |
||
758 |
// authTime may be null |
|
759 |
if (authTime == null) { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
760 |
if (otherTicket.getAuthTime() != null) { |
2 | 761 |
return false; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
762 |
} |
2 | 763 |
} else { |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
764 |
if (!authTime.equals(otherTicket.getAuthTime())) { |
2 | 765 |
return false; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
766 |
} |
2 | 767 |
} |
768 |
||
769 |
// startTime may be null |
|
770 |
if (startTime == null) { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
771 |
if (otherTicket.getStartTime() != null) { |
2 | 772 |
return false; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
773 |
} |
2 | 774 |
} else { |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
775 |
if (!startTime.equals(otherTicket.getStartTime())) { |
2 | 776 |
return false; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
777 |
} |
2 | 778 |
} |
779 |
||
780 |
if (renewTill == null) { |
|
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
781 |
if (otherTicket.getRenewTill() != null) { |
2 | 782 |
return false; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
783 |
} |
2 | 784 |
} else { |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
785 |
if (!renewTill.equals(otherTicket.getRenewTill())) { |
2 | 786 |
return false; |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
787 |
} |
2 | 788 |
} |
789 |
||
790 |
return true; |
|
791 |
} |
|
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
792 |
|
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
793 |
private void readObject(ObjectInputStream s) |
25661
929c829a8400
8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents:
24969
diff
changeset
|
794 |
throws IOException, ClassNotFoundException { |
488
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
795 |
s.defaultReadObject(); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
796 |
if (sessionKey == null) { |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
797 |
throw new InvalidObjectException("Session key cannot be null"); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
798 |
} |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
799 |
try { |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
800 |
init(asn1Encoding, client, server, sessionKey, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
801 |
flags, authTime, startTime, endTime, |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
802 |
renewTill, clientAddresses); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
803 |
} catch (IllegalArgumentException iae) { |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
804 |
throw (InvalidObjectException) |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
805 |
new InvalidObjectException(iae.getMessage()).initCause(iae); |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
806 |
} |
5e84e13e8892
6659990: KerberosTicket.getEndTime does not copy date (findbugs)
valeriep
parents:
51
diff
changeset
|
807 |
} |
2 | 808 |
} |