Java Code Examples for java.lang.management.ManagementPermission

The following are top voted examples for showing how to use java.lang.management.ManagementPermission. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: cn1   File: MemoryPoolMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public void setCollectionUsageThreshold(long threshold) {
    if (!isCollectionUsageThresholdSupported()) {
        //lm.13=VM does not support collection usage threshold.
        throw new UnsupportedOperationException(Messages.getString("lm.13")); //$NON-NLS-1$
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }

    if (threshold < 0) {            
        //lm.15=Collection usage threshold cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$            
    }

    if (exceedsMaxPoolSize(threshold)) {            
        //lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool.
        throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$
    }
    this.setCollectionUsageThresholdImpl(threshold);
}
 
Example 2
Project: cn1   File: MemoryPoolMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public void setUsageThreshold(long threshold) {
    if (!isUsageThresholdSupported()) {
        //lm.13=VM does not support collection usage threshold.
        throw new UnsupportedOperationException(Messages.getString("lm.13"));
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }

    if (threshold < 0) {
        //lm.15=Collection usage threshold cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$            
    }

    if (exceedsMaxPoolSize(threshold)) {
        //lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool.
        throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$
    }
    this.setUsageThresholdImpl(threshold);
}
 
Example 3
Project: cn1   File: RuntimeMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public String getBootClassPath() {
	if (!isBootClassPathSupported()) {
           //lm.1A=VM does not support boot classpath
           throw new UnsupportedOperationException(Messages.getString("lm.1A")); //$NON-NLS-1$
	}

	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new ManagementPermission("monitor"));
	}

	return AccessController.doPrivileged(new PrivilegedAction<String>() {
		public String run() {
			return System.getProperty("sun.boot.class.path");
		}// end method run
	});
}
 
Example 4
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }

    // Validate inputs
    for (int i = 0; i < ids.length; i++) {
        if (ids[i] <= 0) {
            //lm.1B=Thread id must be greater than 0
            throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$            
        }
    }

    if (maxDepth < 0) {            
        //lm.1D=maxDepth value cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$
    }

    // Create an array and populate with individual ThreadInfos
    ThreadInfo[] tis = new ThreadInfo[ids.length];
    for (int i = 0; i < ids.length; i++) {
        tis[i] = this.getThreadInfoImpl(ids[i], maxDepth);
    }
    return tis;
}
 
Example 5
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public ThreadInfo getThreadInfo(long id, int maxDepth) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }

    // Validate inputs
    if (id <= 0) {
        //lm.1B=Thread id must be greater than 0
        throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$            
    }
    if (maxDepth < 0) {
        //lm.1D=maxDepth value cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$
    }
    return this.getThreadInfoImpl(id, maxDepth);
}
 
Example 6
Project: freeVM   File: MemoryPoolMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public void setCollectionUsageThreshold(long threshold) {
    if (!isCollectionUsageThresholdSupported()) {
        throw new UnsupportedOperationException(
                "VM does not support collection usage threshold.");
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }

    if (threshold < 0) {
        throw new IllegalArgumentException(
                "Collection usage threshold cannot be negative.");
    }

    if (exceedsMaxPoolSize(threshold)) {
        throw new IllegalArgumentException(
                "Collection usage threshold cannot exceed maximum amount of memory for pool.");
    }
    this.setCollectionUsageThresholdImpl(threshold);
}
 
Example 7
Project: freeVM   File: MemoryPoolMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public void setUsageThreshold(long threshold) {
    if (!isUsageThresholdSupported()) {
        throw new UnsupportedOperationException(
                "VM does not support usage threshold.");
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }

    if (threshold < 0) {
        throw new IllegalArgumentException(
                "Usage threshold cannot be negative.");
    }

    if (exceedsMaxPoolSize(threshold)) {
        throw new IllegalArgumentException(
                "Usage threshold cannot exceed maximum amount of memory for pool.");
    }
    this.setUsageThresholdImpl(threshold);
}
 
Example 8
Project: freeVM   File: RuntimeMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public String getBootClassPath() {
	if (!isBootClassPathSupported()) {
		throw new UnsupportedOperationException(
				"VM does not support boot classpath.");
	}

	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new ManagementPermission("monitor"));
	}

	return AccessController.doPrivileged(new PrivilegedAction<String>() {
		public String run() {
			return System.getProperty("sun.boot.class.path");
		}// end method run
	});
}
 
Example 9
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }

    // Validate inputs
    for (int i = 0; i < ids.length; i++) {
        if (ids[i] <= 0) {
            throw new IllegalArgumentException(
                    "Thread id must be greater than 0.");
        }
    }

    if (maxDepth < 0) {
        throw new IllegalArgumentException(
                "maxDepth value cannot be negative.");
    }

    // Create an array and populate with individual ThreadInfos
    ThreadInfo[] tis = new ThreadInfo[ids.length];
    for (int i = 0; i < ids.length; i++) {
        tis[i] = this.getThreadInfoImpl(ids[i], maxDepth);
    }
    return tis;
}
 
Example 10
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public ThreadInfo getThreadInfo(long id, int maxDepth) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }

    // Validate inputs
    if (id <= 0) {
        throw new IllegalArgumentException(
                "Thread id must be greater than 0.");
    }
    if (maxDepth < 0) {
        throw new IllegalArgumentException(
                "maxDepth value cannot be negative.");
    }
    return this.getThreadInfoImpl(id, maxDepth);
}
 
Example 11
Project: freeVM   File: MemoryPoolMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public void setCollectionUsageThreshold(long threshold) {
    if (!isCollectionUsageThresholdSupported()) {
        //lm.13=VM does not support collection usage threshold.
        throw new UnsupportedOperationException(Messages.getString("lm.13")); //$NON-NLS-1$
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }

    if (threshold < 0) {            
        //lm.15=Collection usage threshold cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$            
    }

    if (exceedsMaxPoolSize(threshold)) {            
        //lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool.
        throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$
    }
    this.setCollectionUsageThresholdImpl(threshold);
}
 
Example 12
Project: freeVM   File: MemoryPoolMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public void setUsageThreshold(long threshold) {
    if (!isUsageThresholdSupported()) {
        //lm.13=VM does not support collection usage threshold.
        throw new UnsupportedOperationException(Messages.getString("lm.13"));
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }

    if (threshold < 0) {
        //lm.15=Collection usage threshold cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$            
    }

    if (exceedsMaxPoolSize(threshold)) {
        //lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool.
        throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$
    }
    this.setUsageThresholdImpl(threshold);
}
 
Example 13
Project: freeVM   File: RuntimeMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public String getBootClassPath() {
	if (!isBootClassPathSupported()) {
           //lm.1A=VM does not support boot classpath
           throw new UnsupportedOperationException(Messages.getString("lm.1A")); //$NON-NLS-1$
	}

	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new ManagementPermission("monitor"));
	}

	return AccessController.doPrivileged(new PrivilegedAction<String>() {
		public String run() {
			return System.getProperty("sun.boot.class.path");
		}// end method run
	});
}
 
Example 14
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }

    // Validate inputs
    for (int i = 0; i < ids.length; i++) {
        if (ids[i] <= 0) {
            //lm.1B=Thread id must be greater than 0
            throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$            
        }
    }

    if (maxDepth < 0) {            
        //lm.1D=maxDepth value cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$
    }

    // Create an array and populate with individual ThreadInfos
    ThreadInfo[] tis = new ThreadInfo[ids.length];
    for (int i = 0; i < ids.length; i++) {
        tis[i] = this.getThreadInfoImpl(ids[i], maxDepth);
    }
    return tis;
}
 
Example 15
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 6 votes vote down vote up
public ThreadInfo getThreadInfo(long id, int maxDepth) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }

    // Validate inputs
    if (id <= 0) {
        //lm.1B=Thread id must be greater than 0
        throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$            
    }
    if (maxDepth < 0) {
        //lm.1D=maxDepth value cannot be negative.
        throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$
    }
    return this.getThreadInfoImpl(id, maxDepth);
}
 
Example 16
Project: xm-commons   File: XmJvmSecurityUtils.java   Source Code and License 5 votes vote down vote up
/**
 * If JVM security manager exists then checks JVM security 'control' permission.
 */
public static void checkSecurity() {
    SecurityManager securityManager = System.getSecurityManager();
    if (securityManager != null) {
        securityManager.checkPermission(new ManagementPermission(PERMISSION_NAME_CONTROL));
    }
}
 
Example 17
Project: elasticsearch_my   File: JvmInfo.java   Source Code and License 5 votes vote down vote up
public static JvmInfo jvmInfo() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new ManagementPermission("monitor"));
        sm.checkPropertyAccess("*");
    }
    return INSTANCE;
}
 
Example 18
Project: evosuite   File: MSecurityManager.java   Source Code and License 5 votes vote down vote up
protected boolean checkManagementPermission(ManagementPermission perm) {
	String name = perm.getName();

	if (name.equals("monitor")) {
		return true;
	}

	/*
	 * "control" sounds bit risky
	 */
	return false;
}
 
Example 19
Project: cn1   File: MemoryPoolMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void resetPeakUsage() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakUsageImpl();
}
 
Example 20
Project: cn1   File: ClassLoadingMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
 
Example 21
Project: cn1   File: RuntimeMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public List<String> getInputArguments() {
	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new ManagementPermission("monitor"));
	}
       
       // TODO : Retrieve the input args from the VM
       return new ArrayList<String>();
}
 
Example 22
Project: cn1   File: MemoryMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
 
Example 23
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public long[] findMonitorDeadlockedThreads() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.findMonitorDeadlockedThreadsImpl();
}
 
Example 24
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public long[] getAllThreadIds() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.getAllThreadIdsImpl();
}
 
Example 25
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void resetPeakThreadCount() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakThreadCountImpl();
}
 
Example 26
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setThreadContentionMonitoringEnabled(boolean enable) {
    if (!isThreadContentionMonitoringSupported()) {
        //lm.1E=Thread contention monitoring is not supported on this virtual machine.
        throw new UnsupportedOperationException(Messages.getString("lm.1E")); //$NON-NLS-1$            
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setThreadContentionMonitoringEnabledImpl(enable);
}
 
Example 27
Project: cn1   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setThreadCpuTimeEnabled(boolean enable) {
    if (!isThreadCpuTimeSupported()) {
        //lm.01=Thread CPU timing is not supported on this virtual machine.
        throw new UnsupportedOperationException(Messages.getString("lm.01")); //$NON-NLS-1$          
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setThreadCpuTimeEnabledImpl(enable);
}
 
Example 28
Project: cn1   File: ManagementPermissionTest.java   Source Code and License 5 votes vote down vote up
public void testManagementPermissionString() {
    ManagementPermission control = new ManagementPermission("control");
    assertEquals("control", control.getName());

    ManagementPermission monitor = new ManagementPermission("monitor");
    assertEquals("monitor", monitor.getName());

    try {
        new ManagementPermission("invalid");
        fail();
    } catch (IllegalArgumentException e) {
    }
}
 
Example 29
Project: cn1   File: ManagementPermissionTest.java   Source Code and License 5 votes vote down vote up
public void testImplies() {
    ManagementPermission mp1 = new ManagementPermission("monitor");
    ManagementPermission mp2 = new ManagementPermission("control");
    ManagementPermission mp3 = new ManagementPermission("monitor", "");
    assertTrue(mp1.implies(mp1));
    assertTrue(mp1.implies(mp3));
    assertFalse(mp1.implies(mp2));
    assertFalse(mp2.implies(mp1));
}
 
Example 30
Project: freeVM   File: MemoryPoolMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void resetPeakUsage() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakUsageImpl();
}
 
Example 31
Project: freeVM   File: ClassLoadingMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
 
Example 32
Project: freeVM   File: RuntimeMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public List<String> getInputArguments() {
	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new ManagementPermission("monitor"));
	}
       
       // TODO : Retrieve the input args from the VM
       return new ArrayList<String>();
}
 
Example 33
Project: freeVM   File: MemoryMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
 
Example 34
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public long[] findMonitorDeadlockedThreads() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.findMonitorDeadlockedThreadsImpl();
}
 
Example 35
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public long[] getAllThreadIds() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.getAllThreadIdsImpl();
}
 
Example 36
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void resetPeakThreadCount() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakThreadCountImpl();
}
 
Example 37
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setThreadContentionMonitoringEnabled(boolean enable) {
    if (!isThreadContentionMonitoringSupported()) {
        throw new UnsupportedOperationException(
                "Thread contention monitoring is not supported on this virtual machine.");
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setThreadContentionMonitoringEnabledImpl(enable);
}
 
Example 38
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setThreadCpuTimeEnabled(boolean enable) {
    if (!isThreadCpuTimeSupported()) {
        throw new UnsupportedOperationException(
                "Thread CPU timing is not supported on this virtual machine.");
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setThreadCpuTimeEnabledImpl(enable);
}
 
Example 39
Project: freeVM   File: ManagementPermissionTest.java   Source Code and License 5 votes vote down vote up
public void testManagementPermissionString() {
    ManagementPermission control = new ManagementPermission("control");
    assertEquals("control", control.getName());

    ManagementPermission monitor = new ManagementPermission("monitor");
    assertEquals("monitor", monitor.getName());

    try {
        new ManagementPermission("invalid");
        fail();
    } catch (IllegalArgumentException e) {
    }
}
 
Example 40
Project: freeVM   File: ManagementPermissionTest.java   Source Code and License 5 votes vote down vote up
public void testImplies() {
    ManagementPermission mp1 = new ManagementPermission("monitor");
    ManagementPermission mp2 = new ManagementPermission("control");
    ManagementPermission mp3 = new ManagementPermission("monitor", "");
    assertTrue(mp1.implies(mp1));
    assertTrue(mp1.implies(mp3));
    assertFalse(mp1.implies(mp2));
    assertFalse(mp2.implies(mp1));
}
 
Example 41
Project: freeVM   File: MemoryPoolMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void resetPeakUsage() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakUsageImpl();
}
 
Example 42
Project: freeVM   File: ClassLoadingMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
 
Example 43
Project: freeVM   File: RuntimeMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public List<String> getInputArguments() {
	SecurityManager security = System.getSecurityManager();
	if (security != null) {
		security.checkPermission(new ManagementPermission("monitor"));
	}
       
       // TODO : Retrieve the input args from the VM
       return new ArrayList<String>();
}
 
Example 44
Project: freeVM   File: MemoryMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
 
Example 45
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public long[] findMonitorDeadlockedThreads() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.findMonitorDeadlockedThreadsImpl();
}
 
Example 46
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public long[] getAllThreadIds() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.getAllThreadIdsImpl();
}
 
Example 47
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void resetPeakThreadCount() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakThreadCountImpl();
}
 
Example 48
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setThreadContentionMonitoringEnabled(boolean enable) {
    if (!isThreadContentionMonitoringSupported()) {
        //lm.1E=Thread contention monitoring is not supported on this virtual machine.
        throw new UnsupportedOperationException(Messages.getString("lm.1E")); //$NON-NLS-1$            
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setThreadContentionMonitoringEnabledImpl(enable);
}
 
Example 49
Project: freeVM   File: ThreadMXBeanImpl.java   Source Code and License 5 votes vote down vote up
public void setThreadCpuTimeEnabled(boolean enable) {
    if (!isThreadCpuTimeSupported()) {
        //lm.01=Thread CPU timing is not supported on this virtual machine.
        throw new UnsupportedOperationException(Messages.getString("lm.01")); //$NON-NLS-1$          
    }

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setThreadCpuTimeEnabledImpl(enable);
}
 
Example 50
Project: freeVM   File: ManagementPermissionTest.java   Source Code and License 5 votes vote down vote up
public void testManagementPermissionString() {
    ManagementPermission control = new ManagementPermission("control");
    assertEquals("control", control.getName());

    ManagementPermission monitor = new ManagementPermission("monitor");
    assertEquals("monitor", monitor.getName());

    try {
        new ManagementPermission("invalid");
        fail();
    } catch (IllegalArgumentException e) {
    }
}
 
Example 51
Project: freeVM   File: ManagementPermissionTest.java   Source Code and License 5 votes vote down vote up
public void testImplies() {
    ManagementPermission mp1 = new ManagementPermission("monitor");
    ManagementPermission mp2 = new ManagementPermission("control");
    ManagementPermission mp3 = new ManagementPermission("monitor", "");
    assertTrue(mp1.implies(mp1));
    assertTrue(mp1.implies(mp3));
    assertFalse(mp1.implies(mp2));
    assertFalse(mp2.implies(mp1));
}
 
Example 52
Project: javify   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkMonitorPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("monitor"));
}
 
Example 53
Project: javify   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkControlPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("control"));
}
 
Example 54
Project: vertx-template   File: Main.java   Source Code and License 4 votes vote down vote up
private Main installSecurityPolicy() throws Exception {
  Config config = readConfig();
  List<Permission> permissions = new ArrayList<>();

  // Need access to the network interface/port to which we listen
  PortInfo listen = PortInfo.parseUrl(config.getString("listen.url", "http://localhost:8000"));
  permissions.add(new SocketPermission("*:" + listen.port(), "listen,resolve"));

  // Configurable list of servers to which we can connect
  String csv = config.getString("connect.outbound");
  if (csv != null) {
    for (String s : csv.split(",")) {
      permissions.add(new SocketPermission(s, "connect,resolve"));
    }
  }

  // For fake security we need to act as a client to our own embedded authentication
  if (config.getBooleanOrFalse("insecure.fake.security")) {
    permissions.add(new SocketPermission("localhost:" + listen.port(), "connect,resolve"));
  }

  // Connecting to centralized authentication server
  PortInfo authServer = PortInfo.parseUrl(config.getString("auth.server.base.uri"));
  if (authServer != null) {
    permissions.add(new SocketPermission(authServer.host() + ":" + authServer.port(), "connect,resolve"));
  }

  // These two are for hsqldb to store its database files
  permissions.add(new FilePermission(workDir() + "/.hsql", "read,write,delete"));
  permissions.add(new FilePermission(workDir() + "/.hsql/-", "read,write,delete"));

  // In case we are terminating SSL/TLS on the server
  permissions.add(new FilePermission(workDir() + "/local.ssl.jks", "read"));

  // Vert.x default directory for handling file uploads
  permissions.add(new FilePermission(workDir() + "/file-uploads", "read,write"));

  // The SAML implementation needs these four (xml parsing; write metadata into conf)
  permissions.add(new FilePermission(workDir() + "/conf", "read,write"));
  permissions.add(new FilePermission(workDir() + "/conf/-", "read,write"));
  permissions.add(new SecurityPermission("org.apache.xml.security.register"));
  permissions.add(new PropertyPermission("org.apache.xml.security.ignoreLineBreaks", "write"));

  // Oracle JDBC driver requires these
  Flavor flavor = Flavor.fromJdbcUrl(config.getString("database.url", "jdbc:postgresql:"));
  if (flavor == Flavor.oracle) {
    permissions.add(new MBeanServerPermission("createMBeanServer"));
    permissions.add(new ManagementPermission("control"));
    permissions.add(new MBeanPermission("*", "registerMBean"));
    permissions.add(new MBeanTrustPermission("register"));
  }

  setSecurityPolicy(permissions.toArray(new Permission[0]));
  return this;
}
 
Example 55
Project: jvm-stm   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkMonitorPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("monitor"));
}
 
Example 56
Project: jvm-stm   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkControlPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("control"));
}
 
Example 57
Project: JamVM-PH   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkMonitorPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("monitor"));
}
 
Example 58
Project: JamVM-PH   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkControlPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("control"));
}
 
Example 59
Project: classpath   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkMonitorPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("monitor"));
}
 
Example 60
Project: classpath   File: BeanImpl.java   Source Code and License 4 votes vote down vote up
protected void checkControlPermissions()
{
  SecurityManager sm = System.getSecurityManager();
  if (sm != null)
    sm.checkPermission(new ManagementPermission("control"));
}