Java 类java.lang.management.ManagementPermission 实例源码

项目:cn1    文件:MemoryPoolMXBeanImpl.java   
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);
}
项目:cn1    文件:MemoryPoolMXBeanImpl.java   
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);
}
项目:cn1    文件:RuntimeMXBeanImpl.java   
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
    });
}
项目:cn1    文件:ThreadMXBeanImpl.java   
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;
}
项目:cn1    文件:ThreadMXBeanImpl.java   
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);
}
项目:freeVM    文件:MemoryPoolMXBeanImpl.java   
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);
}
项目:freeVM    文件:MemoryPoolMXBeanImpl.java   
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);
}
项目:freeVM    文件:RuntimeMXBeanImpl.java   
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
    });
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
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;
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
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);
}
项目:freeVM    文件:MemoryPoolMXBeanImpl.java   
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);
}
项目:freeVM    文件:MemoryPoolMXBeanImpl.java   
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);
}
项目:freeVM    文件:RuntimeMXBeanImpl.java   
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
    });
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
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;
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
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);
}
项目:xm-commons    文件:XmJvmSecurityUtils.java   
/**
 * 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));
    }
}
项目:elasticsearch_my    文件:JvmInfo.java   
public static JvmInfo jvmInfo() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkPermission(new ManagementPermission("monitor"));
        sm.checkPropertyAccess("*");
    }
    return INSTANCE;
}
项目:evosuite    文件:MSecurityManager.java   
protected boolean checkManagementPermission(ManagementPermission perm) {
    String name = perm.getName();

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

    /*
     * "control" sounds bit risky
     */
    return false;
}
项目:cn1    文件:MemoryPoolMXBeanImpl.java   
public void resetPeakUsage() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakUsageImpl();
}
项目:cn1    文件:ClassLoadingMXBeanImpl.java   
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
项目:cn1    文件:RuntimeMXBeanImpl.java   
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>();
}
项目:cn1    文件:MemoryMXBeanImpl.java   
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
项目:cn1    文件:ThreadMXBeanImpl.java   
public long[] findMonitorDeadlockedThreads() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.findMonitorDeadlockedThreadsImpl();
}
项目:cn1    文件:ThreadMXBeanImpl.java   
public long[] getAllThreadIds() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.getAllThreadIdsImpl();
}
项目:cn1    文件:ThreadMXBeanImpl.java   
public void resetPeakThreadCount() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakThreadCountImpl();
}
项目:cn1    文件:ThreadMXBeanImpl.java   
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);
}
项目:cn1    文件:ThreadMXBeanImpl.java   
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);
}
项目:cn1    文件:ManagementPermissionTest.java   
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) {
    }
}
项目:cn1    文件:ManagementPermissionTest.java   
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));
}
项目:freeVM    文件:MemoryPoolMXBeanImpl.java   
public void resetPeakUsage() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakUsageImpl();
}
项目:freeVM    文件:ClassLoadingMXBeanImpl.java   
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
项目:freeVM    文件:RuntimeMXBeanImpl.java   
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>();
}
项目:freeVM    文件:MemoryMXBeanImpl.java   
public void setVerbose(boolean value) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.setVerboseImpl(value);
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
public long[] findMonitorDeadlockedThreads() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.findMonitorDeadlockedThreadsImpl();
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
public long[] getAllThreadIds() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("monitor"));
    }
    return this.getAllThreadIdsImpl();
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
public void resetPeakThreadCount() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPermission(new ManagementPermission("control"));
    }
    this.resetPeakThreadCountImpl();
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
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);
}
项目:freeVM    文件:ThreadMXBeanImpl.java   
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);
}
项目:freeVM    文件:ManagementPermissionTest.java   
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) {
    }
}
项目:freeVM    文件:ManagementPermissionTest.java   
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));
}