Path: blob/master/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java
41159 views
/*1* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.jdi;2627/**28* The {@code JDIPermission} class represents access rights to29* the {@code VirtualMachineManager}. This is the permission30* which the SecurityManager will check when code that is running with31* a SecurityManager requests access to the VirtualMachineManager, as32* defined in the Java Debug Interface (JDI) for the Java platform.33* <P>34* A {@code JDIPermission} object contains a name (also referred35* to as a "target name") but no actions list; you either have the36* named permission or you don't.37* <P>38* The following table provides a summary description of what the39* permission allows, and discusses the risks of granting code the40* permission.41*42* <table class="striped">43* <caption style="display:none">Table shows permission target name, what the44* permission allows, and associated risks</caption>45* <thead>46* <tr>47* <th scope="col">Permission Target Name</th>48* <th scope="col">What the Permission Allows</th>49* <th scope="col">Risks of Allowing this Permission</th>50* </tr>51* </thead>52*53* <tbody>54* <tr>55* <th scope="row">virtualMachineManager</th>56* <td>Ability to inspect and modify the JDI objects in the57* {@code VirtualMachineManager}58* </td>59* <td>This allows an attacker to control the60* {@code VirtualMachineManager} and cause the system to61* misbehave.62* </td>63* </tr>64* </tbody>65*66* </table>67*68* <p>69* Programmers do not normally create JDIPermission objects directly.70* Instead they are created by the security policy code based on reading71* the security policy file.72*73* @author Tim Bell74* @since 1.575*76* @see Bootstrap77* @see java.security.BasicPermission78* @see java.security.Permission79* @see java.security.Permissions80* @see java.security.PermissionCollection81* @see java.lang.SecurityManager82*83*/8485public final class JDIPermission extends java.security.BasicPermission {8687private static final long serialVersionUID = -6988461416938786271L;8889/**90* The {@code JDIPermission} class represents access rights to the91* {@code VirtualMachineManager}92* @param name Permission name. Must be "virtualMachineManager".93* @throws IllegalArgumentException if the name argument is invalid.94*/95public JDIPermission(String name) {96super(name);97if (!name.equals("virtualMachineManager")) {98throw new IllegalArgumentException("name: " + name);99}100}101102/**103* Constructs a new JDIPermission object.104*105* @param name Permission name. Must be "virtualMachineManager".106* @param actions Must be either null or the empty string.107* @throws IllegalArgumentException if arguments are invalid.108*/109public JDIPermission(String name, String actions)110throws IllegalArgumentException {111super(name);112if (!name.equals("virtualMachineManager")) {113throw new IllegalArgumentException("name: " + name);114}115if (actions != null && actions.length() > 0) {116throw new IllegalArgumentException("actions: " + actions);117}118}119}120121122