author | stefank |
Mon, 25 Aug 2014 09:10:13 +0200 | |
changeset 26314 | f8bc1966fb30 |
parent 8396 | 587947f96036 |
child 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
3050
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
1 |
/* |
8396
587947f96036
7018928: test failure: sun/security/krb5/auto/SSL.java
weijun
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
3050
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
4 |
* |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
8 |
* |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
13 |
* accompanied this code). |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
14 |
* |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
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. |
|
3050
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
22 |
*/ |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
23 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
24 |
/* |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
25 |
* @test |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
26 |
* @bug 6851973 |
8396
587947f96036
7018928: test failure: sun/security/krb5/auto/SSL.java
weijun
parents:
5506
diff
changeset
|
27 |
* @run main/othervm IgnoreChannelBinding |
3050
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
28 |
* @summary ignore incoming channel binding if acceptor does not set one |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
29 |
*/ |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
30 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
31 |
import java.net.InetAddress; |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
32 |
import org.ietf.jgss.ChannelBinding; |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
33 |
import org.ietf.jgss.GSSException; |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
34 |
import sun.security.jgss.GSSUtil; |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
35 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
36 |
public class IgnoreChannelBinding { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
37 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
38 |
public static void main(String[] args) |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
39 |
throws Exception { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
40 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
41 |
new OneKDC(null).writeJAASConf(); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
42 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
43 |
Context c = Context.fromJAAS("client"); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
44 |
Context s = Context.fromJAAS("server"); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
45 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
46 |
// All silent |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
47 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
48 |
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
49 |
Context.handshake(c, s); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
50 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
51 |
// Initiator req, acceptor ignore |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
52 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
53 |
c.x().setChannelBinding(new ChannelBinding( |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
54 |
InetAddress.getByName("client.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
55 |
InetAddress.getByName("host.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
56 |
new byte[0] |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
57 |
)); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
58 |
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
59 |
Context.handshake(c, s); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
60 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
61 |
// Both req, and match |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
62 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
63 |
c.x().setChannelBinding(new ChannelBinding( |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
64 |
InetAddress.getByName("client.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
65 |
InetAddress.getByName("host.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
66 |
new byte[0] |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
67 |
)); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
68 |
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
69 |
s.x().setChannelBinding(new ChannelBinding( |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
70 |
InetAddress.getByName("client.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
71 |
InetAddress.getByName("host.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
72 |
new byte[0] |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
73 |
)); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
74 |
Context.handshake(c, s); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
75 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
76 |
// Both req, NOT match |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
77 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
78 |
c.x().setChannelBinding(new ChannelBinding( |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
79 |
InetAddress.getByName("client.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
80 |
InetAddress.getByName("host.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
81 |
new byte[0] |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
82 |
)); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
83 |
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
84 |
s.x().setChannelBinding(new ChannelBinding( |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
85 |
InetAddress.getByName("client.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
86 |
InetAddress.getByName("host.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
87 |
new byte[1] // 0 -> 1 |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
88 |
)); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
89 |
try { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
90 |
Context.handshake(c, s); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
91 |
throw new Exception("Acceptor should reject initiator"); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
92 |
} catch (GSSException ge) { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
93 |
// Expected bahavior |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
94 |
} |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
95 |
|
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
96 |
// Acceptor req, reject |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
97 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
98 |
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
99 |
s.x().setChannelBinding(new ChannelBinding( |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
100 |
InetAddress.getByName("client.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
101 |
InetAddress.getByName("host.rabbit.hole"), |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
102 |
new byte[0] |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
103 |
)); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
104 |
try { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
105 |
Context.handshake(c, s); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
106 |
throw new Exception("Acceptor should reject initiator"); |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
107 |
} catch (GSSException ge) { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
108 |
// Expected bahavior |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
109 |
if (ge.getMajor() != GSSException.BAD_BINDINGS) { |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
110 |
throw ge; |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
111 |
} |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
112 |
} |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
113 |
} |
c0ce59daa004
6851973: ignore incoming channel binding if acceptor does not set one
weijun
parents:
diff
changeset
|
114 |
} |