javax.management
Class MBeanPermission

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.security.Permission sample code for java.security.Permission definition code for java.security.Permission 
      extended by javax.management.MBeanPermission
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Guard sample code for java.security.Guard definition code for java.security.Guard

public class MBeanPermission
extends Permission sample code for java.security.Permission definition code for java.security.Permission

Permission controlling access to MBeanServer operations. If a security manager has been set using System.setSecurityManager(java.lang.SecurityManager) sample code for java.lang.System.setSecurityManager(java.lang.SecurityManager) definition code for java.lang.System.setSecurityManager(java.lang.SecurityManager) , most operations on the MBean Server require that the caller's permissions imply an MBeanPermission appropriate for the operation. This is described in detail in the documentation for the MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer interface.

As with other Permission sample code for java.security.Permission definition code for java.security.Permission objects, an MBeanPermission can represent either a permission that you have or a permission that you need. When a sensitive operation is being checked for permission, an MBeanPermission is constructed representing the permission you need. The operation is only allowed if the permissions you have imply sample code for javax.management.MBeanPermission.implies(java.security.Permission) definition code for javax.management.MBeanPermission.implies(java.security.Permission) the permission you need.

An MBeanPermission contains four items of information:

If you have an MBeanPermission, it allows operations only if all four of the items match.

The class name, member, and object name can be written together as a single string, which is the name of this permission. The name of the permission is the string returned by getName() sample code for java.security.Permission.getName() definition code for java.security.Permission.getName() . The format of the string is:

className#member[objectName]

The object name is written using the usual syntax for ObjectName sample code for javax.management.ObjectName definition code for javax.management.ObjectName . It may contain any legal characters, including ]. It is terminated by a ] character that is the last character in the string.

One or more of the className, member, or objectName may be omitted. If the member is omitted, the # may be too (but does not have to be). If the objectName is omitted, the [] may be too (but does not have to be). It is not legal to omit all three items, that is to have a name that is the empty string.

One or more of the className, member, or objectName may be the character "-", which is equivalent to a null value. A null value is implied by any value (including another null value) but does not imply any other value.

The possible actions are these:

In a comma-separated list of actions, spaces are allowed before and after each action.

Since:
1.5
See Also:
Serialized Form

Constructor Summary
MBeanPermission sample code for javax.management.MBeanPermission.MBeanPermission(java.lang.String, java.lang.String) definition code for javax.management.MBeanPermission.MBeanPermission(java.lang.String, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name, String sample code for java.lang.String definition code for java.lang.String  actions)
          Create a new MBeanPermission object with the specified target name and actions.
MBeanPermission sample code for javax.management.MBeanPermission.MBeanPermission(java.lang.String, java.lang.String, javax.management.ObjectName, java.lang.String) definition code for javax.management.MBeanPermission.MBeanPermission(java.lang.String, java.lang.String, javax.management.ObjectName, java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  className, String sample code for java.lang.String definition code for java.lang.String  member, ObjectName sample code for javax.management.ObjectName definition code for javax.management.ObjectName  objectName, String sample code for java.lang.String definition code for java.lang.String  actions)
          Create a new MBeanPermission object with the specified target name (class name, member, object name) and actions.
 
Method Summary
 boolean equals sample code for javax.management.MBeanPermission.equals(java.lang.Object) definition code for javax.management.MBeanPermission.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Checks two MBeanPermission objects for equality.
 String sample code for java.lang.String definition code for java.lang.String getActions sample code for javax.management.MBeanPermission.getActions() definition code for javax.management.MBeanPermission.getActions() ()
          Returns the "canonical string representation" of the actions.
 int hashCode sample code for javax.management.MBeanPermission.hashCode() definition code for javax.management.MBeanPermission.hashCode() ()
          Returns the hash code value for this object.
 boolean implies sample code for javax.management.MBeanPermission.implies(java.security.Permission) definition code for javax.management.MBeanPermission.implies(java.security.Permission) (Permission sample code for java.security.Permission definition code for java.security.Permission  p)
          Checks if this MBeanPermission object "implies" the specified permission.
 
Methods inherited from class java.security.Permission sample code for java.security.Permission definition code for java.security.Permission
checkGuard sample code for java.security.Permission.checkGuard(java.lang.Object) definition code for java.security.Permission.checkGuard(java.lang.Object) , getName sample code for java.security.Permission.getName() definition code for java.security.Permission.getName() , newPermissionCollection sample code for java.security.Permission.newPermissionCollection() definition code for java.security.Permission.newPermissionCollection() , toString sample code for java.security.Permission.toString() definition code for java.security.Permission.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

MBeanPermission sample code for javax.management.MBeanPermission(java.lang.String, java.lang.String) definition code for javax.management.MBeanPermission(java.lang.String, java.lang.String)

public MBeanPermission(String sample code for java.lang.String definition code for java.lang.String  name,
                       String sample code for java.lang.String definition code for java.lang.String  actions)

Create a new MBeanPermission object with the specified target name and actions.

The target name is of the form "className#member[objectName]" where each part is optional. It must not be empty or null.

The actions parameter contains a comma-separated list of the desired actions granted on the target name. It must not be empty or null.

Parameters:
name - the triplet "className#member[objectName]".
actions - the action string.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the name or actions is invalid.

MBeanPermission sample code for javax.management.MBeanPermission(java.lang.String, java.lang.String, javax.management.ObjectName, java.lang.String) definition code for javax.management.MBeanPermission(java.lang.String, java.lang.String, javax.management.ObjectName, java.lang.String)

public MBeanPermission(String sample code for java.lang.String definition code for java.lang.String  className,
                       String sample code for java.lang.String definition code for java.lang.String  member,
                       ObjectName sample code for javax.management.ObjectName definition code for javax.management.ObjectName  objectName,
                       String sample code for java.lang.String definition code for java.lang.String  actions)

Create a new MBeanPermission object with the specified target name (class name, member, object name) and actions.

The class name, member and object name parameters define a target name of the form "className#member[objectName]" where each part is optional. This will be the result of Permission.getName() sample code for java.security.Permission.getName() definition code for java.security.Permission.getName() on the resultant MBeanPermission.

The actions parameter contains a comma-separated list of the desired actions granted on the target name. It must not be empty or null.

Parameters:
className - the class name to which this permission applies. May be null or "-", which represents a class name that is implied by any class name but does not imply any other class name.
member - the member to which this permission applies. May be null or "-", which represents a member that is implied by any member but does not imply any other member.
objectName - the object name to which this permission applies. May be null, which represents an object name that is implied by any object name but does not imply any other object name.
actions - the action string.
Method Detail

getActions sample code for javax.management.MBeanPermission.getActions() definition code for javax.management.MBeanPermission.getActions()

public String sample code for java.lang.String definition code for java.lang.String  getActions()
Returns the "canonical string representation" of the actions. That is, this method always returns present actions in alphabetical order.

Specified by:
getActions sample code for java.security.Permission.getActions() definition code for java.security.Permission.getActions() in class Permission sample code for java.security.Permission definition code for java.security.Permission
Returns:
the canonical string representation of the actions.

hashCode sample code for javax.management.MBeanPermission.hashCode() definition code for javax.management.MBeanPermission.hashCode()

public int hashCode()
Returns the hash code value for this object.

Specified by:
hashCode sample code for java.security.Permission.hashCode() definition code for java.security.Permission.hashCode() in class Permission sample code for java.security.Permission definition code for java.security.Permission
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

implies sample code for javax.management.MBeanPermission.implies(java.security.Permission) definition code for javax.management.MBeanPermission.implies(java.security.Permission)

public boolean implies(Permission sample code for java.security.Permission definition code for java.security.Permission  p)

Checks if this MBeanPermission object "implies" the specified permission.

More specifically, this method returns true if:

If this object's className is "*", p's className always matches it. If it is "a.*", p's className matches it if it begins with "a.".

If this object's member is "*", p's member always matches it.

If this object's objectName n1 is an object name pattern, p's objectName n2 matches it if n1.equals(n2) sample code for javax.management.ObjectName.equals(java.lang.Object) definition code for javax.management.ObjectName.equals(java.lang.Object) or if n1.apply(n2) sample code for javax.management.ObjectName.apply(javax.management.ObjectName) definition code for javax.management.ObjectName.apply(javax.management.ObjectName) .

A permission that includes the queryMBeans action is considered to include queryNames as well.

Specified by:
implies sample code for java.security.Permission.implies(java.security.Permission) definition code for java.security.Permission.implies(java.security.Permission) in class Permission sample code for java.security.Permission definition code for java.security.Permission
Parameters:
p - the permission to check against.
Returns:
true if the specified permission is implied by this object, false if not.

equals sample code for javax.management.MBeanPermission.equals(java.lang.Object) definition code for javax.management.MBeanPermission.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Checks two MBeanPermission objects for equality. Checks that obj is an MBeanPermission, and has the same name and actions as this object.

Specified by:
equals sample code for java.security.Permission.equals(java.lang.Object) definition code for java.security.Permission.equals(java.lang.Object) in class Permission sample code for java.security.Permission definition code for java.security.Permission
Parameters:
obj - the object we are testing for equality with this object.
Returns:
true if obj is an MBeanPermission, and has the same name and actions as this MBeanPermission object.
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable