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