001: /*
002: * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.jdi;
027:
028: /**
029: * The <code>JDIPermission</code> class represents access rights to
030: * the <code>VirtualMachineManager</code>. This is the permission
031: * which the SecurityManager will check when code that is running with
032: * a SecurityManager requests access to the VirtualMachineManager, as
033: * defined in the Java Debug Interface (JDI) for the Java platform.
034: * <P>
035: * A <code>JDIPermission</code> object contains a name (also referred
036: * to as a "target name") but no actions list; you either have the
037: * named permission or you don't.
038: * <P>
039: * The following table provides a summary description of what the
040: * permission allows, and discusses the risks of granting code the
041: * permission.
042: * <P>
043: * <table border=1 cellpadding=5 summary="Table shows permission
044: * target name, what the permission allows, and associated risks">
045: * <tr>
046: * <th>Permission Target Name</th>
047: * <th>What the Permission Allows</th>
048: * <th>Risks of Allowing this Permission</th>
049: * </tr>
050: *
051: * <tr>
052: * <td>virtualMachineManager</td>
053: * <td>Ability to inspect and modify the JDI objects in the
054: * <code>VirtualMachineManager</code>
055: * </td>
056: * <td>This allows an attacker to control the
057: * <code>VirtualMachineManager</code> and cause the system to
058: * misbehave.
059: * </td>
060: * </tr>
061: *
062: * </table>
063: *
064: * <p>
065: * Programmers do not normally create JDIPermission objects directly.
066: * Instead they are created by the security policy code based on reading
067: * the security policy file.
068: *
069: * @author Tim Bell
070: * @version 1.9, 05/05/07
071: * @since 1.5
072: *
073: * @see com.sun.jdi.Bootstrap
074: * @see java.security.BasicPermission
075: * @see java.security.Permission
076: * @see java.security.Permissions
077: * @see java.security.PermissionCollection
078: * @see java.lang.SecurityManager
079: *
080: */
081:
082: public final class JDIPermission extends java.security.BasicPermission {
083:
084: /**
085: * The <code>JDIPermission</code> class represents access rights to the
086: * <code>VirtualMachineManager</code>
087: * @param name Permission name. Must be "virtualMachineManager".
088: * @throws IllegalArgumentException if the name argument is invalid.
089: */
090: public JDIPermission(String name) {
091: super (name);
092: if (!name.equals("virtualMachineManager")) {
093: throw new IllegalArgumentException("name: " + name);
094: }
095: }
096:
097: /**
098: * Constructs a new JDIPermission object.
099: *
100: * @param name Permission name. Must be "virtualMachineManager".
101: * @param actions Must be either null or the empty string.
102: * @throws IllegalArgumentException if arguments are invalid.
103: */
104: public JDIPermission(String name, String actions)
105: throws IllegalArgumentException {
106: super (name);
107: if (!name.equals("virtualMachineManager")) {
108: throw new IllegalArgumentException("name: " + name);
109: }
110: if (actions != null && actions.length() > 0) {
111: throw new IllegalArgumentException("actions: " + actions);
112: }
113: }
114: }
|