KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > MBeanTrustPermission


1 /*
2  * @(#)MBeanTrustPermission.java 1.15 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 javax.management;
9
10 import java.security.BasicPermission JavaDoc;
11
12 /**
13  * This permission represents "trust" in a signer or codebase.
14  * <p>
15  * MBeanTrustPermission contains a target name but no actions list.
16  * A single target name, "register", is defined for this permission.
17  * The target "*" is also allowed, permitting "register" and any future
18  * targets that may be defined.
19  * Only the null value or the empty string are allowed for the action
20  * to allow the policy object to create the permissions specified in
21  * the policy file.
22  * <p>
23  * If a signer, or codesource is granted this permission, then it is
24  * considered a trusted source for MBeans. Only MBeans from trusted
25  * sources may be registered in the MBeanServer.
26  *
27  * @since 1.5
28  * @since.unbundled JMX 1.2
29  */

30 public class MBeanTrustPermission extends BasicPermission JavaDoc {
31
32     private static final long serialVersionUID = -2952178077029018140L;
33
34     /** <p>Create a new MBeanTrustPermission with the given name.</p>
35     <p>This constructor is equivalent to
36     <code>MBeanTrustPermission(name,null)</code>.</p>
37     @param name the name of the permission. It must be
38     "register" or "*" for this permission.
39     @exception NullPointerException if the name is null.
40     @exception IllegalArgumentException if the name is neither
41     "register" nor "*".
42     */

43     public MBeanTrustPermission(String JavaDoc name) {
44         this(name, null);
45     }
46
47     /** <p>Create a new MBeanTrustPermission with the given name.</p>
48     @param name the name of the permission. It must be
49     "register" or "*" for this permission.
50     @param actions the actions for the permission. It must be
51     null or <code>""</code>.
52     @exception NullPointerException if the name is null.
53     @exception IllegalArgumentException if the name is neither
54     "register" nor "*"; or if <code>actions</code> is a non-null
55     non-empty string.
56     */

57     public MBeanTrustPermission(String JavaDoc name, String JavaDoc actions) {
58         super(name, actions);
59     /* Check that actions is a null empty string */
60     if (actions != null && actions.length() > 0)
61         throw new IllegalArgumentException JavaDoc("MBeanTrustPermission " +
62                            "actions must be null: " +
63                            actions);
64
65         if (!name.equals("register") && !name.equals("*"))
66             throw new IllegalArgumentException JavaDoc("MBeanTrustPermission: " +
67                            "Unknown target name " +
68                                                "[" + name + "]");
69     }
70 }
71
Popular Tags