jdk/test/sun/security/krb5/auto/UdpTcp.java
author stefank
Mon, 25 Aug 2014 09:10:13 +0200
changeset 26314 f8bc1966fb30
parent 24631 dafd257bc7f3
child 30820 0d4717a011d3
permissions -rw-r--r--
8055416: Several vm/gc/heap/summary "After GC" events emitted for the same GC ID Reviewed-by: brutisso, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23731
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     1
/*
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     4
 *
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     8
 *
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    13
 * accompanied this code).
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    14
 *
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    18
 *
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    21
 * questions.
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    22
 */
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    23
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    24
/*
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    25
 * @test
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    26
 * @bug 4966382 8039132
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    27
 * @run main/othervm UdpTcp UDP
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    28
 * @run main/othervm UdpTcp TCP
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    29
 * @summary udp or tcp
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    30
 */
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    31
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    32
import java.io.ByteArrayOutputStream;
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    33
import java.io.PrintStream;
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    34
import sun.security.krb5.Config;
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    35
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    36
public class UdpTcp {
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    37
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    38
    public static void main(String[] args)
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    39
            throws Exception {
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    40
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    41
        System.setProperty("sun.security.krb5.debug", "true");
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    42
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    43
        OneKDC kdc = new OneKDC(null);
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    44
        kdc.writeJAASConf();
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    45
24631
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    46
        // Two styles of kdc_timeout setting. One global, one realm-specific.
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    47
        if (args[0].equals("UDP")) {
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    48
            KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    49
                    "kdc_timeout = 10s");
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    50
        } else {
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    51
            kdc.addConf("kdc_timeout = 10s");
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    52
            KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    53
                    "udp_preference_limit = 1");
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    54
        }
23731
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    55
        Config.refresh();
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    56
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    57
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    58
        PrintStream oldout = System.out;
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    59
        System.setOut(new PrintStream(bo));
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    60
        Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    61
        System.setOut(oldout);
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    62
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    63
        for (String line: new String(bo.toByteArray()).split("\n")) {
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    64
            if (line.contains(">>> KDCCommunication")) {
24631
dafd257bc7f3 8036779: sun.security.krb5.KdcComm interprets kdc_timeout as msec instead of sec
weijun
parents: 23731
diff changeset
    65
                if (!line.contains(args[0]) || !line.contains("timeout=10000")) {
23731
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    66
                    throw new Exception("No " + args[0] + " in: " + line);
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    67
                }
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    68
            }
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    69
        }
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    70
    }
111b01cbc045 8039132: cleanup @ignore JAAS/krb5 tests
weijun
parents:
diff changeset
    71
}