01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package javax.management;
23:
24: import java.security.BasicPermission;
25:
26: /** This permission represents "trust" in a signer or codebase.
27: *
28: * MBeanTrustPermission contains a target name but no actions list. A single
29: * target name, "register", is defined for this permission. The target "*" is
30: * also allowed, permitting "register" and any future targets that may be
31: * defined. Only the null value or the empty string are allowed for the action
32: * to allow the policy object to create the permissions specified in the policy
33: * file.
34: *
35: * If a signer, or codesource is granted this permission, then it is considered
36: * a trusted source for MBeans. Only MBeans from trusted sources may be
37: * registered in the MBeanServer.
38: *
39: * @author Scott.Stark@jboss.org
40: * @version $Revision: 57200 $
41: */
42: public class MBeanTrustPermission extends BasicPermission {
43: private static final long serialVersionUID = -2952178077029018140L;
44:
45: /** Create a new MBeanTrustPermission with the given name.
46: *
47: * @param name
48: * @throws IllegalArgumentException
49: * @throws NullPointerException
50: */
51: public MBeanTrustPermission(String name)
52: throws IllegalArgumentException, NullPointerException {
53: this (name, null);
54: }
55:
56: /** Create a new MBeanTrustPermission with the given name and actions.
57: *
58: * @param name
59: * @throws IllegalArgumentException - if the name is neither "register" nor
60: * "*"; or if actions is a non-null non-empty string.
61: * @throws NullPointerException - if the name is null.
62: */
63: public MBeanTrustPermission(String name, String actions)
64: throws IllegalArgumentException, NullPointerException {
65: super (name, actions);
66: if (name == null)
67: throw new NullPointerException("name cannot be null");
68: if (name.equals("register") == false
69: && name.equals("*") == false)
70: throw new IllegalArgumentException(
71: "name must be 'register' or '*'");
72: if (actions != null && actions.length() > 0)
73: throw new IllegalArgumentException(
74: "actions must be null or ''");
75: }
76:
77: }
|