Java Code Examples for javax.management.MBeanOperationInfo#getDescriptor()

The following examples show how to use javax.management.MBeanOperationInfo#getDescriptor() . 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: DcmdMBeanPermissionsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 2
Source File: DcmdMBeanPermissionsTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 3
Source File: DcmdMBeanTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 4
Source File: DcmdMBeanTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 5
Source File: DcmdMBeanTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 6
Source File: DcmdMBeanPermissionsTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 7
Source File: DcmdMBeanTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 8
Source File: DcmdMBeanPermissionsTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 9
Source File: DcmdMBeanTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 10
Source File: DcmdMBeanPermissionsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 11
Source File: DcmdMBeanTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 12
Source File: DcmdMBeanPermissionsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 13
Source File: DcmdMBeanTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 14
Source File: DcmdMBeanPermissionsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 15
Source File: DcmdMBeanTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 16
Source File: DcmdMBeanPermissionsTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 17
Source File: DcmdMBeanTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 18
Source File: DcmdMBeanPermissionsTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void testOperation(MBeanServer mbs, CustomSecurityManager sm,
        ObjectName on, MBeanOperationInfo opInfo) {
    System.out.println("Testing " + opInfo.getName());
    Descriptor desc = opInfo.getDescriptor();
    if (desc.getFieldValue("dcmd.permissionClass") == null) {
    // No special permission required, execution should not trigger
    // any security exception
        if (invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
    } else {
        // Building the required permission
        Permission reqPerm = createPermission(
                (String)desc.getFieldValue("dcmd.permissionClass"),
                (String)desc.getFieldValue("dcmd.permissionName"),
                (String)desc.getFieldValue("dcmd.permissionAction"));
        // Paranoid mode: check that the SecurityManager has not already
        // been granted the permission
        sm.denyPermission(reqPerm);
        // A special permission is required for this operation,
        // invoking it without the permission granted must trigger
        // a security exception
        if(!invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // grant the permission and re-try invoking the operation
        sm.grantPermission(reqPerm);
        if(invokeOperation(mbs, on, opInfo)) {
            throw new RuntimeException("TEST FAILED");
        }
        // Clean up
        sm.denyPermission(reqPerm);
    }
}
 
Example 19
Source File: DcmdMBeanTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 20
Source File: DcmdMBeanTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}