Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/auto/CleanState.java
38853 views
1
/*
2
* Copyright (c) 2008, 2013, 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
27
* @compile -XDignore.symbol.file CleanState.java
28
* @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock CleanState
29
* @summary Krb5LoginModule has not cleaned temp info between authentication attempts
30
*/
31
import com.sun.security.auth.module.Krb5LoginModule;
32
import java.util.HashMap;
33
import java.util.Map;
34
import javax.security.auth.Subject;
35
import javax.security.auth.callback.Callback;
36
import javax.security.auth.callback.CallbackHandler;
37
import javax.security.auth.callback.NameCallback;
38
import javax.security.auth.callback.PasswordCallback;
39
40
public class CleanState {
41
public static void main(String[] args) throws Exception {
42
CleanState x = new CleanState();
43
new OneKDC(null);
44
x.go();
45
}
46
47
void go() throws Exception {
48
Krb5LoginModule krb5 = new Krb5LoginModule();
49
50
final String name = OneKDC.USER;
51
final char[] password = OneKDC.PASS;
52
char[] badpassword = "hellokitty".toCharArray();
53
54
Map<String,String> map = new HashMap<>();
55
map.put("useTicketCache", "false");
56
map.put("doNotPrompt", "false");
57
map.put("tryFirstPass", "true");
58
Map<String,Object> shared = new HashMap<>();
59
shared.put("javax.security.auth.login.name", name);
60
shared.put("javax.security.auth.login.password", badpassword);
61
62
krb5.initialize(new Subject(), new CallbackHandler() {
63
@Override
64
public void handle(Callback[] callbacks) {
65
for(Callback callback: callbacks) {
66
if (callback instanceof NameCallback) {
67
((NameCallback)callback).setName(name);
68
}
69
if (callback instanceof PasswordCallback) {
70
((PasswordCallback)callback).setPassword(password);
71
}
72
}
73
}
74
}, shared, map);
75
krb5.login();
76
}
77
}
78
79