test/jdk/java/security/BasicPermission/Wildcard.java
author xuelei
Fri, 01 Mar 2019 08:35:14 -0800
changeset 53972 43c2ab1bdfd3
parent 47216 71c04702a3d5
permissions -rw-r--r--
8215430: Remove the internal package com.sun.net.ssl Reviewed-by: chegar, mullan, wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14667
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     1
/*
53972
43c2ab1bdfd3 8215430: Remove the internal package com.sun.net.ssl
xuelei
parents: 47216
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
14667
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     4
 *
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     8
 *
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    13
 * accompanied this code).
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    14
 *
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    18
 *
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    21
 * questions.
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    22
 */
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    23
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    24
import java.lang.RuntimePermission;
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    25
import java.net.NetPermission;
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    26
import java.sql.SQLPermission;
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    27
import java.util.PropertyPermission;
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    28
import javax.net.ssl.SSLPermission;
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    29
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    30
/*
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    31
 * @test
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    32
 * @bug 7167056
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    33
 * @summary Check that BasicPermission subclasses don't throw exception if name
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    34
 *          contains wildcard character ("*") but does not signify a
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    35
 *          wildcard match
53972
43c2ab1bdfd3 8215430: Remove the internal package com.sun.net.ssl
xuelei
parents: 47216
diff changeset
    36
 * @modules java.sql
14667
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    37
 */
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    38
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    39
public class Wildcard {
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    40
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    41
    public static void main(String[] args) throws Exception {
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    42
        wildcard("*java");
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    43
        wildcard("java*");
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    44
        wildcard("ja*va");
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    45
    }
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    46
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    47
    private static void wildcard(String wildcard) throws Exception {
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    48
        new RuntimePermission(wildcard);
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    49
        new NetPermission(wildcard);
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    50
        new SQLPermission(wildcard);
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    51
        new PropertyPermission(wildcard, "read");
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    52
        new SSLPermission(wildcard);
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    53
    }
6862285acf46 7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
diff changeset
    54
}