KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > management > ManagementPermission


1 /*
2  * @(#)ManagementPermission.java 1.3 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang.management;
9
10 /**
11  * The permission which the SecurityManager will check when code
12  * that is running with a SecurityManager calls methods defined
13  * in the management interface for the Java platform.
14  * <P>
15  * The following table
16  * provides a summary description of what the permission allows,
17  * and discusses the risks of granting code the permission.
18  * <P>
19  *
20  * <table border=1 cellpadding=5 summary="Table shows permission target name, wh
21 at the permission allows, and associated risks">
22  * <tr>
23  * <th>Permission Target Name</th>
24  * <th>What the Permission Allows</th>
25  * <th>Risks of Allowing this Permission</th>
26  * </tr>
27  *
28  * <tr>
29  * <td>control</td>
30  * <td>Ability to control the runtime characteristics of the Java virtual
31  * machine, for example, setting the -verbose:gc and -verbose:class flag,
32  * setting the threshold of a memory pool, and enabling and disabling
33  * the thread contention monitoring support.
34  * </td>
35  * <td>This allows an attacker to control the runtime characteristics
36  * of the Java virtual machine and cause the system to misbehave.
37  * </td>
38  * </tr>
39  * <tr>
40  * <td>monitor</td>
41  * <td>Ability to retrieve runtime information about
42  * the Java virtual machine such as thread
43  * stack trace, a list of all loaded class names, and input arguments
44  * to the Java virtual machine.</td>
45  * <td>This allows malicious code to monitor runtime information and
46  * uncover vulnerabilities.</td>
47  * </tr>
48  *
49  * </table>
50  *
51  * <p>
52  * Programmers do not normally create ManagementPermission objects directly.
53  * Instead they are created by the security policy code based on reading
54  * the security policy file.
55  *
56  * @author Mandy Chung
57  * @version 1.3, 12/19/03
58  * @since 1.5
59  *
60  * @see java.security.BasicPermission
61  * @see java.security.Permission
62  * @see java.security.Permissions
63  * @see java.security.PermissionCollection
64  * @see java.lang.SecurityManager
65  *
66  */

67
68 public final class ManagementPermission extends java.security.BasicPermission JavaDoc {
69
70     /**
71      * Constructs a ManagementPermission with the specified name.
72      *
73      * @param name Permission name. Must be either "monitor" or "control".
74      * @throws IllegalArgumentException if the name argument is invalid.
75      */

76     public ManagementPermission(String JavaDoc name) {
77         super(name);
78     if (!name.equals("control") && !name.equals("monitor")) {
79         throw new IllegalArgumentException JavaDoc("name: " + name);
80     }
81     }
82
83     /**
84      * Constructs a new ManagementPermission object.
85      *
86      * @param name Permission name. Must be either "monitor" or "control".
87      * @param actions Must be either null or the empty string.
88      * @throws IllegalArgumentException if arguments are invalid.
89      */

90     public ManagementPermission(String JavaDoc name, String JavaDoc actions)
91         throws IllegalArgumentException JavaDoc {
92         super(name);
93     if (!name.equals("control") && !name.equals("monitor")) {
94         throw new IllegalArgumentException JavaDoc("name: " + name);
95     }
96     if (actions != null && actions.length() > 0) {
97         throw new IllegalArgumentException JavaDoc("actions: " + actions);
98     }
99     }
100 }
101
Popular Tags