javax.management
Class MBeanPermission

java.lang.Object
  extended by java.security.Permission
      extended by javax.management.MBeanPermission
All Implemented Interfaces:
Serializable, Guard

public class MBeanPermission
extends Permission

Represents the permissions required to perform operations using the MBeanServer. As with all Permission objects, an instance of this class either represents a permission already held or one that is required to access a particular service. In the case of MBeanPermissions, implication checks are made using an instance of this class when a user requests an operation from the server, and a SecurityManager is in place.

An MBeanPermission consists of four elements, which all have to match for the permission to be implied. These are as follows:

  1. The action. For a required permission, this is a single value. For a permission held by the user, this is a list of comma-separated actions (with spaces allowed), or * (representing all actions). getActions() returns this value.
  2. The class name. For a required permission, this is the class name of the bean being accessed, if any. If a bean isn't involved in this action, the value is null. For a permission held by the user, it has one of three values:
    1. The empty string, implying any class.
    2. *, also implying any class.
    3. A class name pattern, which may specify a single class (e.g. java.lang.Object) or a series of classes using the wildcard character * (e.g. javax.swing.*.)
  3. The member. For a required permission, this is the member of the bean being accessed (an attribute or operation), if any. If a member of the bean isn't involved in this action, the value is null. For a permission held by the user, it has one of three values:
    1. The empty string, implying any member.
    2. *, also implying any member.
    3. The name of a member.
  4. The object name. For a required permission, this is the ObjectName of the bean being accessed, if any. If a bean isn't involved in this action, the value is null. The name may not be a pattern. For a permission held by the user, it may be the empty string (allowing everything) or an ObjectName pattern.
Permission.getName() returns the latter three of these as a single string:

className#member[objectName]

where "" is disallowed, as, although any of the elements may be omitted, not all of them should be left out simultaneously. "-" is used to represent null. When this occurs in a required permission, anything may match it. When this forms part of a permission held by the user, it only matches another null value.

The list of valid actions is as follows:

Since:
1.5
See Also:
Serialized Form

Constructor Summary
MBeanPermission(String name, String actions)
          Constructs a new MBeanPermission with the specified name and actions.
MBeanPermission(String className, String member, ObjectName name, String actions)
          Constructs a new MBeanPermission with the specified class name, member, object name and actions.
 
Method Summary
 boolean equals(Object obj)
          Returns true if the given object is also an MBeanPermission with the same name and actions.
 String getActions()
          Returns the list of actions in alphabetical order.
 int hashCode()
          Returns the hashcode of the permission as the sum of the hashcodes of the name and actions.
 boolean implies(Permission p)
           Returns true if this permission implies the supplied permission.
 
Methods inherited from class java.security.Permission
checkGuard, getName, newPermissionCollection, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MBeanPermission

public MBeanPermission(String name,
                       String actions)
Constructs a new MBeanPermission with the specified name and actions. The name is of the form className#member[objectName], where each element is optional, but a completely empty or null name is disallowed. Actions are specified as a comma-separated list and may also not be empty or null.

Parameters:
name - the name of the permission.
actions - the actions associated with this permission.
Throws:
IllegalArgumentException - if the name or actions are invalid.

MBeanPermission

public MBeanPermission(String className,
                       String member,
                       ObjectName name,
                       String actions)
Constructs a new MBeanPermission with the specified class name, member, object name and actions. The name of the permission is created using the form className#member[objectName], where each element is optional, but an empty or null name is disallowed. Actions are specified as a comma-separated list and may also not be empty or null.

Parameters:
className - the name of the class to which this permission applies, or either null or "-" for a value which may be implied by any class name, but not imply any class name itself.
member - the member of the class to which this permission applies, or either null or "-" for a value which may be implied by any member, but not imply any member itself.
name - the ObjectName to which this permission applies, or null for a value which may be implied by any object name, but not imply any object name itself.
actions - the actions associated with this permission.
Method Detail

equals

public boolean equals(Object obj)
Returns true if the given object is also an MBeanPermission with the same name and actions.

Specified by:
equals in class Permission
Parameters:
obj - the object to test.
Returns:
true if the object is an MBeanPermission with the same name and actions.
See Also:
Object.hashCode()

getActions

public String getActions()
Returns the list of actions in alphabetical order.

Specified by:
getActions in class Permission
Returns:
the list of actions.

hashCode

public int hashCode()
Returns the hashcode of the permission as the sum of the hashcodes of the name and actions.

Specified by:
hashCode in class Permission
Returns:
the hashcode of the permission.
See Also:
Object.equals(Object), System.identityHashCode(Object)

implies

public boolean implies(Permission p)

Returns true if this permission implies the supplied permission. This happens if the following holds:

Specified by:
implies in class Permission
Parameters:
p - the permission to check that this permission implies.
Returns:
true if this permission implies p.