Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/krb5/auto/IgnoreChannelBinding.java
41152 views
1
/*
2
* Copyright (c) 2009, 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 6851973 8194486
27
* @summary ignore incoming channel binding if acceptor does not set one
28
* @library /test/lib
29
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
30
* @run main/othervm -Djdk.net.hosts.file=TestHosts IgnoreChannelBinding
31
*/
32
33
import java.net.InetAddress;
34
import org.ietf.jgss.ChannelBinding;
35
import org.ietf.jgss.GSSException;
36
import sun.security.jgss.GSSUtil;
37
38
public class IgnoreChannelBinding {
39
40
public static void main(String[] args)
41
throws Exception {
42
43
new OneKDC(null).writeJAASConf();
44
45
Context c = Context.fromJAAS("client");
46
Context s = Context.fromJAAS("server");
47
48
// All silent
49
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
50
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
51
Context.handshake(c, s);
52
53
// Initiator req, acceptor ignore
54
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
55
c.x().setChannelBinding(new ChannelBinding(
56
InetAddress.getByName("client.rabbit.hole"),
57
InetAddress.getByName("host.rabbit.hole"),
58
new byte[0]
59
));
60
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
61
Context.handshake(c, s);
62
63
// Both req, and match
64
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
65
c.x().setChannelBinding(new ChannelBinding(
66
InetAddress.getByName("client.rabbit.hole"),
67
InetAddress.getByName("host.rabbit.hole"),
68
new byte[0]
69
));
70
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
71
s.x().setChannelBinding(new ChannelBinding(
72
InetAddress.getByName("client.rabbit.hole"),
73
InetAddress.getByName("host.rabbit.hole"),
74
new byte[0]
75
));
76
Context.handshake(c, s);
77
78
// Both req, NOT match
79
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
80
c.x().setChannelBinding(new ChannelBinding(
81
InetAddress.getByName("client.rabbit.hole"),
82
InetAddress.getByName("host.rabbit.hole"),
83
new byte[0]
84
));
85
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
86
s.x().setChannelBinding(new ChannelBinding(
87
InetAddress.getByName("client.rabbit.hole"),
88
InetAddress.getByName("host.rabbit.hole"),
89
new byte[1] // 0 -> 1
90
));
91
try {
92
Context.handshake(c, s);
93
throw new Exception("Acceptor should reject initiator");
94
} catch (GSSException ge) {
95
// Expected bahavior
96
}
97
98
// Acceptor req, reject
99
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
100
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
101
s.x().setChannelBinding(new ChannelBinding(
102
InetAddress.getByName("client.rabbit.hole"),
103
InetAddress.getByName("host.rabbit.hole"),
104
new byte[0]
105
));
106
try {
107
Context.handshake(c, s);
108
throw new Exception("Acceptor should reject initiator");
109
} catch (GSSException ge) {
110
// Expected bahavior
111
if (ge.getMajor() != GSSException.BAD_BINDINGS) {
112
throw ge;
113
}
114
}
115
}
116
}
117
118