001 /* ManagementPermission.java - Permissions for system management. 002 Copyright (C) 2006 Free Software Foundation 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 package java.lang.management; 039 040 import 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 */ 078 public 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 }