Java Code Examples for java.security.AccessControlException#getMessage()

The following examples show how to use java.security.AccessControlException#getMessage() . 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: NetworkServerMBeanImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static void checkPermission(SystemPermission permission)
{
    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(permission);
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }  
}
 
Example 2
Source File: JMXManagementService.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Require SystemPermission("jmx", "control") to change
 * the management state.
 */
private void checkJMXControl() {
    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(CONTROL);
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }
}
 
Example 3
Source File: NetworkServerMBeanImpl.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void checkPermission(SystemPermission permission)
{
    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(permission);
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }  
}
 
Example 4
Source File: JMXManagementService.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Require SystemPermission("jmx", "control") to change
 * the management state.
 */
private void checkJMXControl() {
    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(CONTROL);
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }
}
 
Example 5
Source File: NetworkServerMBeanImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private static void checkPermission(SystemPermission permission)
{
    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(permission);
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }  
}
 
Example 6
Source File: JMXManagementService.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Require SystemPermission("jmx", "control") to change
 * the management state.
 */
private void checkJMXControl() {
    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(CONTROL);
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }
}
 
Example 7
Source File: Version.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Ensure caller has permission to monitor Derby.
 */
private void checkMonitor() {

    try {
        if (System.getSecurityManager() != null)
            AccessController.checkPermission(
                    new SystemPermission(permissionName,
                            SystemPermission.MONITOR));
    } catch (AccessControlException e) {
        // Need to throw a simplified version as AccessControlException
        // will have a reference to Derby's SystemPermission which most likely
        // will not be available on the client.
        throw new SecurityException(e.getMessage());
    }
}
 
Example 8
Source File: ExecCommand.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 9
Source File: ExecCommand.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 10
Source File: ExecCommand.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 11
Source File: ExecCommand.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 12
Source File: ExecCommand.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 13
Source File: ExecCommand.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 14
Source File: ExecCommand.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 15
Source File: ExecCommand.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 16
Source File: ExecCommand.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 17
Source File: ExecCommand.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 18
Source File: ExecCommand.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 19
Source File: ExecCommand.java    From native-obfuscator with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}
 
Example 20
Source File: ExecCommand.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] _args) throws Exception {
    if (!System.getProperty("os.name").startsWith("Windows")) {
        return;
    }

    // tear up
    try {
        new File(".\\Program Files").mkdirs();
        for (int i = 0; i < doCmdCopy.length; ++i) {
            try (BufferedWriter outCmd = new BufferedWriter(
                         new FileWriter(doCmdCopy[i]))) {
                outCmd.write("@echo %1");
            }
        }
    } catch (IOException e) {
        throw new Error(e.getMessage());
    }

    // action
    for (int k = 0; k < 4; ++k) {
        switch (k) {
        case 0:
            // the "jdk.lang.Process.allowAmbiguousCommands" is undefined
            // "true" by default with the legacy verification procedure
            break;
        case 1:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");
            break;
        case 2:
            System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
            break;
        case 3:
            System.setSecurityManager( new SecurityMan() );
            break;
        }
        for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
            String outRes;
            try {
                // tear up
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    deleteOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    deleteOut(".\\Program Files\\dirOut.txt");
                    break;
                }

                Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
                exec.waitFor();

                //exteded check
                switch (i) {
                case 0:
                    // [cmd /C dir > dirOut.txt]
                    checkOut(".\\dirOut.txt");
                    break;
                case 1:
                    // [cmd /C dir > ".\Program Files\dirOut.txt"]
                    checkOut(".\\Program Files\\dirOut.txt");
                    break;
                }
                outRes = "Success";
            } catch (IOException ioe) {
                outRes = "IOException: " + ioe.getMessage();
            } catch (IllegalArgumentException iae) {
                outRes = "IllegalArgumentException: " + iae.getMessage();
            } catch (AccessControlException se) {
                outRes = "AccessControlException: " + se.getMessage();
            }

            if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
                throw new Error("Unexpected output! Step" + k + ":" + i
                            + "\nArgument: " + TEST_RTE_ARG[i]
                            + "\nExpected: " + TEST_RTE_GI[i][k]
                            + "\n  Output: " + outRes);
            } else {
                System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
            }
        }
    }
}