1454
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2008, 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
|
|
26 |
* @bug 6716534
|
|
27 |
* @summary Krb5LoginModule has not cleaned temp info between authentication attempts
|
|
28 |
*/
|
|
29 |
import com.sun.security.auth.module.Krb5LoginModule;
|
|
30 |
import java.util.HashMap;
|
|
31 |
import java.util.Map;
|
|
32 |
import javax.security.auth.Subject;
|
|
33 |
import javax.security.auth.callback.Callback;
|
|
34 |
import javax.security.auth.callback.CallbackHandler;
|
|
35 |
import javax.security.auth.callback.NameCallback;
|
|
36 |
import javax.security.auth.callback.PasswordCallback;
|
|
37 |
|
|
38 |
public class CleanState {
|
|
39 |
public static void main(String[] args) throws Exception {
|
|
40 |
CleanState x = new CleanState();
|
|
41 |
new OneKDC(null);
|
|
42 |
x.go();
|
|
43 |
}
|
|
44 |
|
|
45 |
void go() throws Exception {
|
|
46 |
Krb5LoginModule krb5 = new Krb5LoginModule();
|
|
47 |
|
|
48 |
final String name = OneKDC.USER;
|
|
49 |
final char[] password = OneKDC.PASS;
|
|
50 |
char[] badpassword = "hellokitty".toCharArray();
|
|
51 |
|
|
52 |
Map<String,String> map = new HashMap<String,String>();
|
|
53 |
map.put("useTicketCache", "false");
|
|
54 |
map.put("doNotPrompt", "false");
|
|
55 |
map.put("tryFirstPass", "true");
|
|
56 |
Map<String,Object> shared = new HashMap<String,Object>();
|
|
57 |
shared.put("javax.security.auth.login.name", name);
|
|
58 |
shared.put("javax.security.auth.login.password", badpassword);
|
|
59 |
|
|
60 |
krb5.initialize(new Subject(), new CallbackHandler() {
|
|
61 |
@Override
|
|
62 |
public void handle(Callback[] callbacks) {
|
|
63 |
for(Callback callback: callbacks) {
|
|
64 |
if (callback instanceof NameCallback) {
|
|
65 |
((NameCallback)callback).setName(name);
|
|
66 |
}
|
|
67 |
if (callback instanceof PasswordCallback) {
|
|
68 |
((PasswordCallback)callback).setPassword(password);
|
|
69 |
}
|
|
70 |
}
|
|
71 |
}
|
|
72 |
}, shared, map);
|
|
73 |
krb5.login();
|
|
74 |
}
|
|
75 |
}
|