Package io.hawt.jmx

Interface JMXSecurityMBean

  • All Known Implementing Classes:
    JMXSecurity

    public interface JMXSecurityMBean
    Snagged from Apache Karaf 3.x

    Security MBean. This MBean can be used to find out whether the currently logged in user can access certain MBeans or invoke operations on these MBeans. It can be used when building client-facing consoles to ensure that only operations appropriate for the current user are presented.

    This MBean does not actually invoke any operations on the given objects, it only checks permissions.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean canInvoke​(java.lang.String objectName)
      Checks whether the current user can invoke any methods on a JMX MBean.
      boolean canInvoke​(java.lang.String objectName, java.lang.String methodName)
      Checks whether the current user can invoke any overload of the given method.
      boolean canInvoke​(java.lang.String objectName, java.lang.String methodName, java.lang.String[] argumentTypes)
      Checks whether the current user can invoke the given method.
      javax.management.openmbean.TabularData canInvoke​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> bulkQuery)
      Bulk operation to check whether the current user can access the requested MBeans or invoke the requested methods.
    • Field Detail

      • CAN_INVOKE_TABULAR_TYPE

        static final javax.management.openmbean.TabularType CAN_INVOKE_TABULAR_TYPE
        The Tabular Type returned by the canInvoke(Map) operation. The rows consist of CAN_INVOKE_RESULT_ROW_TYPE entries. It has a composite key with consists of the "ObjectName" and "Method" columns.
      • CAN_INVOKE_RESULT_COLUMNS

        static final java.lang.String[] CAN_INVOKE_RESULT_COLUMNS
        The columns contained in a CAN_INVOKE_RESULT_ROW_TYPE. The data types for these columns are as follows:
        • "ObjectName" : SimpleType.STRING
        • "Method" : SimpleType.STRING
        • "CanInvoke" : SimpleType.BOOLEAN
    • Method Detail

      • canInvoke

        boolean canInvoke​(java.lang.String objectName)
                   throws java.lang.Exception
        Checks whether the current user can invoke any methods on a JMX MBean.
        Parameters:
        objectName - The Object Name of the JMX MBean.
        Returns:
        true if there is at least one method on the MBean that the user can invoke.
        Throws:
        java.lang.Exception
      • canInvoke

        boolean canInvoke​(java.lang.String objectName,
                          java.lang.String methodName)
                   throws java.lang.Exception
        Checks whether the current user can invoke any overload of the given method.
        Parameters:
        objectName - The Object Name of the JMX MBean.
        methodName - The name of the method to check.
        Returns:
        true if there is an overload of the specified method that the user can invoke.
        Throws:
        java.lang.Exception
      • canInvoke

        boolean canInvoke​(java.lang.String objectName,
                          java.lang.String methodName,
                          java.lang.String[] argumentTypes)
                   throws java.lang.Exception
        Checks whether the current user can invoke the given method.
        Parameters:
        objectName - The Object Name of the JMX MBean.
        methodName - The name of the method to check.
        argumentTypes - The argument types of to method.
        Returns:
        true if the user is allowed to invoke the method, or any of the methods with the given name if null is used for the arguments. There may still be certain values that the user does not have permission to pass to the method.
        Throws:
        java.lang.Exception
      • canInvoke

        javax.management.openmbean.TabularData canInvoke​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> bulkQuery)
                                                  throws java.lang.Exception
        Bulk operation to check whether the current user can access the requested MBeans or invoke the requested methods.
        Parameters:
        bulkQuery - A map of Object Name to requested operations. Operations can be specified with or without arguments types. An operation without arguments matches any overloaded method with this name. If an empty list is provided for the operation names, a check is done whether the current user can invoke any operation on the MBean.

        Example:

        
                                           Map<String, List<String>> query = new HashMap<>();
                                           String objectName = "org.acme:type=SomeMBean";
                                           query.put(objectName, Arrays.asList(
                                               "testMethod(long,java.lang.String)", // check this testMethod
                                               "otherMethod"));                     // check any overload of otherMethod
                                           query.put("org.acme:type=SomeOtherMBean",
                                               Collections.<String>emptyList());    // check any method of SomeOtherMBean
                                           TabularData result = mb.canInvoke(query);
                                           
        Returns:
        A Tabular Data object with the result. This object conforms the structure as defined in CAN_INVOKE_TABULAR_TYPE.
        Throws:
        java.lang.Exception