com.sun.jmx.mbeanserver.GetPropertyAction Java Examples

The following examples show how to use com.sun.jmx.mbeanserver.GetPropertyAction. 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: MBeanServerAccessController.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #2
Source File: MBeanServerAccessController.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #3
Source File: TabularDataSupport.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #4
Source File: OpenType.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #5
Source File: TabularDataSupport.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #6
Source File: OpenType.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #7
Source File: MBeanServerAccessController.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #8
Source File: TabularDataSupport.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #9
Source File: OpenType.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #10
Source File: MBeanServerAccessController.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #11
Source File: TabularDataSupport.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #12
Source File: OpenType.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #13
Source File: OpenType.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #14
Source File: TabularDataSupport.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #15
Source File: OpenType.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #16
Source File: MBeanServerAccessController.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #17
Source File: TabularDataSupport.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #18
Source File: OpenType.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #19
Source File: MBeanServerAccessController.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #20
Source File: TabularDataSupport.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #21
Source File: OpenType.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #22
Source File: MBeanServerAccessController.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #23
Source File: TabularDataSupport.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #24
Source File: OpenType.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #25
Source File: MBeanServerAccessController.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #26
Source File: TabularDataSupport.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #27
Source File: OpenType.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}
 
Example #28
Source File: MBeanServerAccessController.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkMLetMethods(ObjectName name, String operation)
throws InstanceNotFoundException {
    // Check if security manager installed
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        return;
    }
    // Check for addURL and getMBeansFromURL methods
    if (!operation.equals("addURL") &&
            !operation.equals("getMBeansFromURL")) {
        return;
    }
    // Check if MBean is instance of MLet
    if (!getMBeanServer().isInstanceOf(name,
            "javax.management.loading.MLet")) {
        return;
    }
    // Throw security exception
    if (operation.equals("addURL")) { // addURL
        throw new SecurityException("Access denied! MLet method addURL " +
                "cannot be invoked unless a security manager is installed.");
    } else { // getMBeansFromURL
        // Whether or not calling getMBeansFromURL is allowed is controlled
        // by the value of the "jmx.remote.x.mlet.allow.getMBeansFromURL"
        // system property. If the value of this property is true, calling
        // the MLet's getMBeansFromURL method is allowed. The default value
        // for this property is false.
        final String propName = "jmx.remote.x.mlet.allow.getMBeansFromURL";
        GetPropertyAction propAction = new GetPropertyAction(propName);
        String propValue = AccessController.doPrivileged(propAction);
        boolean allowGetMBeansFromURL = "true".equalsIgnoreCase(propValue);
        if (!allowGetMBeansFromURL) {
            throw new SecurityException("Access denied! MLet method " +
                    "getMBeansFromURL cannot be invoked unless a " +
                    "security manager is installed or the system property " +
                    "-Djmx.remote.x.mlet.allow.getMBeansFromURL=true " +
                    "is specified.");
        }
    }
}
 
Example #29
Source File: TabularDataSupport.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>,
 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor.
 *
 * @param  tabularType               the <i>tabular type</i> describing this <tt>TabularData</tt> instance;
 *                           cannot be null.
 *
 * @param  initialCapacity   the initial capacity of the HashMap.
 *
 * @param  loadFactor        the load factor of the HashMap
 *
 * @throws IllegalArgumentException  if the initial capacity is less than zero,
 *                                   or the load factor is nonpositive,
 *                                   or the tabular type is null.
 */
public TabularDataSupport(TabularType tabularType, int initialCapacity, float loadFactor) {

    // Check tabularType is not null
    //
    if (tabularType == null) {
        throw new IllegalArgumentException("Argument tabularType cannot be null.");
    }

    // Initialize this.tabularType (and indexNamesArray for convenience)
    //
    this.tabularType = tabularType;
    List<String> tmpNames = tabularType.getIndexNames();
    this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

    // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
    // if very unlikely that we might be the server of a 1.3 client.  In
    // that case you'll need to set this property.  See CR 6334663.
    String useHashMapProp = AccessController.doPrivileged(
            new GetPropertyAction("jmx.tabular.data.hash.map"));
    boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp);

    // Construct the empty contents HashMap
    //
    this.dataMap = useHashMap ?
        new HashMap<Object,CompositeData>(initialCapacity, loadFactor) :
        new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor);
}
 
Example #30
Source File: OpenType.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void checkClassNameOverride() throws SecurityException {
    if (this.getClass().getClassLoader() == null)
        return;  // We trust bootstrap classes.
    if (overridesGetClassName(this.getClass())) {
        final GetPropertyAction getExtendOpenTypes =
            new GetPropertyAction("jmx.extend.open.types");
        if (AccessController.doPrivileged(getExtendOpenTypes) == null) {
            throw new SecurityException("Cannot override getClassName() " +
                    "unless -Djmx.extend.open.types");
        }
    }
}