blob: 6e44efd1234719cdf6edd97c62a056f9dfda3d02 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package javax.management;
27
28import java.security.BasicPermission;
29
30/**
31 * This permission represents "trust" in a signer or codebase.
32 * <p>
33 * MBeanTrustPermission contains a target name but no actions list.
34 * A single target name, "register", is defined for this permission.
35 * The target "*" is also allowed, permitting "register" and any future
36 * targets that may be defined.
37 * Only the null value or the empty string are allowed for the action
38 * to allow the policy object to create the permissions specified in
39 * the policy file.
40 * <p>
41 * If a signer, or codesource is granted this permission, then it is
42 * considered a trusted source for MBeans. Only MBeans from trusted
43 * sources may be registered in the MBeanServer.
44 *
45 * @since 1.5
46 */
47public class MBeanTrustPermission extends BasicPermission {
48
49 private static final long serialVersionUID = -2952178077029018140L;
50
51 /** <p>Create a new MBeanTrustPermission with the given name.</p>
52 <p>This constructor is equivalent to
53 <code>MBeanTrustPermission(name,null)</code>.</p>
54 @param name the name of the permission. It must be
55 "register" or "*" for this permission.
56 *
57 * @throws NullPointerException if <code>name</code> is <code>null</code>.
58 * @throws IllegalArgumentException if <code>name</code> is neither
59 * "register" nor "*".
60 */
61 public MBeanTrustPermission(String name) {
62 this(name, null);
63 }
64
65 /** <p>Create a new MBeanTrustPermission with the given name.</p>
66 @param name the name of the permission. It must be
67 "register" or "*" for this permission.
68 @param actions the actions for the permission. It must be
69 null or <code>""</code>.
70 *
71 * @throws NullPointerException if <code>name</code> is <code>null</code>.
72 * @throws IllegalArgumentException if <code>name</code> is neither
73 * "register" nor "*"; or if <code>actions</code> is a non-null
74 * non-empty string.
75 */
76 public MBeanTrustPermission(String name, String actions) {
77 super(name, actions);
78 /* Check that actions is a null empty string */
79 if (actions != null && actions.length() > 0)
80 throw new IllegalArgumentException("MBeanTrustPermission " +
81 "actions must be null: " +
82 actions);
83
84 if (!name.equals("register") && !name.equals("*"))
85 throw new IllegalArgumentException("MBeanTrustPermission: " +
86 "Unknown target name " +
87 "[" + name + "]");
88 }
89}