author | weijun |
Fri, 19 Apr 2019 10:22:20 +0800 | |
changeset 58611 | 53ddf218eddd |
parent 57487 | 643978a35f6e |
child 58638 | 7be56b2ac50d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
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 |
package sun.security.jgss.krb5; |
|
27 |
||
28 |
import org.ietf.jgss.*; |
|
2942
37d9baeb7518
6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
2
diff
changeset
|
29 |
import sun.security.jgss.GSSCaller; |
2 | 30 |
import sun.security.jgss.spi.*; |
31 |
import sun.security.krb5.*; |
|
25662 | 32 |
import javax.security.auth.kerberos.KerberosTicket; |
33 |
import javax.security.auth.kerberos.KerberosPrincipal; |
|
2 | 34 |
import java.net.InetAddress; |
35 |
import java.io.IOException; |
|
36 |
import java.util.Date; |
|
37 |
import java.security.AccessController; |
|
38 |
import java.security.AccessControlContext; |
|
39 |
import java.security.PrivilegedExceptionAction; |
|
40 |
import java.security.PrivilegedActionException; |
|
41 |
||
42 |
/** |
|
43 |
* Implements the krb5 initiator credential element. |
|
44 |
* |
|
45 |
* @author Mayank Upadhyay |
|
46 |
* @author Ram Marti |
|
47 |
* @since 1.4 |
|
48 |
*/ |
|
49 |
||
50 |
public class Krb5InitCredential |
|
51 |
extends KerberosTicket |
|
52 |
implements Krb5CredElement { |
|
53 |
||
54 |
private static final long serialVersionUID = 7723415700837898232L; |
|
55 |
||
56 |
private Krb5NameElement name; |
|
57 |
private Credentials krb5Credentials; |
|
58611 | 58 |
public KerberosTicket proxyTicket; |
2 | 59 |
|
60 |
private Krb5InitCredential(Krb5NameElement name, |
|
61 |
byte[] asn1Encoding, |
|
62 |
KerberosPrincipal client, |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
63 |
KerberosPrincipal clientAlias, |
2 | 64 |
KerberosPrincipal server, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
65 |
KerberosPrincipal serverAlias, |
2 | 66 |
byte[] sessionKey, |
67 |
int keyType, |
|
68 |
boolean[] flags, |
|
69 |
Date authTime, |
|
70 |
Date startTime, |
|
71 |
Date endTime, |
|
72 |
Date renewTill, |
|
73 |
InetAddress[] clientAddresses) |
|
74 |
throws GSSException { |
|
75 |
super(asn1Encoding, |
|
76 |
client, |
|
77 |
server, |
|
78 |
sessionKey, |
|
79 |
keyType, |
|
80 |
flags, |
|
81 |
authTime, |
|
82 |
startTime, |
|
83 |
endTime, |
|
84 |
renewTill, |
|
85 |
clientAddresses); |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
86 |
KerberosSecrets.getJavaxSecurityAuthKerberosAccess() |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
87 |
.kerberosTicketSetClientAlias(this, clientAlias); |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
88 |
KerberosSecrets.getJavaxSecurityAuthKerberosAccess() |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
89 |
.kerberosTicketSetServerAlias(this, serverAlias); |
2 | 90 |
this.name = name; |
91 |
||
92 |
try { |
|
93 |
// Cache this for later use by the sun.security.krb5 package. |
|
94 |
krb5Credentials = new Credentials(asn1Encoding, |
|
95 |
client.getName(), |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
96 |
(clientAlias != null ? |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
97 |
clientAlias.getName() : null), |
2 | 98 |
server.getName(), |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
99 |
(serverAlias != null ? |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
100 |
serverAlias.getName() : null), |
2 | 101 |
sessionKey, |
102 |
keyType, |
|
103 |
flags, |
|
104 |
authTime, |
|
105 |
startTime, |
|
106 |
endTime, |
|
107 |
renewTill, |
|
108 |
clientAddresses); |
|
109 |
} catch (KrbException e) { |
|
110 |
throw new GSSException(GSSException.NO_CRED, -1, |
|
111 |
e.getMessage()); |
|
112 |
} catch (IOException e) { |
|
113 |
throw new GSSException(GSSException.NO_CRED, -1, |
|
114 |
e.getMessage()); |
|
115 |
} |
|
116 |
||
117 |
} |
|
118 |
||
119 |
private Krb5InitCredential(Krb5NameElement name, |
|
120 |
Credentials delegatedCred, |
|
121 |
byte[] asn1Encoding, |
|
122 |
KerberosPrincipal client, |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
123 |
KerberosPrincipal clientAlias, |
2 | 124 |
KerberosPrincipal server, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
125 |
KerberosPrincipal serverAlias, |
2 | 126 |
byte[] sessionKey, |
127 |
int keyType, |
|
128 |
boolean[] flags, |
|
129 |
Date authTime, |
|
130 |
Date startTime, |
|
131 |
Date endTime, |
|
132 |
Date renewTill, |
|
133 |
InetAddress[] clientAddresses) |
|
134 |
throws GSSException { |
|
135 |
super(asn1Encoding, |
|
136 |
client, |
|
137 |
server, |
|
138 |
sessionKey, |
|
139 |
keyType, |
|
140 |
flags, |
|
141 |
authTime, |
|
142 |
startTime, |
|
143 |
endTime, |
|
144 |
renewTill, |
|
145 |
clientAddresses); |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
146 |
KerberosSecrets.getJavaxSecurityAuthKerberosAccess() |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
147 |
.kerberosTicketSetClientAlias(this, clientAlias); |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
148 |
KerberosSecrets.getJavaxSecurityAuthKerberosAccess() |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
149 |
.kerberosTicketSetServerAlias(this, serverAlias); |
2 | 150 |
this.name = name; |
151 |
// A delegated cred does not have all fields set. So do not try to |
|
152 |
// creat new Credentials out of the delegatedCred. |
|
153 |
this.krb5Credentials = delegatedCred; |
|
154 |
} |
|
155 |
||
2942
37d9baeb7518
6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
2
diff
changeset
|
156 |
static Krb5InitCredential getInstance(GSSCaller caller, Krb5NameElement name, |
2 | 157 |
int initLifetime) |
158 |
throws GSSException { |
|
159 |
||
160 |
KerberosTicket tgt = getTgt(caller, name, initLifetime); |
|
161 |
if (tgt == null) |
|
162 |
throw new GSSException(GSSException.NO_CRED, -1, |
|
163 |
"Failed to find any Kerberos tgt"); |
|
164 |
||
165 |
if (name == null) { |
|
166 |
String fullName = tgt.getClient().getName(); |
|
167 |
name = Krb5NameElement.getInstance(fullName, |
|
168 |
Krb5MechFactory.NT_GSS_KRB5_PRINCIPAL); |
|
169 |
} |
|
170 |
||
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
171 |
KerberosPrincipal clientAlias = KerberosSecrets |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
172 |
.getJavaxSecurityAuthKerberosAccess() |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
173 |
.kerberosTicketGetClientAlias(tgt); |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
174 |
KerberosPrincipal serverAlias = KerberosSecrets |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
175 |
.getJavaxSecurityAuthKerberosAccess() |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
176 |
.kerberosTicketGetServerAlias(tgt); |
58611 | 177 |
Krb5InitCredential result = new Krb5InitCredential(name, |
2 | 178 |
tgt.getEncoded(), |
179 |
tgt.getClient(), |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
180 |
clientAlias, |
2 | 181 |
tgt.getServer(), |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
182 |
serverAlias, |
2 | 183 |
tgt.getSessionKey().getEncoded(), |
184 |
tgt.getSessionKeyType(), |
|
185 |
tgt.getFlags(), |
|
186 |
tgt.getAuthTime(), |
|
187 |
tgt.getStartTime(), |
|
188 |
tgt.getEndTime(), |
|
189 |
tgt.getRenewTill(), |
|
190 |
tgt.getClientAddresses()); |
|
58611 | 191 |
result.proxyTicket = KerberosSecrets.getJavaxSecurityAuthKerberosAccess(). |
192 |
kerberosTicketGetProxy(tgt); |
|
193 |
return result; |
|
2 | 194 |
} |
195 |
||
196 |
static Krb5InitCredential getInstance(Krb5NameElement name, |
|
197 |
Credentials delegatedCred) |
|
198 |
throws GSSException { |
|
199 |
||
200 |
EncryptionKey sessionKey = delegatedCred.getSessionKey(); |
|
201 |
||
202 |
/* |
|
203 |
* all of the following data is optional in a KRB-CRED |
|
204 |
* messages. This check for each field. |
|
205 |
*/ |
|
206 |
||
207 |
PrincipalName cPrinc = delegatedCred.getClient(); |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
208 |
PrincipalName cAPrinc = delegatedCred.getClientAlias(); |
2 | 209 |
PrincipalName sPrinc = delegatedCred.getServer(); |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
210 |
PrincipalName sAPrinc = delegatedCred.getServerAlias(); |
2 | 211 |
|
212 |
KerberosPrincipal client = null; |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
213 |
KerberosPrincipal clientAlias = null; |
2 | 214 |
KerberosPrincipal server = null; |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
215 |
KerberosPrincipal serverAlias = null; |
2 | 216 |
|
217 |
Krb5NameElement credName = null; |
|
218 |
||
219 |
if (cPrinc != null) { |
|
220 |
String fullName = cPrinc.getName(); |
|
221 |
credName = Krb5NameElement.getInstance(fullName, |
|
222 |
Krb5MechFactory.NT_GSS_KRB5_PRINCIPAL); |
|
223 |
client = new KerberosPrincipal(fullName); |
|
224 |
} |
|
225 |
||
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
226 |
if (cAPrinc != null) { |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
227 |
clientAlias = new KerberosPrincipal(cAPrinc.getName()); |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
228 |
} |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
229 |
|
2 | 230 |
// XXX Compare name to credName |
231 |
||
232 |
if (sPrinc != null) { |
|
233 |
server = |
|
234 |
new KerberosPrincipal(sPrinc.getName(), |
|
235 |
KerberosPrincipal.KRB_NT_SRV_INST); |
|
236 |
} |
|
237 |
||
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
238 |
if (sAPrinc != null) { |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
239 |
serverAlias = new KerberosPrincipal(sAPrinc.getName()); |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
240 |
} |
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
241 |
|
2 | 242 |
return new Krb5InitCredential(credName, |
243 |
delegatedCred, |
|
244 |
delegatedCred.getEncoded(), |
|
245 |
client, |
|
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
246 |
clientAlias, |
2 | 247 |
server, |
57487
643978a35f6e
8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents:
50750
diff
changeset
|
248 |
serverAlias, |
2 | 249 |
sessionKey.getBytes(), |
250 |
sessionKey.getEType(), |
|
251 |
delegatedCred.getFlags(), |
|
252 |
delegatedCred.getAuthTime(), |
|
253 |
delegatedCred.getStartTime(), |
|
254 |
delegatedCred.getEndTime(), |
|
255 |
delegatedCred.getRenewTill(), |
|
256 |
delegatedCred.getClientAddresses()); |
|
257 |
} |
|
258 |
||
259 |
/** |
|
260 |
* Returns the principal name for this credential. The name |
|
261 |
* is in mechanism specific format. |
|
262 |
* |
|
263 |
* @return GSSNameSpi representing principal name of this credential |
|
264 |
* @exception GSSException may be thrown |
|
265 |
*/ |
|
266 |
public final GSSNameSpi getName() throws GSSException { |
|
267 |
return name; |
|
268 |
} |
|
269 |
||
270 |
/** |
|
271 |
* Returns the init lifetime remaining. |
|
272 |
* |
|
273 |
* @return the init lifetime remaining in seconds |
|
274 |
* @exception GSSException may be thrown |
|
275 |
*/ |
|
276 |
public int getInitLifetime() throws GSSException { |
|
40255
0222e4232e7c
8163104: Unexpected NPE still possible on some Kerberos ticket calls
coffeys
parents:
25859
diff
changeset
|
277 |
Date d = getEndTime(); |
0222e4232e7c
8163104: Unexpected NPE still possible on some Kerberos ticket calls
coffeys
parents:
25859
diff
changeset
|
278 |
if (d == null) { |
0222e4232e7c
8163104: Unexpected NPE still possible on some Kerberos ticket calls
coffeys
parents:
25859
diff
changeset
|
279 |
return 0; |
0222e4232e7c
8163104: Unexpected NPE still possible on some Kerberos ticket calls
coffeys
parents:
25859
diff
changeset
|
280 |
} |
50750
45511dcfed3f
8187218: GSSCredential.getRemainingLifetime() returns negative value for TTL > 24 days.
pkoppula
parents:
47216
diff
changeset
|
281 |
long retVal = d.getTime() - System.currentTimeMillis(); |
45511dcfed3f
8187218: GSSCredential.getRemainingLifetime() returns negative value for TTL > 24 days.
pkoppula
parents:
47216
diff
changeset
|
282 |
return (int)(retVal/1000); |
2 | 283 |
} |
284 |
||
285 |
/** |
|
286 |
* Returns the accept lifetime remaining. |
|
287 |
* |
|
288 |
* @return the accept lifetime remaining in seconds |
|
289 |
* @exception GSSException may be thrown |
|
290 |
*/ |
|
291 |
public int getAcceptLifetime() throws GSSException { |
|
292 |
return 0; |
|
293 |
} |
|
294 |
||
295 |
public boolean isInitiatorCredential() throws GSSException { |
|
296 |
return true; |
|
297 |
} |
|
298 |
||
299 |
public boolean isAcceptorCredential() throws GSSException { |
|
300 |
return false; |
|
301 |
} |
|
302 |
||
303 |
/** |
|
304 |
* Returns the oid representing the underlying credential |
|
305 |
* mechanism oid. |
|
306 |
* |
|
307 |
* @return the Oid for this credential mechanism |
|
308 |
* @exception GSSException may be thrown |
|
309 |
*/ |
|
310 |
public final Oid getMechanism() { |
|
311 |
return Krb5MechFactory.GSS_KRB5_MECH_OID; |
|
312 |
} |
|
313 |
||
314 |
public final java.security.Provider getProvider() { |
|
315 |
return Krb5MechFactory.PROVIDER; |
|
316 |
} |
|
317 |
||
318 |
||
319 |
/** |
|
320 |
* Returns a sun.security.krb5.Credentials instance so that it maybe |
|
321 |
* used in that package for th Kerberos protocol. |
|
322 |
*/ |
|
323 |
Credentials getKrb5Credentials() { |
|
324 |
return krb5Credentials; |
|
325 |
} |
|
326 |
||
327 |
/* |
|
328 |
* XXX Call to this.refresh() should refresh the locally cached copy |
|
329 |
* of krb5Credentials also. |
|
330 |
*/ |
|
331 |
||
332 |
/** |
|
333 |
* Called to invalidate this credential element. |
|
334 |
*/ |
|
335 |
public void dispose() throws GSSException { |
|
336 |
try { |
|
337 |
destroy(); |
|
338 |
} catch (javax.security.auth.DestroyFailedException e) { |
|
339 |
GSSException gssException = |
|
340 |
new GSSException(GSSException.FAILURE, -1, |
|
341 |
"Could not destroy credentials - " + e.getMessage()); |
|
342 |
gssException.initCause(e); |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
// XXX call to this.destroy() should destroy the locally cached copy |
|
347 |
// of krb5Credentials and then call super.destroy(). |
|
348 |
||
2942
37d9baeb7518
6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
2
diff
changeset
|
349 |
private static KerberosTicket getTgt(GSSCaller caller, Krb5NameElement name, |
2 | 350 |
int initLifetime) |
351 |
throws GSSException { |
|
352 |
||
14413 | 353 |
final String clientPrincipal; |
2 | 354 |
|
355 |
/* |
|
356 |
* Find the TGT for the realm that the client is in. If the client |
|
357 |
* name is not available, then use the default realm. |
|
358 |
*/ |
|
359 |
if (name != null) { |
|
360 |
clientPrincipal = (name.getKrb5PrincipalName()).getName(); |
|
361 |
} else { |
|
362 |
clientPrincipal = null; |
|
363 |
} |
|
364 |
||
365 |
final AccessControlContext acc = AccessController.getContext(); |
|
366 |
||
367 |
try { |
|
2942
37d9baeb7518
6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
2
diff
changeset
|
368 |
final GSSCaller realCaller = (caller == GSSCaller.CALLER_UNKNOWN) |
37d9baeb7518
6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents:
2
diff
changeset
|
369 |
? GSSCaller.CALLER_INITIATE |
2 | 370 |
: caller; |
371 |
return AccessController.doPrivileged( |
|
372 |
new PrivilegedExceptionAction<KerberosTicket>() { |
|
373 |
public KerberosTicket run() throws Exception { |
|
14413 | 374 |
// It's OK to use null as serverPrincipal. TGT is almost |
375 |
// the first ticket for a principal and we use list. |
|
58611 | 376 |
return Krb5Util.getInitialTicket( |
2 | 377 |
realCaller, |
58611 | 378 |
clientPrincipal, acc); |
2 | 379 |
}}); |
380 |
} catch (PrivilegedActionException e) { |
|
381 |
GSSException ge = |
|
382 |
new GSSException(GSSException.NO_CRED, -1, |
|
383 |
"Attempt to obtain new INITIATE credentials failed!" + |
|
384 |
" (" + e.getMessage() + ")"); |
|
385 |
ge.initCause(e.getException()); |
|
386 |
throw ge; |
|
387 |
} |
|
388 |
} |
|
14413 | 389 |
|
390 |
@Override |
|
391 |
public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException { |
|
392 |
try { |
|
393 |
Krb5NameElement kname = (Krb5NameElement)name; |
|
394 |
Credentials newCred = Credentials.acquireS4U2selfCreds( |
|
395 |
kname.getKrb5PrincipalName(), krb5Credentials); |
|
396 |
return new Krb5ProxyCredential(this, kname, newCred.getTicket()); |
|
397 |
} catch (IOException | KrbException ke) { |
|
398 |
GSSException ge = |
|
399 |
new GSSException(GSSException.FAILURE, -1, |
|
400 |
"Attempt to obtain S4U2self credentials failed!"); |
|
401 |
ge.initCause(ke); |
|
402 |
throw ge; |
|
403 |
} |
|
404 |
} |
|
2 | 405 |
} |