jdk/src/java.management/share/classes/java/lang/management/ManagementPermission.java
author ksrini
Mon, 01 May 2017 07:33:19 -0700
changeset 44858 7183899b064b
parent 25859 3317bb8137f4
child 45130 469dceb426cc
permissions -rw-r--r--
8179415: Update java.management and java.management.rmi to be HTML-5 friendly Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 25859
diff changeset
     2
 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1320
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The permission which the SecurityManager will check when code
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * that is running with a SecurityManager calls methods defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * in the management interface for the Java platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The following table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * provides a summary description of what the permission allows,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * and discusses the risks of granting code the permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 25859
diff changeset
    37
 * <table border="1" cellpadding=5>
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 25859
diff changeset
    38
 * <caption style="display:none">Table shows permission target name, what the permission allows, and associated risks</caption>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <th>Permission Target Name</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <th>What the Permission Allows</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <th>Risks of Allowing this Permission</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *   <td>control</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *   <td>Ability to control the runtime characteristics of the Java virtual
11820
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    48
 *       machine, for example, enabling and disabling the verbose output for
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    49
 *       the class loading or memory system, setting the threshold of a memory
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    50
 *       pool, and enabling and disabling the thread contention monitoring
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    51
 *       support. Some actions controlled by this permission can disclose
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    52
 *       information about the running application, like the -verbose:class
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    53
 *       flag.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *   </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *   <td>This allows an attacker to control the runtime characteristics
11820
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    56
 *       of the Java virtual machine and cause the system to misbehave. An
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    57
 *       attacker can also access some information related to the running
49cf84efbd2d 7120974: ManagementPermission "control" needs clarification
fparain
parents: 5506
diff changeset
    58
 *       application.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *   </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *   <td>monitor</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *   <td>Ability to retrieve runtime information about
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *       the Java virtual machine such as thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *       stack trace, a list of all loaded class names, and input arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *       to the Java virtual machine.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *   <td>This allows malicious code to monitor runtime information and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *       uncover vulnerabilities.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Programmers do not normally create ManagementPermission objects directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * Instead they are created by the security policy code based on reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * the security policy file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * @author  Mandy Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * @see java.security.BasicPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * @see java.security.PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @see java.lang.SecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
public final class ManagementPermission extends java.security.BasicPermission {
1320
2412b1562801 6749308: java.io, java.lang, java.util exception classes don't specify serialVersionUID
chegar
parents: 2
diff changeset
    90
    private static final long serialVersionUID = 1897496590799378737L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Constructs a ManagementPermission with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param name Permission name. Must be either "monitor" or "control".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @throws NullPointerException if <code>name</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @throws IllegalArgumentException if <code>name</code> is empty or invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public ManagementPermission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if (!name.equals("control") && !name.equals("monitor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            throw new IllegalArgumentException("name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Constructs a new ManagementPermission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param name Permission name. Must be either "monitor" or "control".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param actions Must be either null or the empty string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @throws NullPointerException if <code>name</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @throws IllegalArgumentException if <code>name</code> is empty or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * if arguments are invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public ManagementPermission(String name, String actions)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (!name.equals("control") && !name.equals("monitor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            throw new IllegalArgumentException("name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        if (actions != null && actions.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            throw new IllegalArgumentException("actions: " + actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}