java.lang.management.ManagementPermission Java Examples
The following examples show how to use
java.lang.management.ManagementPermission.
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: Activator.java From micro-integrator with Apache License 2.0 | 5 votes |
public void startDeploy(BundleContext bundleContext) throws Exception { // Need permissions in order to instantiate user core SecurityManager secMan = System.getSecurityManager(); /* * Read the SSL trust store configurations from the Security.TrustStore * element of the Carbon.xml */ CarbonServerConfigurationService config = CarbonServerConfigurationService.getInstance(); String type = config.getFirstProperty("Security.TrustStore.Type"); String password = config.getFirstProperty("Security.TrustStore.Password"); String storeFile = new File(config.getFirstProperty("Security.TrustStore.Location")).getAbsolutePath(); // set the SSL trust store System Properties System.setProperty("javax.net.ssl.trustStore", storeFile); System.setProperty("javax.net.ssl.trustStoreType", type); System.setProperty("javax.net.ssl.trustStorePassword", password); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } try { if (Boolean.parseBoolean(System.getProperty("NonUserCoreMode"))) { log.debug("UserCore component activated in NonUserCoreMode Mode"); return; } RealmService realmService = new DefaultRealmService(bundleContext); bundleContext.registerService(new String[]{RealmService.class.getName(), UserRealmService.class.getName()}, realmService, null); UserCoreUtil.setRealmService(realmService); } catch (Throwable e) { String msg = "Cannot start User Manager Core bundle"; log.error(msg, e); // do not throw exceptions; } }
Example #2
Source File: MicroIntegratorBaseUtils.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Method to test whether a given user has permission to execute the given * method. */ public static void checkSecurity() { java.lang.SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } }
Example #3
Source File: ServerManagement.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Method to switch a node to maintenance mode. * <p/> * Here is the sequence of events: * <p/> * <ol> * <li>Client calls this method</li> * <li>The server stops accepting new requests/connections, but continues to stay alive so * that old requests & connections can be served</li> * <li>Once all requests have been processed, the method returns</li * </ol> * @throws Exception - on errors while starting maintenance */ public void startMaintenance() throws Exception { SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } log.info("Starting to switch to maintenance mode..."); for (TransportInDescription tinDesc : inTransports.values()) { TransportListener transport = tinDesc.getReceiver(); transport.stop(); } log.info("Stopped all transport listeners"); waitForRequestCompletion(); }
Example #4
Source File: ServerManagement.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Wait till all service requests have been serviced. This method will only wait for a maximum * of {@link ServerManagement#TIMEOUT} * * @throws Exception If an error occurs while trying to connect to the Tomcat MBean */ public void waitForRequestCompletion() throws Exception { SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } log.info("Waiting for request service completion..."); /** * Get all MBeans with names such as Catalina:type=RequestProcessor,worker=http-9762,name=HttpRequest<n> * & Catalina:type=RequestProcessor,worker=http-9762,name=HttpsRequest<n> */ MBeanServer mbs = MbeanManagementFactory.getMBeanServer(); boolean areRequestsInService; long start = System.currentTimeMillis(); do { // Check whether there are any processors which are currently in the SERVICE stage (3) QueryExp query = Query.eq(Query.attr("stage"), Query.value(3)); // 3 = org.apache.coyote.Constants.STAGE_SERVICE Set set = mbs.queryNames(new ObjectName("Catalina:type=RequestProcessor,*"), query); if (set.size() > 0) { areRequestsInService = true; if (System.currentTimeMillis() - start > TIMEOUT) { log.warn("Timeout occurred even though there are active connections."); break; } Thread.sleep(2000); } else { areRequestsInService = false; } } while (areRequestsInService); log.info("All requests have been served."); }
Example #5
Source File: ServerManagement.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Method to change the state of a node from "maintenance" to "normal" * * @throws Exception If an error occurs while trying to connect to the Tomcat MBean */ public void endMaintenance() throws Exception { SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } log.info("Switching to normal mode..."); for (Iterator iter = inTransports.values().iterator(); iter.hasNext();) { TransportInDescription tinDesc = (TransportInDescription) iter.next(); TransportListener transport = tinDesc.getReceiver(); transport.start(); } log.info("Switched to normal mode"); }
Example #6
Source File: SecuritySubjectPermissionsTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@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 #7
Source File: Activator.java From micro-integrator with Apache License 2.0 | 4 votes |
@Override public void start(BundleContext bundleContext) throws Exception { if (log.isDebugEnabled()) { log.debug(Activator.class.getName() + "#start() BEGIN - " + System.currentTimeMillis()); } try { // Need permissions in order to activate Carbon Core SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } // We assume it's super tenant during the deployment time // PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext // .getThreadLocalCarbonContext(); // privilegedCarbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); // privilegedCarbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); logServerInfo(); Security.addProvider(new BouncyCastleProvider()); if (log.isDebugEnabled()){ log.debug("BouncyCastle security provider is successfully registered in JVM."); } // bundleContext.registerService(CarbonCoreInitializedEvent.class.getName(), new CarbonCoreInitializedEventImpl(), null); // GhostServiceMetaArtifactsLoader serviceMetaArtifactsLoader = new GhostServiceMetaArtifactsLoader(); // bundleContext.registerService(GhostMetaArtifactsLoader.class.getName(), serviceMetaArtifactsLoader, null); // CarbonCoreDataHolder.getInstance().setBundleContext(bundleContext); initializeCarbonServerConfigurationService(bundleContext); // Initialize MI Server CoreServerInitializer coreServerInitializer = new CoreServerInitializer(CarbonCoreDataHolder.getInstance().getServerConfigurationService(), bundleContext); coreServerInitializer.initMIServer(); } catch (Throwable e) { throw new Exception(e); } if (log.isDebugEnabled()) { log.debug(Activator.class.getName() + "#start() COMPLETED - " + System.currentTimeMillis()); } }
Example #8
Source File: Repl.java From java-repl with Apache License 2.0 | 4 votes |
private static void sandboxApplication() throws UnsupportedEncodingException { Policy.setPolicy(new Policy() { private final PermissionCollection permissions = new Permissions(); { permissions.add(new SocketPermission("*", "accept, connect, resolve")); permissions.add(new RuntimePermission("accessClassInPackage.sun.misc.*")); permissions.add(new RuntimePermission("accessClassInPackage.sun.misc")); permissions.add(new RuntimePermission("getProtectionDomain")); permissions.add(new RuntimePermission("accessDeclaredMembers")); permissions.add(new RuntimePermission("createClassLoader")); permissions.add(new RuntimePermission("closeClassLoader")); permissions.add(new RuntimePermission("modifyThreadGroup")); permissions.add(new RuntimePermission("getStackTrace")); permissions.add(new ManagementPermission("monitor")); permissions.add(new ReflectPermission("suppressAccessChecks")); permissions.add(new PropertyPermission("*", "read")); permissions.add(new FilePermission(temporaryDirectory("JavaREPL").getAbsolutePath() + "/-", "read, write, delete")); permissions.add(new FilePermission(sequence(System.getProperty("java.home").split(File.separator)). reverse(). drop(1). reverse(). toString(File.separator) + "/-", "read")); permissions.add(new FilePermission("./-", "read")); Sequence<String> extensions = sequence(((URLClassLoader) getSystemJavaCompiler().getClass().getClassLoader()).getURLs()).map(URL::getPath). join(paths("java.ext.dirs")). join(paths("java.library.path")). append(System.getProperty("user.home")); for (String extension : extensions) { permissions.add(new FilePermission(extension, "read")); permissions.add(new FilePermission(extension + "/-", "read")); } } @Override public PermissionCollection getPermissions(CodeSource codesource) { return permissions; } }); System.setSecurityManager(new SecurityManager()); }
Example #9
Source File: Util.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #10
Source File: Util.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #11
Source File: Util.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #12
Source File: Util.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #13
Source File: Util.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #14
Source File: Util.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #15
Source File: Util.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #16
Source File: Util.java From openjdk-8 with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #17
Source File: Util.java From jdk8u_jdk with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #18
Source File: Util.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #19
Source File: Util.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #20
Source File: Util.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }
Example #21
Source File: Util.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * Check that the current context is trusted to perform monitoring * or management. * <p> * If the check fails we throw a SecurityException, otherwise * we return normally. * * @exception SecurityException if a security manager exists and if * the caller does not have ManagementPermission("control"). */ static void checkAccess(ManagementPermission p) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(p); } }