42 * @run main/othervm BasicKrb5Test rc4-hmac -s
43 * @run main/othervm BasicKrb5Test -C
44 * @run main/othervm BasicKrb5Test des-cbc-crc -C
45 * @run main/othervm BasicKrb5Test des-cbc-md5 -C
46 * @run main/othervm BasicKrb5Test des3-cbc-sha1 -C
47 * @run main/othervm BasicKrb5Test aes128-cts -C
48 * @run main/othervm BasicKrb5Test aes256-cts -C
49 * @run main/othervm BasicKrb5Test rc4-hmac -C
50 * @run main/othervm BasicKrb5Test -s -C
51 * @run main/othervm BasicKrb5Test des-cbc-crc -s -C
52 * @run main/othervm BasicKrb5Test des-cbc-md5 -s -C
53 * @run main/othervm BasicKrb5Test des3-cbc-sha1 -s -C
54 * @run main/othervm BasicKrb5Test aes128-cts -s -C
55 * @run main/othervm BasicKrb5Test aes256-cts -s -C
56 * @run main/othervm BasicKrb5Test rc4-hmac -s -C
57 */
58
59 import org.ietf.jgss.GSSName;
60 import sun.security.jgss.GSSUtil;
61 import sun.security.krb5.Config;
62 import sun.security.krb5.internal.crypto.EType;
63
64 /**
65 * Basic JGSS/krb5 test with 3 parties: client, server, backend server. Each
66 * party uses JAAS login to get subjects and executes JGSS calls using
67 * Subject.doAs.
68 */
69 public class BasicKrb5Test {
70
71 private static boolean conf = true;
72 /**
73 * @param args empty or etype
74 */
75 public static void main(String[] args)
76 throws Exception {
77
78 String etype = null;
79 for (String arg: args) {
80 if (arg.equals("-s")) Context.usingStream = true;
81 else if(arg.equals("-C")) conf = false;
82 else etype = arg;
83 }
84
85 // Creates and starts the KDC. This line must be put ahead of etype check
86 // since the check needs a krb5.conf.
87 new OneKDC(etype).writeJAASConf();
88
89 System.out.println("Testing etype " + etype);
90 if (etype != null && !EType.isSupported(Config.getType(etype))) {
91 // aes256 is not enabled on all systems
92 System.out.println("Not supported.");
93 return;
94 }
95
96 new BasicKrb5Test().go(OneKDC.SERVER, OneKDC.BACKEND);
97 }
98
99 void go(final String server, final String backend) throws Exception {
100 Context c, s, s2, b;
101 c = Context.fromJAAS("client");
102 s = Context.fromJAAS("server");
103 b = Context.fromJAAS("backend");
104
105 c.startAsClient(server, GSSUtil.GSS_KRB5_MECH_OID);
106 c.x().requestCredDeleg(true);
107 c.x().requestConf(conf);
108 s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
109
110 c.status();
111 s.status();
112
|
42 * @run main/othervm BasicKrb5Test rc4-hmac -s
43 * @run main/othervm BasicKrb5Test -C
44 * @run main/othervm BasicKrb5Test des-cbc-crc -C
45 * @run main/othervm BasicKrb5Test des-cbc-md5 -C
46 * @run main/othervm BasicKrb5Test des3-cbc-sha1 -C
47 * @run main/othervm BasicKrb5Test aes128-cts -C
48 * @run main/othervm BasicKrb5Test aes256-cts -C
49 * @run main/othervm BasicKrb5Test rc4-hmac -C
50 * @run main/othervm BasicKrb5Test -s -C
51 * @run main/othervm BasicKrb5Test des-cbc-crc -s -C
52 * @run main/othervm BasicKrb5Test des-cbc-md5 -s -C
53 * @run main/othervm BasicKrb5Test des3-cbc-sha1 -s -C
54 * @run main/othervm BasicKrb5Test aes128-cts -s -C
55 * @run main/othervm BasicKrb5Test aes256-cts -s -C
56 * @run main/othervm BasicKrb5Test rc4-hmac -s -C
57 */
58
59 import org.ietf.jgss.GSSName;
60 import sun.security.jgss.GSSUtil;
61 import sun.security.krb5.Config;
62 import sun.security.krb5.KrbException;
63 import sun.security.krb5.internal.crypto.EType;
64
65 /**
66 * Basic JGSS/krb5 test with 3 parties: client, server, backend server. Each
67 * party uses JAAS login to get subjects and executes JGSS calls using
68 * Subject.doAs.
69 */
70 public class BasicKrb5Test {
71
72 private static boolean conf = true;
73 /**
74 * @param args empty or etype
75 */
76 public static void main(String[] args)
77 throws Exception {
78
79 String etype = null;
80 for (String arg: args) {
81 if (arg.equals("-s")) Context.usingStream = true;
82 else if(arg.equals("-C")) conf = false;
83 else etype = arg;
84 }
85
86 // Creates and starts the KDC. This line must be put ahead of etype check
87 // since the check needs a krb5.conf.
88 try {
89 new OneKDC(etype).writeJAASConf();
90 } catch (KrbException ke) {
91 System.out.println("Testing etype " + etype + "Not supported.");
92 return;
93 }
94
95 new BasicKrb5Test().go(OneKDC.SERVER, OneKDC.BACKEND);
96 }
97
98 void go(final String server, final String backend) throws Exception {
99 Context c, s, s2, b;
100 c = Context.fromJAAS("client");
101 s = Context.fromJAAS("server");
102 b = Context.fromJAAS("backend");
103
104 c.startAsClient(server, GSSUtil.GSS_KRB5_MECH_OID);
105 c.x().requestCredDeleg(true);
106 c.x().requestConf(conf);
107 s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
108
109 c.status();
110 s.status();
111
|