author | ssahoo |
Thu, 25 Jan 2018 05:57:22 -0800 | |
changeset 48668 | 2da4a52715d8 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1454 | 1 |
/* |
48668 | 2 |
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
1454 | 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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1454 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
48668 | 26 |
* @bug 6716534 8194486 |
27 |
* @summary Krb5LoginModule has not cleaned temp info between authentication attempts |
|
28 |
* @library /test/lib |
|
15006 | 29 |
* @compile -XDignore.symbol.file CleanState.java |
48668 | 30 |
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts |
31 |
* @run main/othervm -Djdk.net.hosts.file=TestHosts CleanState |
|
1454 | 32 |
*/ |
33 |
import com.sun.security.auth.module.Krb5LoginModule; |
|
34 |
import java.util.HashMap; |
|
35 |
import java.util.Map; |
|
36 |
import javax.security.auth.Subject; |
|
37 |
import javax.security.auth.callback.Callback; |
|
38 |
import javax.security.auth.callback.CallbackHandler; |
|
39 |
import javax.security.auth.callback.NameCallback; |
|
40 |
import javax.security.auth.callback.PasswordCallback; |
|
41 |
||
42 |
public class CleanState { |
|
43 |
public static void main(String[] args) throws Exception { |
|
44 |
CleanState x = new CleanState(); |
|
45 |
new OneKDC(null); |
|
46 |
x.go(); |
|
47 |
} |
|
48 |
||
49 |
void go() throws Exception { |
|
50 |
Krb5LoginModule krb5 = new Krb5LoginModule(); |
|
51 |
||
52 |
final String name = OneKDC.USER; |
|
53 |
final char[] password = OneKDC.PASS; |
|
54 |
char[] badpassword = "hellokitty".toCharArray(); |
|
55 |
||
7977
f47f211cd627
7008713: diamond conversion of kerberos5 and security tools
smarks
parents:
5506
diff
changeset
|
56 |
Map<String,String> map = new HashMap<>(); |
1454 | 57 |
map.put("useTicketCache", "false"); |
58 |
map.put("doNotPrompt", "false"); |
|
59 |
map.put("tryFirstPass", "true"); |
|
7977
f47f211cd627
7008713: diamond conversion of kerberos5 and security tools
smarks
parents:
5506
diff
changeset
|
60 |
Map<String,Object> shared = new HashMap<>(); |
1454 | 61 |
shared.put("javax.security.auth.login.name", name); |
62 |
shared.put("javax.security.auth.login.password", badpassword); |
|
63 |
||
64 |
krb5.initialize(new Subject(), new CallbackHandler() { |
|
65 |
@Override |
|
66 |
public void handle(Callback[] callbacks) { |
|
67 |
for(Callback callback: callbacks) { |
|
68 |
if (callback instanceof NameCallback) { |
|
69 |
((NameCallback)callback).setName(name); |
|
70 |
} |
|
71 |
if (callback instanceof PasswordCallback) { |
|
72 |
((PasswordCallback)callback).setPassword(password); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
}, shared, map); |
|
77 |
krb5.login(); |
|
78 |
} |
|
79 |
} |