public abstract class MBeanServerAccessController extends Object implements MBeanServerForwarder
An object of this class implements the MBeanServer 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 RuntimeException if the operation is not allowed; in this case the request is not forwarded to the wrapped object.
A typical use of this class is to insert it between a connector server
such as the RMI connector and the MBeanServer with which the connector
is associated. Requests from the connector client can then be filtered
and those operations that are not allowed, or not allowed in a particular
context, can be rejected by throwing a SecurityException
in the corresponding check* method.
This is an abstract class, because in its implementation none of the checking methods does anything. To be useful, it must be subclassed and at least one of the checking methods overridden to do some checking. Some or all of the MBeanServer methods may also be overridden, for instance if the default checking behaviour is inappropriate.
If there is no SecurityManager, then the access controller will refuse to create an MBean that is a ClassLoader, which includes MLets, or to execute the method addURL on an MBean that is an MLet. This prevents people from opening security holes unintentionally. Otherwise, it would not be obvious that granting write access grants the ability to download and execute arbitrary code in the target MBean server. Advanced users who do want the ability to use MLets are presumably advanced enough to handle policy files and security managers.
| Constructor and Description |
|---|
MBeanServerAccessController() |
| Modifier and Type | Method and Description |
|---|---|
void |
addNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
Call
checkRead(), then forward this method to the
wrapped object. |
void |
addNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback)
Call
checkRead(), then forward this method to the
wrapped object. |
protected abstract void |
checkRead()
Check if the caller can do read operations.
|
protected abstract void |
checkWrite()
Check if the caller can do write operations.
|
ObjectInstance |
createMBean(String className,
ObjectName name)
Call
checkWrite(), then forward this method to the
wrapped object. |
ObjectInstance |
createMBean(String className,
ObjectName name,
Object[] params,
String[] signature)
Call
checkWrite(), then forward this method to the
wrapped object. |
ObjectInstance |
createMBean(String className,
ObjectName name,
ObjectName loaderName)
Call
checkWrite(), then forward this method to the
wrapped object. |
ObjectInstance |
createMBean(String className,
ObjectName name,
ObjectName loaderName,
Object[] params,
String[] signature)
Call
checkWrite(), then forward this method to the
wrapped object. |
ObjectInputStream |
deserialize(ObjectName name,
byte[] data)
Call
checkRead(), then forward this method to the
wrapped object. |
ObjectInputStream |
deserialize(String className,
byte[] data)
Call
checkRead(), then forward this method to the
wrapped object. |
ObjectInputStream |
deserialize(String className,
ObjectName loaderName,
byte[] data)
Call
checkRead(), then forward this method to the
wrapped object. |
Object |
getAttribute(ObjectName name,
String attribute)
Call
checkRead(), then forward this method to the
wrapped object. |
AttributeList |
getAttributes(ObjectName name,
String[] attributes)
Call
checkRead(), then forward this method to the
wrapped object. |
ClassLoader |
getClassLoader(ObjectName loaderName)
Call
checkRead(), then forward this method to the
wrapped object. |
ClassLoader |
getClassLoaderFor(ObjectName mbeanName)
Call
checkRead(), then forward this method to the
wrapped object. |
ClassLoaderRepository |
getClassLoaderRepository()
Call
checkRead(), then forward this method to the
wrapped object. |
String |
getDefaultDomain()
Call
checkRead(), then forward this method to the
wrapped object. |
String[] |
getDomains()
Call
checkRead(), then forward this method to the
wrapped object. |
Integer |
getMBeanCount()
Call
checkRead(), then forward this method to the
wrapped object. |
MBeanInfo |
getMBeanInfo(ObjectName name)
Call
checkRead(), then forward this method to the
wrapped object. |
MBeanServer |
getMBeanServer() |
ObjectInstance |
getObjectInstance(ObjectName name)
Call
checkRead(), then forward this method to the
wrapped object. |
Object |
instantiate(String className)
Call
checkWrite(), then forward this method to the
wrapped object. |
Object |
instantiate(String className,
Object[] params,
String[] signature)
Call
checkWrite(), then forward this method to the
wrapped object. |
Object |
instantiate(String className,
ObjectName loaderName)
Call
checkWrite(), then forward this method to the
wrapped object. |
Object |
instantiate(String className,
ObjectName loaderName,
Object[] params,
String[] signature)
Call
checkWrite(), then forward this method to the
wrapped object. |
Object |
invoke(ObjectName name,
String operationName,
Object[] params,
String[] signature)
Call
checkWrite(), then forward this method to the
wrapped object. |
boolean |
isInstanceOf(ObjectName name,
String className)
Call
checkRead(), then forward this method to the
wrapped object. |
boolean |
isRegistered(ObjectName name)
Call
checkRead(), then forward this method to the
wrapped object. |
Set |
queryMBeans(ObjectName name,
QueryExp query)
Call
checkRead(), then forward this method to the
wrapped object. |
Set |
queryNames(ObjectName name,
QueryExp query)
Call
checkRead(), then forward this method to the
wrapped object. |
ObjectInstance |
registerMBean(Object object,
ObjectName name)
Call
checkWrite(), then forward this method to the
wrapped object. |
void |
removeNotificationListener(ObjectName name,
NotificationListener listener)
Call
checkRead(), then forward this method to the
wrapped object. |
void |
removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
Call
checkRead(), then forward this method to the
wrapped object. |
void |
removeNotificationListener(ObjectName name,
ObjectName listener)
Call
checkRead(), then forward this method to the
wrapped object. |
void |
removeNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback)
Call
checkRead(), then forward this method to the
wrapped object. |
void |
setAttribute(ObjectName name,
Attribute attribute)
Call
checkWrite(), then forward this method to the
wrapped object. |
AttributeList |
setAttributes(ObjectName name,
AttributeList attributes)
Call
checkWrite(), then forward this method to the
wrapped object. |
void |
setMBeanServer(MBeanServer mbs) |
void |
unregisterMBean(ObjectName name)
Call
checkWrite(), then forward this method to the
wrapped object. |
public MBeanServer getMBeanServer()
getMBeanServer in interface MBeanServerForwarderpublic void setMBeanServer(MBeanServer mbs)
setMBeanServer in interface MBeanServerForwarderprotected abstract void checkRead()
protected abstract void checkWrite()
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException
checkRead(), then forward this method to the
wrapped object.addNotificationListener in interface MBeanServeraddNotificationListener in interface MBeanServerConnectionInstanceNotFoundExceptionpublic void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException
checkRead(), then forward this method to the
wrapped object.addNotificationListener in interface MBeanServeraddNotificationListener in interface MBeanServerConnectionInstanceNotFoundExceptionpublic ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
checkWrite(), then forward this method to the
wrapped object.createMBean in interface MBeanServercreateMBean in interface MBeanServerConnectionReflectionExceptionInstanceAlreadyExistsExceptionMBeanRegistrationExceptionMBeanExceptionNotCompliantMBeanExceptionpublic ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
checkWrite(), then forward this method to the
wrapped object.createMBean in interface MBeanServercreateMBean in interface MBeanServerConnectionReflectionExceptionInstanceAlreadyExistsExceptionMBeanRegistrationExceptionMBeanExceptionNotCompliantMBeanExceptionpublic ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
checkWrite(), then forward this method to the
wrapped object.createMBean in interface MBeanServercreateMBean in interface MBeanServerConnectionReflectionExceptionInstanceAlreadyExistsExceptionMBeanRegistrationExceptionMBeanExceptionNotCompliantMBeanExceptionInstanceNotFoundExceptionpublic ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
checkWrite(), then forward this method to the
wrapped object.createMBean in interface MBeanServercreateMBean in interface MBeanServerConnectionReflectionExceptionInstanceAlreadyExistsExceptionMBeanRegistrationExceptionMBeanExceptionNotCompliantMBeanExceptionInstanceNotFoundExceptionpublic ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException
checkRead(), then forward this method to the
wrapped object.deserialize in interface MBeanServerInstanceNotFoundExceptionOperationsExceptionpublic ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException
checkRead(), then forward this method to the
wrapped object.deserialize in interface MBeanServerOperationsExceptionReflectionExceptionpublic ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionException
checkRead(), then forward this method to the
wrapped object.deserialize in interface MBeanServerInstanceNotFoundExceptionOperationsExceptionReflectionExceptionpublic Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
checkRead(), then forward this method to the
wrapped object.getAttribute in interface MBeanServergetAttribute in interface MBeanServerConnectionMBeanExceptionAttributeNotFoundExceptionInstanceNotFoundExceptionReflectionExceptionpublic AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException
checkRead(), then forward this method to the
wrapped object.getAttributes in interface MBeanServergetAttributes in interface MBeanServerConnectionInstanceNotFoundExceptionReflectionExceptionpublic ClassLoader getClassLoader(ObjectName loaderName) throws InstanceNotFoundException
checkRead(), then forward this method to the
wrapped object.getClassLoader in interface MBeanServerInstanceNotFoundExceptionpublic ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException
checkRead(), then forward this method to the
wrapped object.getClassLoaderFor in interface MBeanServerInstanceNotFoundExceptionpublic ClassLoaderRepository getClassLoaderRepository()
checkRead(), then forward this method to the
wrapped object.getClassLoaderRepository in interface MBeanServerpublic String getDefaultDomain()
checkRead(), then forward this method to the
wrapped object.getDefaultDomain in interface MBeanServergetDefaultDomain in interface MBeanServerConnectionpublic String[] getDomains()
checkRead(), then forward this method to the
wrapped object.getDomains in interface MBeanServergetDomains in interface MBeanServerConnectionpublic Integer getMBeanCount()
checkRead(), then forward this method to the
wrapped object.getMBeanCount in interface MBeanServergetMBeanCount in interface MBeanServerConnectionpublic MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException
checkRead(), then forward this method to the
wrapped object.getMBeanInfo in interface MBeanServergetMBeanInfo in interface MBeanServerConnectionInstanceNotFoundExceptionIntrospectionExceptionReflectionExceptionpublic ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException
checkRead(), then forward this method to the
wrapped object.getObjectInstance in interface MBeanServergetObjectInstance in interface MBeanServerConnectionInstanceNotFoundExceptionpublic Object instantiate(String className) throws ReflectionException, MBeanException
checkWrite(), then forward this method to the
wrapped object.instantiate in interface MBeanServerReflectionExceptionMBeanExceptionpublic Object instantiate(String className, Object[] params, String[] signature) throws ReflectionException, MBeanException
checkWrite(), then forward this method to the
wrapped object.instantiate in interface MBeanServerReflectionExceptionMBeanExceptionpublic Object instantiate(String className, ObjectName loaderName) throws ReflectionException, MBeanException, InstanceNotFoundException
checkWrite(), then forward this method to the
wrapped object.instantiate in interface MBeanServerReflectionExceptionMBeanExceptionInstanceNotFoundExceptionpublic Object instantiate(String className, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, MBeanException, InstanceNotFoundException
checkWrite(), then forward this method to the
wrapped object.instantiate in interface MBeanServerReflectionExceptionMBeanExceptionInstanceNotFoundExceptionpublic Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException
checkWrite(), then forward this method to the
wrapped object.invoke in interface MBeanServerinvoke in interface MBeanServerConnectionInstanceNotFoundExceptionMBeanExceptionReflectionExceptionpublic boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException
checkRead(), then forward this method to the
wrapped object.isInstanceOf in interface MBeanServerisInstanceOf in interface MBeanServerConnectionInstanceNotFoundExceptionpublic boolean isRegistered(ObjectName name)
checkRead(), then forward this method to the
wrapped object.isRegistered in interface MBeanServerisRegistered in interface MBeanServerConnectionpublic Set queryMBeans(ObjectName name, QueryExp query)
checkRead(), then forward this method to the
wrapped object.queryMBeans in interface MBeanServerqueryMBeans in interface MBeanServerConnectionpublic Set queryNames(ObjectName name, QueryExp query)
checkRead(), then forward this method to the
wrapped object.queryNames in interface MBeanServerqueryNames in interface MBeanServerConnectionpublic ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
checkWrite(), then forward this method to the
wrapped object.registerMBean in interface MBeanServerInstanceAlreadyExistsExceptionMBeanRegistrationExceptionNotCompliantMBeanExceptionpublic void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException
checkRead(), then forward this method to the
wrapped object.removeNotificationListener in interface MBeanServerremoveNotificationListener in interface MBeanServerConnectionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException
checkRead(), then forward this method to the
wrapped object.removeNotificationListener in interface MBeanServerremoveNotificationListener in interface MBeanServerConnectionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException
checkRead(), then forward this method to the
wrapped object.removeNotificationListener in interface MBeanServerremoveNotificationListener in interface MBeanServerConnectionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException
checkRead(), then forward this method to the
wrapped object.removeNotificationListener in interface MBeanServerremoveNotificationListener in interface MBeanServerConnectionInstanceNotFoundExceptionListenerNotFoundExceptionpublic void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
checkWrite(), then forward this method to the
wrapped object.setAttribute in interface MBeanServersetAttribute in interface MBeanServerConnectionInstanceNotFoundExceptionAttributeNotFoundExceptionInvalidAttributeValueExceptionMBeanExceptionReflectionExceptionpublic AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException
checkWrite(), then forward this method to the
wrapped object.setAttributes in interface MBeanServersetAttributes in interface MBeanServerConnectionInstanceNotFoundExceptionReflectionExceptionpublic void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException
checkWrite(), then forward this method to the
wrapped object.unregisterMBean in interface MBeanServerunregisterMBean in interface MBeanServerConnectionInstanceNotFoundExceptionMBeanRegistrationExceptionCopyright © 2019 Terracotta, Inc.. All rights reserved.