41 System.setProperty("sun.security.krb5.debug", "true"); |
41 System.setProperty("sun.security.krb5.debug", "true"); |
42 |
42 |
43 OneKDC kdc = new OneKDC(null); |
43 OneKDC kdc = new OneKDC(null); |
44 kdc.writeJAASConf(); |
44 kdc.writeJAASConf(); |
45 |
45 |
46 KDC.saveConfig(OneKDC.KRB5_CONF, kdc, |
46 // Two styles of kdc_timeout setting. One global, one realm-specific. |
47 "udp_preference_limit = " |
47 if (args[0].equals("UDP")) { |
48 + (args[0].equals("UDP") ? "1000" : "100")); |
48 KDC.saveConfig(OneKDC.KRB5_CONF, kdc, |
|
49 "kdc_timeout = 10s"); |
|
50 } else { |
|
51 kdc.addConf("kdc_timeout = 10s"); |
|
52 KDC.saveConfig(OneKDC.KRB5_CONF, kdc, |
|
53 "udp_preference_limit = 1"); |
|
54 } |
49 Config.refresh(); |
55 Config.refresh(); |
50 |
56 |
51 ByteArrayOutputStream bo = new ByteArrayOutputStream(); |
57 ByteArrayOutputStream bo = new ByteArrayOutputStream(); |
52 PrintStream oldout = System.out; |
58 PrintStream oldout = System.out; |
53 System.setOut(new PrintStream(bo)); |
59 System.setOut(new PrintStream(bo)); |
54 Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false); |
60 Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false); |
55 System.setOut(oldout); |
61 System.setOut(oldout); |
56 |
62 |
57 for (String line: new String(bo.toByteArray()).split("\n")) { |
63 for (String line: new String(bo.toByteArray()).split("\n")) { |
58 if (line.contains(">>> KDCCommunication")) { |
64 if (line.contains(">>> KDCCommunication")) { |
59 if (!line.contains(args[0])) { |
65 if (!line.contains(args[0]) || !line.contains("timeout=10000")) { |
60 throw new Exception("No " + args[0] + " in: " + line); |
66 throw new Exception("No " + args[0] + " in: " + line); |
61 } |
67 } |
62 } |
68 } |
63 } |
69 } |
64 } |
70 } |