4533
|
1 |
/*
|
|
2 |
* Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 6895424
|
|
27 |
* @summary RFC 5653
|
|
28 |
*/
|
|
29 |
|
|
30 |
import org.ietf.jgss.GSSContext;
|
|
31 |
import org.ietf.jgss.GSSManager;
|
|
32 |
import org.ietf.jgss.GSSName;
|
|
33 |
import org.ietf.jgss.Oid;
|
|
34 |
import sun.security.jgss.GSSUtil;
|
|
35 |
|
|
36 |
public class Test5653 {
|
|
37 |
|
|
38 |
public static void main(String[] args)
|
|
39 |
throws Exception {
|
|
40 |
|
|
41 |
Oid oldOid = new Oid("1.3.6.1.5.6.2");
|
|
42 |
new OneKDC(null).writeJAASConf();
|
|
43 |
|
|
44 |
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
|
|
45 |
GSSManager m = GSSManager.getInstance();
|
|
46 |
boolean found = false;
|
|
47 |
|
|
48 |
// Test 1: the getMechsForName() method accepts it.
|
|
49 |
for (Oid tmp: m.getMechsForName(oldOid)) {
|
|
50 |
if (tmp.equals(GSSUtil.GSS_KRB5_MECH_OID)) {
|
|
51 |
found = true;
|
|
52 |
break;
|
|
53 |
}
|
|
54 |
}
|
|
55 |
if (!found) {
|
|
56 |
throw new Exception("Cannot found krb5 mech for old name type");
|
|
57 |
}
|
|
58 |
|
|
59 |
// Test 2: the createName() method accepts it.
|
|
60 |
GSSName name = m.createName("server@host.rabbit.hole", oldOid);
|
|
61 |
|
|
62 |
// Test 3: its getStringNameType() output is correct
|
|
63 |
if (!name.getStringNameType().equals(GSSName.NT_HOSTBASED_SERVICE)) {
|
|
64 |
throw new Exception("GSSName not correct name type");
|
|
65 |
}
|
|
66 |
|
|
67 |
// Test 4: everything still works.
|
|
68 |
GSSContext c1 = m.createContext(
|
|
69 |
name,
|
|
70 |
GSSUtil.GSS_KRB5_MECH_OID,
|
|
71 |
null,
|
|
72 |
GSSContext.DEFAULT_LIFETIME);
|
|
73 |
byte[] token = c1.initSecContext(new byte[0], 0, 0);
|
|
74 |
|
|
75 |
Context s;
|
|
76 |
s = Context.fromJAAS("server");
|
|
77 |
s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
|
|
78 |
s.x().acceptSecContext(token, 0, token.length);
|
|
79 |
}
|
|
80 |
}
|