001/* ManagementPermission.java - Permissions for system management. 002 Copyright (C) 2006 Free Software Foundation 003 004This file is part of GNU Classpath. 005 006GNU Classpath is free software; you can redistribute it and/or modify 007it under the terms of the GNU General Public License as published by 008the Free Software Foundation; either version 2, or (at your option) 009any later version. 010 011GNU Classpath is distributed in the hope that it will be useful, but 012WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014General Public License for more details. 015 016You should have received a copy of the GNU General Public License 017along with GNU Classpath; see the file COPYING. If not, write to the 018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 01902110-1301 USA. 020 021Linking this library statically or dynamically with other modules is 022making a combined work based on this library. Thus, the terms and 023conditions of the GNU General Public License cover the whole 024combination. 025 026As a special exception, the copyright holders of this library give you 027permission to link this library with independent modules to produce an 028executable, regardless of the license terms of these independent 029modules, and to copy and distribute the resulting executable under 030terms of your choice, provided that you also meet, for each linked 031independent module, the terms and conditions of the license of that 032module. An independent module is a module which is not derived from 033or based on this library. If you modify this library, you may extend 034this exception to your version of the library, but you are not 035obligated to do so. If you do not wish to do so, delete this 036exception statement from your version. */ 037 038package java.lang.management; 039 040import java.security.BasicPermission; 041 042/** 043 * <p> 044 * Represents the permission to view or modify the data 045 * which forms part of the system management interfaces. 046 * Calls to methods of the system management beans, 047 * provided by the {@link ManagementFactory}, may perform 048 * checks against the current {@link java.lang.SecurityManager} 049 * (if any) before allowing the operation to proceed. 050 * Instances of this object are supplied to the 051 * {@link java.lang.SecurityManager} in order to perform 052 * these checks. It is not normal for instances of this 053 * class to be created outside the use of the 054 * {@link java.lang.SecurityManager}. 055 * </p> 056 * <p> 057 * This object can represent two types of management 058 * permission: 059 * </p> 060 * <ul> 061 * <li><strong>monitor</strong> — this allows access 062 * to information such as the arguments supplied to the 063 * virtual machine, the currently loaded classes and the 064 * stack traces of running threads. Malicious code may 065 * use this to obtain information about the system and 066 * exploit any vulnerabilities found.</li> 067 * <li><strong>control</strong> — this allows the 068 * information stored by the management beans to be altered. 069 * For example, additional debugging information (such 070 * as class loading traces) may be turned on or memory 071 * usage limits changed. Malicious code could use 072 * this to alter the behaviour of the system.</li> 073 * </ul> 074 * 075 * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 076 * @since 1.5 077 */ 078public final class ManagementPermission 079 extends BasicPermission 080{ 081 082 /** 083 * Compatible with JDK 1.5 084 */ 085 private static final long serialVersionUID = 1897496590799378737L; 086 087 /** 088 * Constructs a new <code>ManagementPermission</code> 089 * for one of the two permission targets, "monitor" 090 * and "control". 091 * 092 * @param name the name of the permission this instance 093 * should represent; either "monitor" or 094 * "control". 095 * @throws IllegalArgumentException if the name is not 096 * either "monitor" 097 * or "control". 098 */ 099 public ManagementPermission(String name) 100 { 101 super(name); 102 if (!(name.equals("monitor") || name.equals("control"))) 103 throw new IllegalArgumentException("Invalid permission."); 104 } 105 106 /** 107 * Constructs a new <code>ManagementPermission</code> 108 * for one of the two permission targets, "monitor" 109 * and "control". Actions are not supported, so 110 * this value should be either <code>null</code> 111 * or the empty string. 112 * 113 * @param name the name of the permission this instance 114 * should represent; either "monitor" or 115 * "control". 116 * @param actions either <code>null</code> or the 117 * empty string. 118 * @throws IllegalArgumentException if the name is not 119 * either "monitor" 120 * or "control", or 121 * a value for actions 122 * is specified. 123 */ 124 public ManagementPermission(String name, String actions) 125 { 126 this(name); 127 if (!(actions == null || actions.equals(""))) 128 throw new IllegalArgumentException("Invalid actions."); 129 } 130 131} 132