示例#1
1
  public static void go0(String... expected) throws Exception {
    System.setProperty("sun.security.krb5.debug", "true");

    // Make sure KDCs' ports starts with 1 and 2 and 3,
    // useful for checking debug output.
    int p1 = 10000 + new java.util.Random().nextInt(10000);
    int p2 = 20000 + new java.util.Random().nextInt(10000);
    int p3 = 30000 + new java.util.Random().nextInt(10000);

    FileWriter fw = new FileWriter("alternative-krb5.conf");

    fw.write(
        "[libdefaults]\n"
            + "default_realm = "
            + OneKDC.REALM
            + "\n"
            + "kdc_timeout = "
            + toReal(2000)
            + "\n");
    fw.write(
        "[realms]\n"
            + OneKDC.REALM
            + " = {\n"
            + "kdc = "
            + OneKDC.KDCHOST
            + ":"
            + p1
            + "\n"
            + "kdc = "
            + OneKDC.KDCHOST
            + ":"
            + p2
            + "\n"
            + "kdc = "
            + OneKDC.KDCHOST
            + ":"
            + p3
            + "\n"
            + "}\n");

    fw.close();
    System.setProperty("java.security.krb5.conf", "alternative-krb5.conf");
    Config.refresh();

    // Turn on k3 only
    KDC k3 = on(p3);

    test(expected[0]);
    test(expected[1]);
    Config.refresh();
    test(expected[2]);

    k3.terminate(); // shutdown k3
    on(p2); // k2 is on
    test(expected[3]);
    on(p1); // k1 and k2 is on
    test(expected[4]);
  }