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