com.sun.jmx.remote.opt.security
Class MBeanServerFileAccessController

java.lang.Object
  extended by com.sun.jmx.remote.opt.security.MBeanServerAccessController
      extended by com.sun.jmx.remote.opt.security.MBeanServerFileAccessController
All Implemented Interfaces:
MBeanServer, MBeanServerConnection, MBeanServerForwarder

public class MBeanServerFileAccessController
extends MBeanServerAccessController

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() and checkWrite() 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.


Field Summary
static String READONLY
           
static String READWRITE
           
 
Constructor Summary
MBeanServerFileAccessController(Properties accessFileProps)
          Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the MBeanServerAccessController.setMBeanServer(javax.management.MBeanServer) method after doing access checks based on read and write permissions.
MBeanServerFileAccessController(Properties accessFileProps, MBeanServer mbs)
          Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the MBeanServerAccessController.setMBeanServer(javax.management.MBeanServer) method after doing access checks based on read and write permissions.
MBeanServerFileAccessController(String accessFileName)
          Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the MBeanServerAccessController.setMBeanServer(javax.management.MBeanServer) method after doing access checks based on read and write permissions.
MBeanServerFileAccessController(String accessFileName, MBeanServer mbs)
          Create a new MBeanServerAccessController that forwards all the MBeanServer requests to mbs after doing access checks based on read and write permissions.
 
Method Summary
 void checkRead()
          Check if the caller can do read operations.
 void checkWrite()
          Check if the caller can do write operations.
 void refresh()
          Refresh the set of username/access level entries.
 
Methods inherited from class com.sun.jmx.remote.opt.security.MBeanServerAccessController
addNotificationListener, addNotificationListener, createMBean, createMBean, createMBean, createMBean, deserialize, deserialize, deserialize, getAttribute, getAttributes, getClassLoader, getClassLoaderFor, getClassLoaderRepository, getDefaultDomain, getDomains, getMBeanCount, getMBeanInfo, getMBeanServer, getObjectInstance, instantiate, instantiate, instantiate, instantiate, invoke, isInstanceOf, isRegistered, queryMBeans, queryNames, registerMBean, removeNotificationListener, removeNotificationListener, removeNotificationListener, removeNotificationListener, setAttribute, setAttributes, setMBeanServer, unregisterMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READONLY

public static final String READONLY
See Also:
Constant Field Values

READWRITE

public static final String READWRITE
See Also:
Constant Field Values
Constructor Detail

MBeanServerFileAccessController

public MBeanServerFileAccessController(String accessFileName)
                                throws IOException

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

This instance is initialized from the specified properties file.

Parameters:
accessFileName - name of the file which denotes a properties file on disk containing the username/access level entries.
Throws:
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".

MBeanServerFileAccessController

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 - name of the file which denotes a properties file on disk containing the username/access level entries.
mbs - the MBeanServer object to which requests will be forwarded.
Throws:
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".

MBeanServerFileAccessController

public MBeanServerFileAccessController(Properties accessFileProps)
                                throws IOException

Create a new MBeanServerAccessController that forwards all the MBeanServer requests to the MBeanServer set by invoking the MBeanServerAccessController.setMBeanServer(javax.management.MBeanServer) 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 using its clone method 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 list containing the username/access level entries.
Throws:
IllegalArgumentException - if accessFileProps is null or if any of the supplied access level values differs from "readonly" or "readwrite".
IOException

MBeanServerFileAccessController

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 MBeanServerAccessController.setMBeanServer(javax.management.MBeanServer) 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 using its clone method 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 list containing the username/access level entries.
mbs - the MBeanServer object to which requests will be forwarded.
Throws:
IllegalArgumentException - if accessFileProps is null or if any of the supplied access level values differs from "readonly" or "readwrite".
IOException
Method Detail

checkRead

public void checkRead()
Check if the caller can do read operations. This method does nothing if so, otherwise throws SecurityException.

Specified by:
checkRead in class MBeanServerAccessController

checkWrite

public void checkWrite()
Check if the caller can do write operations. This method does nothing if so, otherwise throws SecurityException.

Specified by:
checkWrite in class MBeanServerAccessController

refresh

public 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.

Throws:
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".


Copyright © 2014 Terracotta, Inc.. All rights reserved.