Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/auto/CleanState.java
41152 views
1
/*
2
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
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
*
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.
22
*/
23
24
/*
25
* @test
26
* @bug 6716534 8194486
27
* @summary Krb5LoginModule has not cleaned temp info between authentication attempts
28
* @library /test/lib
29
* @compile -XDignore.symbol.file CleanState.java
30
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
31
* @run main/othervm -Djdk.net.hosts.file=TestHosts CleanState
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
56
Map<String,String> map = new HashMap<>();
57
map.put("useTicketCache", "false");
58
map.put("doNotPrompt", "false");
59
map.put("tryFirstPass", "true");
60
Map<String,Object> shared = new HashMap<>();
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
}
80
81