jdk/test/javax/net/ssl/ServerName/IllegalSNIName.java
author xuelei
Wed, 05 Mar 2014 07:24:34 +0000
changeset 23052 241885315119
parent 19793 jdk/test/sun/security/ssl/javax/net/ssl/ServerName/IllegalSNIName.java@05e90dbeecd4
permissions -rw-r--r--
8032473: Restructure JSSE regression test hierarchy in jdk test Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19440
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     1
/*
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     4
 *
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     8
 *
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    13
 * accompanied this code).
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    14
 *
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    18
 *
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    21
 * questions.
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    22
 */
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    23
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    24
/*
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    25
 * @test
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    26
 * @bug 8020842
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    27
 * @summary SNIHostName does not throw IAE when hostname ends
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    28
 *          with a trailing dot
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    29
 */
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    30
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    31
import javax.net.ssl.SNIHostName;
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    32
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    33
public class IllegalSNIName {
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    34
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    35
    public static void main(String[] args) throws Exception {
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    36
        String[] illegalNames = {
19793
05e90dbeecd4 8024068: sun/security/ssl/javax/net/ssl/ServerName/IllegalSNIName.java fails
xuelei
parents: 19440
diff changeset
    37
                "example\u3002\u3002com",
19440
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    38
                "example..com",
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    39
                "com\u3002",
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    40
                "com.",
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    41
                "."
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    42
            };
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    43
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    44
        for (String name : illegalNames) {
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    45
            try {
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    46
                SNIHostName hostname = new SNIHostName(name);
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    47
                throw new Exception(
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    48
                    "Expected to get IllegalArgumentException for " + name);
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    49
            } catch (IllegalArgumentException iae) {
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    50
                // That's the right behavior.
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    51
            }
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    52
        }
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    53
    }
c4414bc88602 8020842: IDN do not throw IAE when hostname ends with a trailing dot
xuelei
parents:
diff changeset
    54
}