Java Code Examples for javax.management.DynamicMBean#getAttributes()

The following examples show how to use javax.management.DynamicMBean#getAttributes() . 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: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 2
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 3
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 4
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 5
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 6
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 7
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 8
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
        MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 9
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 10
Source File: DefaultMBeanServerInterceptor.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 11
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 12
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 13
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 14
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}
 
Example 15
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public AttributeList getAttributes(ObjectName name, String[] attributes)
    throws InstanceNotFoundException, ReflectionException  {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("ObjectName name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    if (attributes == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attributes cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }

    name = nonDefaultDomain(name);

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "getAttributes", "ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    final String[] allowedAttributes;
    final SecurityManager sm = System.getSecurityManager();
    if (sm == null)
        allowedAttributes = attributes;
    else {
        final String classname = getClassName(instance);

        // Check if the caller has the right to invoke 'getAttribute'
        //
        checkMBeanPermission(classname, null, name, "getAttribute");

        // Check if the caller has the right to invoke 'getAttribute'
        // on each specific attribute
        //
        List<String> allowedList =
            new ArrayList<String>(attributes.length);
        for (String attr : attributes) {
            try {
                checkMBeanPermission(classname, attr, name, "getAttribute");
                allowedList.add(attr);
            } catch (SecurityException e) {
                // OK: Do not add this attribute to the list
            }
        }
        allowedAttributes =
                allowedList.toArray(new String[allowedList.size()]);
    }

    try {
        return instance.getAttributes(allowedAttributes);
    } catch (Throwable t) {
        rethrow(t);
        throw new AssertionError();
    }
}