jdk/src/share/classes/com/sun/jdi/JDIPermission.java
author alanb
Fri, 02 Nov 2012 15:50:11 +0000
changeset 14342 8435a30053c1
parent 11277 e3a1c90dd439
child 20742 4ae78e8060d6
permissions -rw-r--r--
7197491: update copyright year to match last edit in jdk8 jdk repository Reviewed-by: chegar, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 11277
diff changeset
     2
 * Copyright (c) 2004, 2011, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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 com.sun.jdi;
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 <code>JDIPermission</code> class represents access rights to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * the <code>VirtualMachineManager</code>.  This is the permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * which the SecurityManager will check when code that is running with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * a SecurityManager requests access to the VirtualMachineManager, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * defined in the Java Debug Interface (JDI) for the Java platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A <code>JDIPermission</code> object contains a name (also referred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * to as a "target name") but no actions list; you either have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * named permission or you don't.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * The following table provides a summary description of what the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * permission allows, and discusses the risks of granting code the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <table border=1 cellpadding=5 summary="Table shows permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * target name, what the permission allows, and associated risks">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <th>Permission Target Name</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <th>What the Permission Allows</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <th>Risks of Allowing this Permission</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *   <td>virtualMachineManager</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *   <td>Ability to inspect and modify the JDI objects in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *   <code>VirtualMachineManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *   </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *   <td>This allows an attacker to control the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *   <code>VirtualMachineManager</code> and cause the system to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *   misbehave.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * Programmers do not normally create JDIPermission objects directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Instead they are created by the security policy code based on reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * the security policy file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * @author  Tim Bell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @see com.sun.jdi.Bootstrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * @see java.security.BasicPermission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * @see java.security.Permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @see java.security.Permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @see java.security.PermissionCollection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * @see java.lang.SecurityManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
public final class JDIPermission extends java.security.BasicPermission {
11277
e3a1c90dd439 7117053: Fix build warnings in com/sun/tools/jdi/*
jjh
parents: 5506
diff changeset
    82
    private static final long serialVersionUID = -6988461416938786271L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * The <code>JDIPermission</code> class represents access rights to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * <code>VirtualMachineManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param name Permission name. Must be "virtualMachineManager".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @throws IllegalArgumentException if the name argument is invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public JDIPermission(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        if (!name.equals("virtualMachineManager")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            throw new IllegalArgumentException("name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Constructs a new JDIPermission object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param name Permission name. Must be "virtualMachineManager".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param actions Must be either null or the empty string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @throws IllegalArgumentException if arguments are invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public JDIPermission(String name, String actions)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (!name.equals("virtualMachineManager")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            throw new IllegalArgumentException("name: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (actions != null && actions.length() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            throw new IllegalArgumentException("actions: " + actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
}