1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */
7 package javax.management;
8
9 import java.security.BasicPermission;
10
11 /**
12 * Controls access to actions performed on MBeanServers. The name specifies
13 * the permission applies to an operation. The special value * applies to
14 * all operations.
15 *
16 * <ul>
17 * <li><b>createMBeanServer<b> controls access to
18 * {@link MBeanServerFactory#createMBeanServer()} or
19 * {@link MBeanServerFactory#createMBeanServer(java.lang.String)} </li>
20 * <li><b>findMBeanServer<b> controls access to
21 * {@link MBeanServerFactory#findMBeanServer(java.lang.String)} </li>
22 * <li><b>newMBeanServer<b> controls access to
23 * {@link MBeanServerFactory#newMBeanServer()} or
24 * {@link MBeanServerFactory#newMBeanServer(java.lang.String)} </li>
25 * <li><b>releaseMBeanServer<b> controls access to
26 * {@link MBeanServerFactory#releaseMBeanServer(javax.management.MBeanServer)} </li>
27 *
28 * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
29 * @version $Revision: 1.1.2.1 $
30 */
31 public class MBeanServerPermission
32 extends BasicPermission
33 {
34 // Constants ---------------------------------------------------
35
36 private static final long serialVersionUID = -5661980843569388590L;
37
38 // Attributes --------------------------------------------------
39
40 // Static ------------------------------------------------------
41
42 // Constructors ------------------------------------------------
43
44 /**
45 * Construct a new MBeanServer permission for a given name
46 *
47 * @param name the name of the permission to grant
48 * @exception NullPointerExecption if the name is null
49 * @exception IllegalArgumentException if the name is not * or one of
50 * listed names
51 */
52 public MBeanServerPermission(String name)
53 {
54 this(name, null);
55 }
56
57 /**
58 * Construct a new MBeanServer permission for a given name
59 *
60 * @param name the name of the permission to grant
61 * @param actions unused
62 * @exception NullPointerExecption if the name is null
63 * @exception IllegalArgumentException if the name is not * or one of
64 * listed names
65 */
66 public MBeanServerPermission(String name, String actions)
67 {
68 super(name, actions);
69 if (name.equals("*") == false &&
70 name.equals("createMBeanServer") == false &&
71 name.equals("findMBeanServer") == false &&
72 name.equals("newMBeanServer") == false &&
73 name.equals("releaseMBeanServer") == false)
74 throw new IllegalArgumentException("Unknown name: " + name);
75 }
76
77 // Public ------------------------------------------------------
78
79 /**
80 * @return human readable string.
81 */
82 public String toString()
83 {
84 StringBuffer buffer = new StringBuffer(100);
85 buffer.append(getClass().getName()).append(":");
86 buffer.append(" name=").append(getName());
87 buffer.append(" actions=").append(getActions());
88 return buffer.toString();
89 }
90
91 // X Implementation --------------------------------------------
92
93 // Y Overrides -------------------------------------------------
94
95 // Protected ---------------------------------------------------
96
97 // Private -----------------------------------------------------
98
99 // Inner classes -----------------------------------------------
100 }