APIdia Launch Partner
Top Description Fields Constructors Methods
javax.management

public Class MBeanPermission

extends Permission
Class Inheritance
Annotations
@Deprecated
since:25
forRemoval:true
Imports
java.io.IOException, .ObjectInputStream, java.security.Permission

Deprecated

for removal since 25.

This class was only useful in conjunction with the Security Manager, which is no longer supported. There is no replacement for this class.

Permission controlling access to MBeanServer operations. If a security manager has been set using System#setSecurityManager, 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 interface.

As with other 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 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(). The format of the string is:

className#member[objectName]

The object name is written using the usual syntax for 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.

API Note

This permission cannot be used for controlling access to resources as the Security Manager is no longer supported. Consequently this class is deprecated for removal in a future release.

Since
1.5

Field Summary

Modifier and TypeField and Description
private String
private static final int
private static final int
ALL

All actions.

private transient boolean
classNameExactMatch

True if classNamePrefix must match exactly.

private transient String
classNamePrefix

The classname prefix that must match.

private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private transient int
mask

The actions mask.

private transient String
member

The member that must match.

private static final int
NONE

No actions.

private transient ObjectName
objectName

The objectName that must match.

private static final int
private static final int
private static final int
private static final int
private static final long
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
MBeanPermission(String
the triplet "className#member[objectName]".
name
,
String
the action string.
actions
)

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

public
MBeanPermission(String
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.
className
,
String
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.
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.
objectName
,
String
the action string.
actions
)

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

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if obj is an MBeanPermission, and has the same name and actions as this MBeanPermission object.
equals
(Object
the object we are testing for equality with this object.
obj
)

Implements abstract java.security.Permission.equals.

Checks two MBeanPermission objects for equality.

public String

Returns:

the canonical string representation of the actions.
getActions
()

Implements abstract java.security.Permission.getActions.

Returns the "canonical string representation" of the actions.

private static String
getActions(int mask)

Returns the "canonical string representation" of the actions from the mask.

private static int

Returns:

the action mask.
getMask
(String
the action string.
action
)

Converts an action String to an integer action mask.

public int

Returns:

a hash code value for this object.
hashCode
()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

public boolean

Returns:

true if the specified permission is implied by this object, false if not.
implies
(Permission
the permission to check against.
p
)

Implements abstract java.security.Permission.implies.

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

private void
initName(String className, String member, ObjectName objectName)

Assign fields based on className, member, and objectName parameters.

private static String
makeName(String className, String member, ObjectName objectName)

private void
parseActions()

Parse actions parameter.

private void
parseName()

Parse name parameter.

private void
readObject(ObjectInputStream in)

Deserialize this object based on its name and actions.

private void
setClassName(String className)

private void
setMember(String member)

Inherited from java.security.Permission:
checkGuardgetNamenewPermissionCollectiontoString

Field Detail

actionsback to summary
private String actions
AddNotificationListenerback to summary
private static final int AddNotificationListener

Actions list.

ALLback to summary
private static final int ALL

All actions.

classNameExactMatchback to summary
private transient boolean classNameExactMatch

True if classNamePrefix must match exactly. Otherwise, the className being matched must start with classNamePrefix.

classNamePrefixback to summary
private transient String classNamePrefix

The classname prefix that must match. If null, is implied by any classNamePrefix but does not imply any non-null classNamePrefix.

GetAttributeback to summary
private static final int GetAttribute
GetClassLoaderback to summary
private static final int GetClassLoader
GetClassLoaderForback to summary
private static final int GetClassLoaderFor
GetClassLoaderRepositoryback to summary
private static final int GetClassLoaderRepository
GetDomainsback to summary
private static final int GetDomains
GetMBeanInfoback to summary
private static final int GetMBeanInfo
GetObjectInstanceback to summary
private static final int GetObjectInstance
Instantiateback to summary
private static final int Instantiate
Invokeback to summary
private static final int Invoke
IsInstanceOfback to summary
private static final int IsInstanceOf
maskback to summary
private transient int mask

The actions mask.

memberback to summary
private transient String member

The member that must match. If null, is implied by any member but does not imply any non-null member.

NONEback to summary
private static final int NONE

No actions.

objectNameback to summary
private transient ObjectName objectName

The objectName that must match. If null, is implied by any objectName but does not imply any non-null objectName.

QueryMBeansback to summary
private static final int QueryMBeans
QueryNamesback to summary
private static final int QueryNames
RegisterMBeanback to summary
private static final int RegisterMBean
RemoveNotificationListenerback to summary
private static final int RemoveNotificationListener
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.security.Permission.serialVersionUID.

SetAttributeback to summary
private static final int SetAttribute
UnregisterMBeanback to summary
private static final int UnregisterMBean

Constructor Detail

MBeanPermissionback to summary
public MBeanPermission(String name, 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:String

the triplet "className#member[objectName]".

actions:String

the action string.

Exceptions
IllegalArgumentException:
if the name or actions is invalid.
MBeanPermissionback to summary
public MBeanPermission(String className, String member, ObjectName objectName, 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 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:String

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:String

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: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:String

the action string.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Implements abstract java.security.Permission.equals.

Checks two MBeanPermission objects for equality. Checks that obj is an MBeanPermission, and has the same name and actions as this object.

Parameters
obj:Object

the object we are testing for equality with this object.

Returns:boolean

true if obj is an MBeanPermission, and has the same name and actions as this MBeanPermission object.

getActionsback to summary
public String getActions()

Implements abstract java.security.Permission.getActions.

Returns the "canonical string representation" of the actions. That is, this method always returns present actions in alphabetical order.

Returns:String

the canonical string representation of the actions.

getActionsback to summary
private static String getActions(int mask)

Returns the "canonical string representation" of the actions from the mask.

getMaskback to summary
private static int getMask(String action)

Converts an action String to an integer action mask.

Parameters
action:String

the action string.

Returns:int

the action mask.

hashCodeback to summary
public int hashCode()

Implements abstract java.security.Permission.hashCode.

Returns the hash code value for this object.

Returns:int

a hash code value for this object.

impliesback to summary
public boolean implies(Permission p)

Implements abstract java.security.Permission.implies.

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

More specifically, this method returns true if:

  • p is an instance of MBeanPermission; and
  • p has a null className or p's className matches this object's className; and
  • p has a null member or p's member matches this object's member; and
  • p has a null object name or p's object name matches this object's object name; and
  • p's actions are a subset of this object's actions

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) or if n1.apply(n2).

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

Parameters
p:Permission

the permission to check against.

Returns:boolean

true if the specified permission is implied by this object, false if not.

initNameback to summary
private void initName(String className, String member, ObjectName objectName)

Assign fields based on className, member, and objectName parameters.

makeNameback to summary
private static String makeName(String className, String member, ObjectName objectName)
parseActionsback to summary
private void parseActions()

Parse actions parameter.

parseNameback to summary
private void parseName()

Parse name parameter.

readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Deserialize this object based on its name and actions.

setClassNameback to summary
private void setClassName(String className)
setMemberback to summary
private void setMember(String member)