APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.jmx.remote.security

public Class MBeanServerFileAccessController

extends MBeanServerAccessController
Class Inheritance
Imports
java.io.FileInputStream, .IOException, java.security.Principal, java.util.ArrayList, .HashMap, .List, .Map, .Properties, .Set, .StringTokenizer, java.util.regex.Pattern, javax.management.MBeanServer, .ObjectName, javax.security.auth.Subject

An object of this class implements the MBeanServerAccessController interface and, for each of its methods, calls an appropriate checking method and then forwards the request to a wrapped MBeanServer object. The checking method may throw a SecurityException if the operation is not allowed; in this case the request is not forwarded to the wrapped object.

This class implements the checkRead(), checkWrite(), checkCreate(String), and checkUnregister(ObjectName) methods based on an access level properties file containing username/access level pairs. The set of username/access level pairs is passed either as a filename which denotes a properties file on disk, or directly as an instance of the Properties class. In both cases, the name of each property represents a username, and the value of the property is the associated access level. Thus, any given username either does not exist in the properties or has exactly one access level. The same access level can be shared by several usernames.

The supported access level values are readonly and readwrite. The readwrite access level can be qualified by one or more clauses, where each clause looks like create classNamePattern or unregister. For example:

monitorRole  readonly
controlRole  readwrite \
             create javax.management.timer.*,javax.management.monitor.* \
             unregister

(The continuation lines with \ come from the parser for Properties files.)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static enum
private static class

Field Summary

Modifier and TypeField and Description
private String
private Map<String, MBeanServerFileAccessController.Access>
pack-priv static final String
private Properties
pack-priv static final String
pack-priv static final String
pack-priv static final String

Constructor Summary

AccessConstructor and Description
public
MBeanServerFileAccessController(String
name of the file which denotes a properties file on disk containing the username/access level entries.
accessFileName
)

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the setMBeanServer method after doing access checks based on read and write permissions.

public
MBeanServerFileAccessController(String
name of the file which denotes a properties file on disk containing the username/access level entries.
accessFileName
,
MBeanServer
the MBeanServer object to which requests will be forwarded.
mbs
)

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to mbs after doing access checks based on read and write permissions.

public
MBeanServerFileAccessController(Properties
properties list containing the username/access level entries.
accessFileProps
)

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the setMBeanServer method after doing access checks based on read and write permissions.

public
MBeanServerFileAccessController(Properties
properties list containing the username/access level entries.
accessFileProps
,
MBeanServer
the MBeanServer object to which requests will be forwarded.
mbs
)

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the setMBeanServer method after doing access checks based on read and write permissions.

Method Summary

Modifier and TypeMethod and Description
private synchronized void
public void
checkCreate(String className)

Overrides com.sun.jmx.remote.security.MBeanServerAccessController.checkCreate.

Check if the caller can create MBeans or instances of the given class.

private static boolean
public void
checkRead()

Implements abstract com.sun.jmx.remote.security.MBeanServerAccessController.checkRead.

Check if the caller can do read operations.

public void
checkUnregister(ObjectName name)

Overrides com.sun.jmx.remote.security.MBeanServerAccessController.checkUnregister.

Check if the caller can do unregister operations.

public void
checkWrite()

Implements abstract com.sun.jmx.remote.security.MBeanServerAccessController.checkWrite.

Check if the caller can do write operations.

private static boolean
classNameMatch(String pattern, String className)

private void
private static Properties
public synchronized void
refresh()

Refresh the set of username/access level entries.

Inherited from com.sun.jmx.remote.security.MBeanServerAccessController:
addNotificationListeneraddNotificationListenercreateMBeancreateMBeancreateMBeancreateMBeandeserializedeserializedeserializegetAttributegetAttributesgetClassLoadergetClassLoaderForgetClassLoaderRepositorygetDefaultDomaingetDomainsgetMBeanCountgetMBeanInfogetMBeanServergetObjectInstanceinstantiateinstantiateinstantiateinstantiateinvokeisInstanceOfisRegisteredqueryMBeansqueryNamesregisterMBeanremoveNotificationListenerremoveNotificationListenerremoveNotificationListenerremoveNotificationListenersetAttributesetAttributessetMBeanServerunregisterMBean

Field Detail

accessFileNameback to summary
private String accessFileName
accessMapback to summary
private Map<String, MBeanServerFileAccessController.Access> accessMap
CREATEback to summary
pack-priv static final String CREATE
originalPropsback to summary
private Properties originalProps
READONLYback to summary
pack-priv static final String READONLY
READWRITEback to summary
pack-priv static final String READWRITE
UNREGISTERback to summary
pack-priv static final String UNREGISTER

Constructor Detail

MBeanServerFileAccessControllerback to summary
public MBeanServerFileAccessController(String accessFileName) throws IOException

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the setMBeanServer method after doing access checks based on read and write permissions.

This instance is initialized from the specified properties file.

Parameters
accessFileName:String

name of the file which denotes a properties file on disk containing the username/access level entries.

Exceptions
IOException:
if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
IllegalArgumentException:
if any of the supplied access level values differs from "readonly" or "readwrite".
MBeanServerFileAccessControllerback to summary
public MBeanServerFileAccessController(String accessFileName, MBeanServer mbs) throws IOException

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to mbs after doing access checks based on read and write permissions.

This instance is initialized from the specified properties file.

Parameters
accessFileName:String

name of the file which denotes a properties file on disk containing the username/access level entries.

mbs:MBeanServer

the MBeanServer object to which requests will be forwarded.

Exceptions
IOException:
if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
IllegalArgumentException:
if any of the supplied access level values differs from "readonly" or "readwrite".
MBeanServerFileAccessControllerback to summary
public MBeanServerFileAccessController(Properties accessFileProps) throws IOException

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the setMBeanServer method after doing access checks based on read and write permissions.

This instance is initialized from the specified properties instance. This constructor makes a copy of the properties instance and it is the copy that is consulted to check the username and access level of an incoming connection. The original properties object can be modified without affecting the copy. If the refresh method is then called, the MBeanServerFileAccessController will make a new copy of the properties object at that time.

Parameters
accessFileProps:Properties

properties list containing the username/access level entries.

Exceptions
IllegalArgumentException:
if accessFileProps is null or if any of the supplied access level values differs from "readonly" or "readwrite".
MBeanServerFileAccessControllerback to summary
public MBeanServerFileAccessController(Properties accessFileProps, MBeanServer mbs) throws IOException

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the setMBeanServer method after doing access checks based on read and write permissions.

This instance is initialized from the specified properties instance. This constructor makes a copy of the properties instance and it is the copy that is consulted to check the username and access level of an incoming connection. The original properties object can be modified without affecting the copy. If the refresh method is then called, the MBeanServerFileAccessController will make a new copy of the properties object at that time.

Parameters
accessFileProps:Properties

properties list containing the username/access level entries.

mbs:MBeanServer

the MBeanServer object to which requests will be forwarded.

Exceptions
IllegalArgumentException:
if accessFileProps is null or if any of the supplied access level values differs from "readonly" or "readwrite".

Method Detail

checkAccessback to summary
private synchronized void checkAccess(MBeanServerFileAccessController.AccessType requiredAccess, String arg)
checkCreateback to summary
public void checkCreate(String className)

Overrides com.sun.jmx.remote.security.MBeanServerAccessController.checkCreate.

Check if the caller can create MBeans or instances of the given class. This method does nothing if so, otherwise throws SecurityException.

Annotations
@Override
checkCreateAccessback to summary
private static boolean checkCreateAccess(MBeanServerFileAccessController.Access access, String className)
checkReadback to summary
public void checkRead()

Implements abstract com.sun.jmx.remote.security.MBeanServerAccessController.checkRead.

Check if the caller can do read operations. This method does nothing if so, otherwise throws SecurityException.

Annotations
@Override
checkUnregisterback to summary
public void checkUnregister(ObjectName name)

Overrides com.sun.jmx.remote.security.MBeanServerAccessController.checkUnregister.

Check if the caller can do unregister operations. This method does nothing if so, otherwise throws SecurityException.

Annotations
@Override
checkWriteback to summary
public void checkWrite()

Implements abstract com.sun.jmx.remote.security.MBeanServerAccessController.checkWrite.

Check if the caller can do write operations. This method does nothing if so, otherwise throws SecurityException.

Annotations
@Override
classNameMatchback to summary
private static boolean classNameMatch(String pattern, String className)
parsePropertiesback to summary
private void parseProperties(Properties props)
propertiesFromFileback to summary
private static Properties propertiesFromFile(String fname) throws IOException
refreshback to summary
public synchronized void refresh() throws IOException

Refresh the set of username/access level entries.

If this instance was created using the MBeanServerFileAccessController(String) or MBeanServerFileAccessController(String, MBeanServer) constructors to specify a file from which the entries are read, the file is re-read.

If this instance was created using the MBeanServerFileAccessController(Properties) or MBeanServerFileAccessController(Properties, MBeanServer) constructors then a new copy of the Properties object is made.

Exceptions
IOException:
if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
IllegalArgumentException:
if any of the supplied access level values differs from "readonly" or "readwrite".
com.sun.jmx.remote.security back to summary

private Class MBeanServerFileAccessController.Access

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.jmx.remote.security.MBeanServerFileAccessController.Access

Field Summary

Modifier and TypeField and Description
pack-priv final String[]
private final String[]
private boolean
pack-priv final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
Access(boolean write, boolean unregister, List<String> createPatternList)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

createPatternsback to summary
pack-priv final String[] createPatterns
NO_STRINGSback to summary
private final String[] NO_STRINGS
unregisterback to summary
private boolean unregister
writeback to summary
pack-priv final boolean write

Constructor Detail

Accessback to summary
pack-priv Access(boolean write, boolean unregister, List<String> createPatternList)
com.sun.jmx.remote.security back to summary

private final Enum MBeanServerFileAccessController.AccessType

extends Enum<MBeanServerFileAccessController.AccessType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final MBeanServerFileAccessController.AccessType
public static final MBeanServerFileAccessController.AccessType
public static final MBeanServerFileAccessController.AccessType
public static final MBeanServerFileAccessController.AccessType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static MBeanServerFileAccessController.AccessType
public static MBeanServerFileAccessController.AccessType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CREATEback to summary
public static final MBeanServerFileAccessController.AccessType CREATE
READback to summary
public static final MBeanServerFileAccessController.AccessType READ
UNREGISTERback to summary
public static final MBeanServerFileAccessController.AccessType UNREGISTER
WRITEback to summary
public static final MBeanServerFileAccessController.AccessType WRITE

Constructor Detail

AccessTypeback to summary
private AccessType()

Method Detail

valueOfback to summary
public static MBeanServerFileAccessController.AccessType valueOf(String name)
valuesback to summary
public static MBeanServerFileAccessController.AccessType[] values()
com.sun.jmx.remote.security back to summary

private Class MBeanServerFileAccessController.Parser

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.jmx.remote.security.MBeanServerFileAccessController.Parser

Field Summary

Modifier and TypeField and Description
private int
c

private static final int
private int
i

private final String
private final int
private final String
s

Constructor Summary

AccessConstructor and Description
private
Parser(String identity, String s)

Method Summary

Modifier and TypeMethod and Description
private void
next()

pack-priv static MBeanServerFileAccessController.Access
parseAccess(String identity, String s)

private MBeanServerFileAccessController.Access
private String
private void
parseCreate(List<String> createClasses)

private MBeanServerFileAccessController.Access
private String
private void
private IllegalArgumentException
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cback to summary
private int c
EOSback to summary
private static final int EOS
iback to summary
private int i
identityback to summary
private final String identity
lenback to summary
private final int len
sback to summary
private final String s

Constructor Detail

Parserback to summary
private Parser(String identity, String s)

Method Detail

nextback to summary
private void next()
parseAccessback to summary
pack-priv static MBeanServerFileAccessController.Access parseAccess(String identity, String s)
parseAccessback to summary
private MBeanServerFileAccessController.Access parseAccess()
parseClassNameback to summary
private String parseClassName()
parseCreateback to summary
private void parseCreate(List<String> createClasses)
parseReadWriteback to summary
private MBeanServerFileAccessController.Access parseReadWrite()
parseWordback to summary
private String parseWord()
skipSpaceback to summary
private void skipSpace()
syntaxback to summary
private IllegalArgumentException syntax(String msg)