javax.management.MBeanServerPermission Java Examples

The following examples show how to use javax.management.MBeanServerPermission. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmxMBeanServer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #2
Source File: JmxMBeanServer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #3
Source File: SecuritySubjectPermissionsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
    if (System.getSecurityManager() == null) {
        Policy.setPolicy(new Policy() {
            @Override public PermissionCollection getPermissions(CodeSource cs) {
                Permissions res = new Permissions();

                res.add(new RuntimePermission("*"));
                res.add(new MBeanServerPermission("*"));
                res.add(new MBeanPermission("*", "*"));
                res.add(new MBeanTrustPermission("*"));
                res.add(new ReflectPermission("*"));
                res.add(new SSLPermission("*"));
                res.add(new ManagementPermission("monitor"));
                res.add(new ManagementPermission("control"));
                res.add(new SerializablePermission("*"));
                res.add(new SecurityPermission("*"));
                res.add(new SocketPermission("*", "connect,accept,listen,resolve"));
                res.add(new FilePermission("<<ALL FILES>>", "read,write,delete,execute,readlink"));
                res.add(new PropertyPermission("*", "read,write"));

                res.add(new TestPermission("common"));

                return res;
            }
        });

        System.setSecurityManager(new SecurityManager());

        setupSM = true;
    }
}
 
Example #4
Source File: JmxMBeanServer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #5
Source File: JmxMBeanServer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #6
Source File: JmxMBeanServer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #7
Source File: JmxMBeanServer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #8
Source File: JmxMBeanServer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #9
Source File: JmxMBeanServer.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #10
Source File: JmxMBeanServer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #11
Source File: JmxMBeanServer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #12
Source File: JmxMBeanServer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #13
Source File: JmxMBeanServer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #14
Source File: JmxMBeanServer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #15
Source File: JmxMBeanServer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #16
Source File: JmxMBeanServer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkNewMBeanServerPermission() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("newMBeanServer");
        sm.checkPermission(perm);
    }
}
 
Example #17
Source File: ManagementFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the platform {@link javax.management.MBeanServer MBeanServer}.
 * On the first call to this method, it first creates the platform
 * {@code MBeanServer} by calling the
 * {@link javax.management.MBeanServerFactory#createMBeanServer
 * MBeanServerFactory.createMBeanServer}
 * method and registers each platform MXBean in this platform
 * {@code MBeanServer} with its
 * {@link PlatformManagedObject#getObjectName ObjectName}.
 * This method, in subsequent calls, will simply return the
 * initially created platform {@code MBeanServer}.
 * <p>
 * MXBeans that get created and destroyed dynamically, for example,
 * memory {@link MemoryPoolMXBean pools} and
 * {@link MemoryManagerMXBean managers},
 * will automatically be registered and deregistered into the platform
 * {@code MBeanServer}.
 * <p>
 * If the system property {@code javax.management.builder.initial}
 * is set, the platform {@code MBeanServer} creation will be done
 * by the specified {@link javax.management.MBeanServerBuilder}.
 * <p>
 * It is recommended that this platform MBeanServer also be used
 * to register other application managed beans
 * besides the platform MXBeans.
 * This will allow all MBeans to be published through the same
 * {@code MBeanServer} and hence allow for easier network publishing
 * and discovery.
 * Name conflicts with the platform MXBeans should be avoided.
 *
 * @return the platform {@code MBeanServer}; the platform
 *         MXBeans are registered into the platform {@code MBeanServer}
 *         at the first time this method is called.
 *
 * @exception SecurityException if there is a security manager
 * and the caller does not have the permission required by
 * {@link javax.management.MBeanServerFactory#createMBeanServer}.
 *
 * @see javax.management.MBeanServerFactory
 * @see javax.management.MBeanServerFactory#createMBeanServer
 */
public static synchronized MBeanServer getPlatformMBeanServer() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("createMBeanServer");
        sm.checkPermission(perm);
    }

    if (platformMBeanServer == null) {
        platformMBeanServer = MBeanServerFactory.createMBeanServer();
        platformComponents()
                .stream()
                .filter(PlatformComponent::shouldRegister)
                .flatMap(pc -> pc.nameToMBeanMap().entrySet().stream())
                .forEach(entry -> addMXBean(platformMBeanServer, entry.getKey(), entry.getValue()));
    }
    return platformMBeanServer;
}
 
Example #18
Source File: ManagementFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the platform {@link javax.management.MBeanServer MBeanServer}.
 * On the first call to this method, it first creates the platform
 * {@code MBeanServer} by calling the
 * {@link javax.management.MBeanServerFactory#createMBeanServer
 * MBeanServerFactory.createMBeanServer}
 * method and registers each platform MXBean in this platform
 * {@code MBeanServer} with its
 * {@link PlatformManagedObject#getObjectName ObjectName}.
 * This method, in subsequent calls, will simply return the
 * initially created platform {@code MBeanServer}.
 * <p>
 * MXBeans that get created and destroyed dynamically, for example,
 * memory {@link MemoryPoolMXBean pools} and
 * {@link MemoryManagerMXBean managers},
 * will automatically be registered and deregistered into the platform
 * {@code MBeanServer}.
 * <p>
 * If the system property {@code javax.management.builder.initial}
 * is set, the platform {@code MBeanServer} creation will be done
 * by the specified {@link javax.management.MBeanServerBuilder}.
 * <p>
 * It is recommended that this platform MBeanServer also be used
 * to register other application managed beans
 * besides the platform MXBeans.
 * This will allow all MBeans to be published through the same
 * {@code MBeanServer} and hence allow for easier network publishing
 * and discovery.
 * Name conflicts with the platform MXBeans should be avoided.
 *
 * @return the platform {@code MBeanServer}; the platform
 *         MXBeans are registered into the platform {@code MBeanServer}
 *         at the first time this method is called.
 *
 * @exception SecurityException if there is a security manager
 * and the caller does not have the permission required by
 * {@link javax.management.MBeanServerFactory#createMBeanServer}.
 *
 * @see javax.management.MBeanServerFactory
 * @see javax.management.MBeanServerFactory#createMBeanServer
 */
public static synchronized MBeanServer getPlatformMBeanServer() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("createMBeanServer");
        sm.checkPermission(perm);
    }

    MBeanServer thePlatformMBeanServer= null;
    if(TenantGlobals.isDataIsolationEnabled() && null != TenantContainer.current()) {
        thePlatformMBeanServer = TenantContainer.current().getFieldValue(ManagementFactory.class, "platformMBeanServer",
                ManagementFactory::createPlatformMBeanServer);
    } else {
        //use the value in root.
        if (platformMBeanServer == null) {
            platformMBeanServer = createPlatformMBeanServer();
        }
        thePlatformMBeanServer = platformMBeanServer;
    }
    return thePlatformMBeanServer;
}
 
Example #19
Source File: ManagementFactory.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the platform {@link javax.management.MBeanServer MBeanServer}.
 * On the first call to this method, it first creates the platform
 * {@code MBeanServer} by calling the
 * {@link javax.management.MBeanServerFactory#createMBeanServer
 * MBeanServerFactory.createMBeanServer}
 * method and registers each platform MXBean in this platform
 * {@code MBeanServer} with its
 * {@link PlatformManagedObject#getObjectName ObjectName}.
 * This method, in subsequent calls, will simply return the
 * initially created platform {@code MBeanServer}.
 * <p>
 * MXBeans that get created and destroyed dynamically, for example,
 * memory {@link MemoryPoolMXBean pools} and
 * {@link MemoryManagerMXBean managers},
 * will automatically be registered and deregistered into the platform
 * {@code MBeanServer}.
 * <p>
 * If the system property {@code javax.management.builder.initial}
 * is set, the platform {@code MBeanServer} creation will be done
 * by the specified {@link javax.management.MBeanServerBuilder}.
 * <p>
 * It is recommended that this platform MBeanServer also be used
 * to register other application managed beans
 * besides the platform MXBeans.
 * This will allow all MBeans to be published through the same
 * {@code MBeanServer} and hence allow for easier network publishing
 * and discovery.
 * Name conflicts with the platform MXBeans should be avoided.
 *
 * @return the platform {@code MBeanServer}; the platform
 *         MXBeans are registered into the platform {@code MBeanServer}
 *         at the first time this method is called.
 *
 * @exception SecurityException if there is a security manager
 * and the caller does not have the permission required by
 * {@link javax.management.MBeanServerFactory#createMBeanServer}.
 *
 * @see javax.management.MBeanServerFactory
 * @see javax.management.MBeanServerFactory#createMBeanServer
 */
public static synchronized MBeanServer getPlatformMBeanServer() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("createMBeanServer");
        sm.checkPermission(perm);
    }

    if (platformMBeanServer == null) {
        platformMBeanServer = MBeanServerFactory.createMBeanServer();
        for (PlatformComponent pc : PlatformComponent.values()) {
            List<? extends PlatformManagedObject> list =
                pc.getMXBeans(pc.getMXBeanInterface());
            for (PlatformManagedObject o : list) {
                // Each PlatformComponent represents one management
                // interface. Some MXBean may extend another one.
                // The MXBean instances for one platform component
                // (returned by pc.getMXBeans()) might be also
                // the MXBean instances for another platform component.
                // e.g. com.sun.management.GarbageCollectorMXBean
                //
                // So need to check if an MXBean instance is registered
                // before registering into the platform MBeanServer
                if (!platformMBeanServer.isRegistered(o.getObjectName())) {
                    addMXBean(platformMBeanServer, o);
                }
            }
        }
        HashMap<ObjectName, DynamicMBean> dynmbeans =
                ManagementFactoryHelper.getPlatformDynamicMBeans();
        for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) {
            addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey());
        }
    }
    return platformMBeanServer;
}
 
Example #20
Source File: ManagementFactory.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the platform {@link javax.management.MBeanServer MBeanServer}.
 * On the first call to this method, it first creates the platform
 * {@code MBeanServer} by calling the
 * {@link javax.management.MBeanServerFactory#createMBeanServer
 * MBeanServerFactory.createMBeanServer}
 * method and registers each platform MXBean in this platform
 * {@code MBeanServer} with its
 * {@link PlatformManagedObject#getObjectName ObjectName}.
 * This method, in subsequent calls, will simply return the
 * initially created platform {@code MBeanServer}.
 * <p>
 * MXBeans that get created and destroyed dynamically, for example,
 * memory {@link MemoryPoolMXBean pools} and
 * {@link MemoryManagerMXBean managers},
 * will automatically be registered and deregistered into the platform
 * {@code MBeanServer}.
 * <p>
 * If the system property {@code javax.management.builder.initial}
 * is set, the platform {@code MBeanServer} creation will be done
 * by the specified {@link javax.management.MBeanServerBuilder}.
 * <p>
 * It is recommended that this platform MBeanServer also be used
 * to register other application managed beans
 * besides the platform MXBeans.
 * This will allow all MBeans to be published through the same
 * {@code MBeanServer} and hence allow for easier network publishing
 * and discovery.
 * Name conflicts with the platform MXBeans should be avoided.
 *
 * @return the platform {@code MBeanServer}; the platform
 *         MXBeans are registered into the platform {@code MBeanServer}
 *         at the first time this method is called.
 *
 * @exception SecurityException if there is a security manager
 * and the caller does not have the permission required by
 * {@link javax.management.MBeanServerFactory#createMBeanServer}.
 *
 * @see javax.management.MBeanServerFactory
 * @see javax.management.MBeanServerFactory#createMBeanServer
 */
public static synchronized MBeanServer getPlatformMBeanServer() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("createMBeanServer");
        sm.checkPermission(perm);
    }

    if (platformMBeanServer == null) {
        platformMBeanServer = MBeanServerFactory.createMBeanServer();
        for (PlatformComponent pc : PlatformComponent.values()) {
            List<? extends PlatformManagedObject> list =
                pc.getMXBeans(pc.getMXBeanInterface());
            for (PlatformManagedObject o : list) {
                // Each PlatformComponent represents one management
                // interface. Some MXBean may extend another one.
                // The MXBean instances for one platform component
                // (returned by pc.getMXBeans()) might be also
                // the MXBean instances for another platform component.
                // e.g. com.sun.management.GarbageCollectorMXBean
                //
                // So need to check if an MXBean instance is registered
                // before registering into the platform MBeanServer
                if (!platformMBeanServer.isRegistered(o.getObjectName())) {
                    addMXBean(platformMBeanServer, o);
                }
            }
        }
        HashMap<ObjectName, DynamicMBean> dynmbeans =
                ManagementFactoryHelper.getPlatformDynamicMBeans();
        for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) {
            addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey());
        }
    }
    return platformMBeanServer;
}
 
Example #21
Source File: ManagementFactory.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the platform {@link javax.management.MBeanServer MBeanServer}.
 * On the first call to this method, it first creates the platform
 * {@code MBeanServer} by calling the
 * {@link javax.management.MBeanServerFactory#createMBeanServer
 * MBeanServerFactory.createMBeanServer}
 * method and registers each platform MXBean in this platform
 * {@code MBeanServer} with its
 * {@link PlatformManagedObject#getObjectName ObjectName}.
 * This method, in subsequent calls, will simply return the
 * initially created platform {@code MBeanServer}.
 * <p>
 * MXBeans that get created and destroyed dynamically, for example,
 * memory {@link MemoryPoolMXBean pools} and
 * {@link MemoryManagerMXBean managers},
 * will automatically be registered and deregistered into the platform
 * {@code MBeanServer}.
 * <p>
 * If the system property {@code javax.management.builder.initial}
 * is set, the platform {@code MBeanServer} creation will be done
 * by the specified {@link javax.management.MBeanServerBuilder}.
 * <p>
 * It is recommended that this platform MBeanServer also be used
 * to register other application managed beans
 * besides the platform MXBeans.
 * This will allow all MBeans to be published through the same
 * {@code MBeanServer} and hence allow for easier network publishing
 * and discovery.
 * Name conflicts with the platform MXBeans should be avoided.
 *
 * @return the platform {@code MBeanServer}; the platform
 *         MXBeans are registered into the platform {@code MBeanServer}
 *         at the first time this method is called.
 *
 * @exception SecurityException if there is a security manager
 * and the caller does not have the permission required by
 * {@link javax.management.MBeanServerFactory#createMBeanServer}.
 *
 * @see javax.management.MBeanServerFactory
 * @see javax.management.MBeanServerFactory#createMBeanServer
 */
public static synchronized MBeanServer getPlatformMBeanServer() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        Permission perm = new MBeanServerPermission("createMBeanServer");
        sm.checkPermission(perm);
    }

    if (platformMBeanServer == null) {
        platformMBeanServer = MBeanServerFactory.createMBeanServer();
        for (PlatformComponent pc : PlatformComponent.values()) {
            List<? extends PlatformManagedObject> list =
                pc.getMXBeans(pc.getMXBeanInterface());
            for (PlatformManagedObject o : list) {
                // Each PlatformComponent represents one management
                // interface. Some MXBean may extend another one.
                // The MXBean instances for one platform component
                // (returned by pc.getMXBeans()) might be also
                // the MXBean instances for another platform component.
                // e.g. com.sun.management.GarbageCollectorMXBean
                //
                // So need to check if an MXBean instance is registered
                // before registering into the platform MBeanServer
                if (!platformMBeanServer.isRegistered(o.getObjectName())) {
                    addMXBean(platformMBeanServer, o);
                }
            }
        }
    }
    return platformMBeanServer;
}