/** {@inheritDoc} */ public synchronized void start(final StartContext context) throws StartException { //If the platform MBeanServer was set up to be the PluggableMBeanServer, use that otherwise create a new one and delegate MBeanServer platform = ManagementFactory.getPlatformMBeanServer(); PluggableMBeanServerImpl pluggable = platform instanceof PluggableMBeanServerImpl ? (PluggableMBeanServerImpl)platform : new PluggableMBeanServerImpl(platform, null); MBeanServerDelegate delegate = platform instanceof PluggableMBeanServerImpl ? ((PluggableMBeanServerImpl)platform).getMBeanServerDelegate() : null; pluggable.setAuditLogger(auditLoggerInfo); pluggable.setAuthorizer(authorizer); authorizer.setNonFacadeMBeansSensitive(coreMBeanSensitivity); if (resolvedDomainName != null || expressionsDomainName != null) { //TODO make these configurable ConfiguredDomains configuredDomains = new ConfiguredDomains(resolvedDomainName, expressionsDomainName); showModelPlugin = new ModelControllerMBeanServerPlugin(configuredDomains, modelControllerValue.getValue(), delegate, legacyWithProperPropertyFormat, forStandalone); pluggable.addPlugin(showModelPlugin); } mBeanServer = pluggable; }
@Override public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = true; try { delegate = findDelegate(name); authorizeMBeanOperation(delegate, name, GET_OBJECT_INSTANCE, null, JmxAction.Impact.READ_ONLY); return delegate.getObjectInstance(name); } catch (Exception e) { error = e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getObjectInstance(name); } } }
@Override public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = false; try { delegate = findDelegateForNewObject(name); authorizeMBeanOperation(delegate, name, CREATE_MBEAN, null, JmxAction.Impact.WRITE); return checkNotAReservedDomainRegistrationIfObjectNameWasChanged(name, delegate.createMBean(className, name, params, signature), delegate); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof InstanceAlreadyExistsException) throw (InstanceAlreadyExistsException)e; if (e instanceof MBeanException) throw (MBeanException)e; if (e instanceof NotCompliantMBeanException) throw (NotCompliantMBeanException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).createMBean(className, name, params, signature); } } }
@Override public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); Throwable error = null; MBeanServerPlugin delegate = findDelegate(name); boolean readOnly = false; try { //Need to determine impact of the operation readOnly = isOperationReadOnly(name, operationName, signature); delegate = findDelegate(name); authorizeMBeanOperation(delegate, name, INVOKE, null, readOnly ? JmxAction.Impact.READ_ONLY : JmxAction.Impact.WRITE); return delegate.invoke(name, operationName, params, signature); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof MBeanException) throw (MBeanException)e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).invoke(name, operationName, params, signature); } } }
@Override public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); Throwable error = null; MBeanServerPlugin delegate = findDelegate(name); boolean readOnly = false; try { //Need to determine impact of the operation readOnly = isOperationReadOnly(name, operationName, signature); delegate = findDelegate(name); if (delegate.shouldAuthorize()) { authorizeSensitiveOperation(INVOKE, readOnly, true); } return delegate.invoke(name, operationName, params, signature); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof MBeanException) throw (MBeanException)e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).invoke(name, operationName, params, signature); } } }
@Override public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanException, NotCompliantMBeanException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = false; try { delegate = findDelegateForNewObject(name); if (delegate.shouldAuthorize()) { authorizeSensitiveOperation(CREATE_MBEAN, readOnly, true); } return delegate.createMBean(className, name, params, signature); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof InstanceAlreadyExistsException) throw (InstanceAlreadyExistsException)e; if (e instanceof MBeanException) throw (MBeanException)e; if (e instanceof NotCompliantMBeanException) throw (NotCompliantMBeanException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).createMBean(className, name, params, signature); } } }
@Override public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = false; try { delegate = findDelegate(name); if (delegate.shouldAuthorize()) { authorizeSensitiveOperation(UNREGISTER_MBEAN, readOnly, true); } delegate.unregisterMBean(name); } catch (Exception e) { error = e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; if (e instanceof MBeanRegistrationException) throw (MBeanRegistrationException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).unregisterMBean(name); } } }
/** {@inheritDoc} */ public synchronized void start(final StartContext context) throws StartException { //If the platform MBeanServer was set up to be the PluggableMBeanServer, use that otherwise create a new one and delegate MBeanServer platform = ManagementFactory.getPlatformMBeanServer(); PluggableMBeanServerImpl pluggable = platform instanceof PluggableMBeanServerImpl ? (PluggableMBeanServerImpl)platform : new PluggableMBeanServerImpl(platform, null); MBeanServerDelegate delegate = platform instanceof PluggableMBeanServerImpl ? ((PluggableMBeanServerImpl)platform).getMBeanServerDelegate() : null; pluggable.setAuditLogger(auditLoggerInfo); pluggable.setAuthorizer(authorizer); pluggable.setSecurityIdentitySupplier(securityIdentitySupplier); pluggable.setJmxEffect(jmxEffect); authorizer.setNonFacadeMBeansSensitive(coreMBeanSensitivity); if (resolvedDomainName != null || expressionsDomainName != null) { //TODO make these configurable ConfiguredDomains configuredDomains = new ConfiguredDomains(resolvedDomainName, expressionsDomainName); showModelPlugin = new ModelControllerMBeanServerPlugin(pluggable, configuredDomains, modelControllerValue.getValue(), notificationRegistryValue.getValue(), delegate, legacyWithProperPropertyFormat, processType, managementModelProviderValue.getValue(), isMasterHc); pluggable.addPlugin(showModelPlugin); } mBeanServer = pluggable; }
@Override public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { return findDelegate(name).getAttribute(name, attribute); }
@Override public ClassLoader getClassLoader(ObjectName loaderName) throws InstanceNotFoundException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = true; try { delegate = findDelegate(loaderName); //Special authorization authorizeClassloadingOperation(delegate, loaderName, GET_CLASSLOADER); return delegate.getClassLoader(loaderName); } catch (Exception e) { error = e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getClassLoader(loaderName); } } }
@Override public ClassLoader getClassLoader(ObjectName loaderName) throws InstanceNotFoundException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = true; try { delegate = findDelegate(loaderName); if (delegate.shouldAuthorize()) { //Special authorization authorizeSuperUserOrAdministrator(GET_CLASSLOADER); } return delegate.getClassLoader(loaderName); } catch (Exception e) { error = e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getClassLoader(loaderName); } } }
@Override public ClassLoaderRepository getClassLoaderRepository() { Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = true; try { //Special authorization authorizeClassloadingOperation(delegate, GET_CLASSLOADER_REPOSITORY); return delegate.getClassLoaderRepository(); } catch (Exception e) { error = e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getClassLoaderRepository(); } } }
@Override public Object instantiate(String className) throws ReflectionException, MBeanException { Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = false; try { if (delegate.shouldAuthorize()) { authorizeSuperUserOrAdministrator(INSTANTIATE); } return delegate.instantiate(className); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof MBeanException) throw (MBeanException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).instantiate(className); } } }
@Override public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = true; try { delegate = findDelegateForNewObject(mbeanName); //Special authorization authorizeClassloadingOperation(delegate, mbeanName, GET_CLASSLOADER_FOR); return delegate.getClassLoaderFor(mbeanName); } catch (Exception e) { error = e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getClassLoaderFor(mbeanName); } } }
@Override public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException { Throwable error = null; MBeanServerPlugin delegate = null; final boolean readOnly = true; try { delegate = findDelegateForNewObject(mbeanName); if (delegate.shouldAuthorize()) { //Special authorization authorizeSuperUserOrAdministrator(GET_CLASSLOADER_FOR); } return delegate.getClassLoaderFor(mbeanName); } catch (Exception e) { error = e; if (e instanceof InstanceNotFoundException) throw (InstanceNotFoundException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getClassLoaderFor(mbeanName); } } }
@Override public Object instantiate(String className, Object[] params, String[] signature) throws ReflectionException, MBeanException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = false; try { //Special authorization authorizeClassloadingOperation(delegate, INSTANTIATE); return delegate.instantiate(className, params, signature); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof MBeanException) throw (MBeanException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).instantiate(className, params, signature); } } }
@Override public Object instantiate(String className, Object[] params, String[] signature) throws ReflectionException, MBeanException { params = nullAsEmpty(params); signature = nullAsEmpty(signature); Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = false; try { if (delegate.shouldAuthorize()) { authorizeSuperUserOrAdministrator(INSTANTIATE); } return delegate.instantiate(className, params, signature); } catch (Exception e) { error = e; if (e instanceof ReflectionException) throw (ReflectionException)e; if (e instanceof MBeanException) throw (MBeanException)e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).instantiate(className, params, signature); } } }
/** {@inheritDoc} */ public synchronized void start(final StartContext context) throws StartException { //If the platform MBeanServer was set up to be the PluggableMBeanServer, use that otherwise create a new one and delegate MBeanServer platform = ManagementFactory.getPlatformMBeanServer(); PluggableMBeanServerImpl pluggable = platform instanceof PluggableMBeanServerImpl ? (PluggableMBeanServerImpl)platform : new PluggableMBeanServerImpl(platform); if (resolvedDomainName != null || expressionsDomainName != null) { //TODO make these configurable ConfiguredDomains configuredDomains = new ConfiguredDomains(resolvedDomainName, expressionsDomainName); showModelPlugin = new ModelControllerMBeanServerPlugin(configuredDomains, modelControllerValue.getValue(), legacyWithProperPropertyFormat); pluggable.addPlugin(showModelPlugin); } mBeanServer = pluggable; }
@Override public String getDefaultDomain() { Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = true; try { //No authorization needed to get the name of the default domain return delegate.getDefaultDomain(); } catch (Exception e) { error = e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getDefaultDomain(); } } }
@Override public ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { return findDelegateForNewObject(name).registerMBean(object, name); }