Example usage for java.lang System setSecurityManager

List of usage examples for java.lang System setSecurityManager

Introduction

In this page you can find the example usage for java.lang System setSecurityManager.

Prototype

public static void setSecurityManager(SecurityManager sm) 

Source Link

Document

Sets the system-wide security manager.

Usage

From source file:org.apache.hadoop.hdfs.TestDFSShell.java

@Test
public void testPut() throws IOException {
    Configuration conf = new HdfsConfiguration();
    MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
    FileSystem fs = cluster.getFileSystem();
    assertTrue("Not a HDFS: " + fs.getUri(), fs instanceof DistributedFileSystem);
    final DistributedFileSystem dfs = (DistributedFileSystem) fs;

    try {/*from   www  .j  ava2 s  . c o m*/
        // remove left over crc files:
        new File(TEST_ROOT_DIR, ".f1.crc").delete();
        new File(TEST_ROOT_DIR, ".f2.crc").delete();
        final File f1 = createLocalFile(new File(TEST_ROOT_DIR, "f1"));
        final File f2 = createLocalFile(new File(TEST_ROOT_DIR, "f2"));

        final Path root = mkdir(dfs, new Path("/test/put"));
        final Path dst = new Path(root, "dst");

        show("begin");

        final Thread copy2ndFileThread = new Thread() {
            @Override
            public void run() {
                try {
                    show("copy local " + f2 + " to remote " + dst);
                    dfs.copyFromLocalFile(false, false, new Path(f2.getPath()), dst);
                } catch (IOException ioe) {
                    show("good " + StringUtils.stringifyException(ioe));
                    return;
                }
                //should not be here, must got IOException
                assertTrue(false);
            }
        };

        //use SecurityManager to pause the copying of f1 and begin copying f2
        SecurityManager sm = System.getSecurityManager();
        System.out.println("SecurityManager = " + sm);
        System.setSecurityManager(new SecurityManager() {
            private boolean firstTime = true;

            @Override
            public void checkPermission(Permission perm) {
                if (firstTime) {
                    Thread t = Thread.currentThread();
                    if (!t.toString().contains("DataNode")) {
                        String s = "" + Arrays.asList(t.getStackTrace());
                        if (s.contains("FileUtil.copyContent")) {
                            //pause at FileUtil.copyContent

                            firstTime = false;
                            copy2ndFileThread.start();
                            try {
                                Thread.sleep(5000);
                            } catch (InterruptedException e) {
                            }
                        }
                    }
                }
            }
        });
        show("copy local " + f1 + " to remote " + dst);
        dfs.copyFromLocalFile(false, false, new Path(f1.getPath()), dst);
        show("done");

        try {
            copy2ndFileThread.join();
        } catch (InterruptedException e) {
        }
        System.setSecurityManager(sm);

        // copy multiple files to destination directory
        final Path destmultiple = mkdir(dfs, new Path("/test/putmultiple"));
        Path[] srcs = new Path[2];
        srcs[0] = new Path(f1.getPath());
        srcs[1] = new Path(f2.getPath());
        dfs.copyFromLocalFile(false, false, srcs, destmultiple);
        srcs[0] = new Path(destmultiple, "f1");
        srcs[1] = new Path(destmultiple, "f2");
        assertTrue(dfs.exists(srcs[0]));
        assertTrue(dfs.exists(srcs[1]));

        // move multiple files to destination directory
        final Path destmultiple2 = mkdir(dfs, new Path("/test/movemultiple"));
        srcs[0] = new Path(f1.getPath());
        srcs[1] = new Path(f2.getPath());
        dfs.moveFromLocalFile(srcs, destmultiple2);
        assertFalse(f1.exists());
        assertFalse(f2.exists());
        srcs[0] = new Path(destmultiple2, "f1");
        srcs[1] = new Path(destmultiple2, "f2");
        assertTrue(dfs.exists(srcs[0]));
        assertTrue(dfs.exists(srcs[1]));

        f1.delete();
        f2.delete();
    } finally {
        try {
            dfs.close();
        } catch (Exception e) {
        }
        cluster.shutdown();
    }
}

From source file:org.apache.hadoop.hive.cli.TestCliDriverMethods.java

@Override
public void setUp() {
    securityManager = System.getSecurityManager();
    System.setSecurityManager(new NoExitSecurityManager(securityManager));
}

From source file:org.apache.hadoop.hive.cli.TestCliDriverMethods.java

@Override
public void tearDown() {
    System.setSecurityManager(securityManager);
}

From source file:org.apache.hadoop.tools.TestExternalCall.java

@Before
public void setup() {

    securityManager = System.getSecurityManager();
    System.setSecurityManager(new NoExitSecurityManager());
    try {/*from   www.j a v a2  s.  c o  m*/
        fs = FileSystem.get(getConf());
        root = new Path("target/tmp").makeQualified(fs.getUri(), fs.getWorkingDirectory()).toString();
        TestDistCpUtils.delete(fs, root);
    } catch (IOException e) {
        LOG.error("Exception encountered ", e);
    }
}

From source file:org.apache.hadoop.tools.TestExternalCall.java

@After
public void tearDown() {
    System.setSecurityManager(securityManager);
}

From source file:org.apache.jcs.auxiliary.remote.RemoteUtils.java

/**
 * Creates and exports a registry on the specified port of the local host.
 * <p>//  w  w w  . java2s  . co  m
 * @param port
 * @return the port the registry was started on
 * @throws RemoteException
 */
public static int createRegistry(int port) throws RemoteException {
    if (log.isInfoEnabled()) {
        log.info("createRegistry> setting security manager");
    }
    System.setSecurityManager(new RMISecurityManager());

    if (port < 1024) {
        if (log.isInfoEnabled()) {
            log.info("Port chosen was less than 1024, will use default [" + Registry.REGISTRY_PORT
                    + "] instead.");
        }
        port = Registry.REGISTRY_PORT;
    }

    if (log.isInfoEnabled()) {
        log.info("createRegistry> creating registry on port [" + port + "]");
    }
    LocateRegistry.createRegistry(port);
    return port;
}

From source file:org.apache.log4j.chainsaw.LogUI.java

/**
 * Creates, activates, and then shows the Chainsaw GUI, optionally showing
 * the splash screen, and using the passed shutdown action when the user
 * requests to exit the application (if null, then Chainsaw will exit the vm)
 *
 * @param model//from  www .  j a  v a 2 s. co  m
 * @param newShutdownAction
 *                    DOCUMENT ME!
 */
public static void createChainsawGUI(ApplicationPreferenceModel model, Action newShutdownAction) {

    if (model.isOkToRemoveSecurityManager()) {
        MessageCenter.getInstance()
                .addMessage("User has authorised removal of Java Security Manager via preferences");
        System.setSecurityManager(null);
        // this SHOULD set the Policy/Permission stuff for any
        // code loaded from our custom classloader.  
        // crossing fingers...
        Policy.setPolicy(new Policy() {

            public void refresh() {
            }

            public PermissionCollection getPermissions(CodeSource codesource) {
                Permissions perms = new Permissions();
                perms.add(new AllPermission());
                return (perms);
            }
        });
    }

    final LogUI logUI = new LogUI();
    logUI.applicationPreferenceModel = model;

    if (model.isShowSplash()) {
        showSplash(logUI);
    }
    logUI.cyclicBufferSize = model.getCyclicBufferSize();
    logUI.pluginRegistry = repositoryExImpl.getPluginRegistry();

    logUI.handler = new ChainsawAppenderHandler();
    logUI.handler.addEventBatchListener(logUI.new NewTabEventBatchReceiver());

    /**
     * TODO until we work out how JoranConfigurator might be able to have
     * configurable class loader, if at all.  For now we temporarily replace the
     * TCCL so that Plugins that need access to resources in 
     * the Plugins directory can find them (this is particularly
     * important for the Web start version of Chainsaw
     */
    //configuration initialized here
    logUI.ensureChainsawAppenderHandlerAdded();
    logger = LogManager.getLogger(LogUI.class);

    //set hostname, application and group properties which will cause Chainsaw and other apache-generated
    //logging events to route (by default) to a tab named 'chainsaw-log'
    PropertyRewritePolicy policy = new PropertyRewritePolicy();
    policy.setProperties("hostname=chainsaw,application=log,group=chainsaw");

    RewriteAppender rewriteAppender = new RewriteAppender();
    rewriteAppender.setRewritePolicy(policy);

    Enumeration appenders = Logger.getLogger("org.apache").getAllAppenders();
    if (!appenders.hasMoreElements()) {
        appenders = Logger.getRootLogger().getAllAppenders();
    }
    while (appenders.hasMoreElements()) {
        Appender nextAppender = (Appender) appenders.nextElement();
        rewriteAppender.addAppender(nextAppender);
    }
    Logger.getLogger("org.apache").removeAllAppenders();
    Logger.getLogger("org.apache").addAppender(rewriteAppender);
    Logger.getLogger("org.apache").setAdditivity(false);

    //commons-vfs uses httpclient for http filesystem support, route this to the chainsaw-log tab as well
    appenders = Logger.getLogger("httpclient").getAllAppenders();
    if (!appenders.hasMoreElements()) {
        appenders = Logger.getRootLogger().getAllAppenders();
    }
    while (appenders.hasMoreElements()) {
        Appender nextAppender = (Appender) appenders.nextElement();
        rewriteAppender.addAppender(nextAppender);
    }
    Logger.getLogger("httpclient").removeAllAppenders();
    Logger.getLogger("httpclient").addAppender(rewriteAppender);
    Logger.getLogger("httpclient").setAdditivity(false);

    //set the commons.vfs.cache logger to info, since it can contain password information
    Logger.getLogger("org.apache.commons.vfs.cache").setLevel(Level.INFO);

    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            e.printStackTrace();
            logger.error("Uncaught exception in thread " + t, e);
        }
    });

    String config = configurationURLAppArg;
    if (config != null) {
        logger.info("Command-line configuration arg provided (overriding auto-configuration URL) - using: "
                + config);
    } else {
        config = model.getConfigurationURL();
    }

    if (config != null && (!config.trim().equals(""))) {
        config = config.trim();
        try {
            URL configURL = new URL(config);
            logger.info("Using '" + config + "' for auto-configuration");
            logUI.loadConfigurationUsingPluginClassLoader(configURL);
        } catch (MalformedURLException e) {
            logger.error("Initial configuration - failed to convert config string to url", e);
        } catch (IOException e) {
            logger.error("Unable to access auto-configuration URL: " + config);
        }
    }

    //register a listener to load the configuration when it changes (avoid having to restart Chainsaw when applying a new configuration)
    //this doesn't remove receivers from receivers panel, it just triggers DOMConfigurator.configure.
    model.addPropertyChangeListener("configurationURL", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            String newConfiguration = evt.getNewValue().toString();
            if (newConfiguration != null && !(newConfiguration.trim().equals(""))) {
                newConfiguration = newConfiguration.trim();
                try {
                    logger.info("loading updated configuration: " + newConfiguration);
                    URL newConfigurationURL = new URL(newConfiguration);
                    File file = new File(newConfigurationURL.toURI());
                    if (file.exists()) {
                        logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
                    } else {
                        logger.info("Updated configuration but file does not exist");
                    }
                } catch (MalformedURLException e) {
                    logger.error("Updated configuration - failed to convert config string to URL", e);
                } catch (URISyntaxException e) {
                    logger.error("Updated configuration - failed to convert config string to URL", e);
                }
            }
        }
    });

    LogManager.getRootLogger().setLevel(Level.TRACE);
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            logUI.activateViewer();
        }
    });

    logger.info("SecurityManager is now: " + System.getSecurityManager());

    if (newShutdownAction != null) {
        logUI.setShutdownAction(newShutdownAction);
    } else {
        logUI.setShutdownAction(new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
    }
}

From source file:org.apache.oozie.tools.TestOozieSharelibCLI.java

@Override
protected void tearDown() throws Exception {
    System.setSecurityManager(SECURITY_MANAGER);
    if (services != null) {
        services.destroy();//from ww  w. ja v a2 s . co m
    }
    tmpFolder.delete();
    super.tearDown();
}

From source file:org.azyva.dragom.test.integration.IntegrationTestSuite.java

/**
 * Main method./*  w  ww.  j a  v a 2s .c om*/
 *
 * @param args Arguments.
 */
public static void main(String[] args) {
    Set<String> setTestCategory;
    boolean indAllTests;

    System.setSecurityManager(new NoExitSecurityManager());

    EclipseSynchronizeErrOut.fix();

    IntegrationTestSuite.inputStreamDouble = new InputStreamDouble();
    System.setIn(IntegrationTestSuite.inputStreamDouble);

    if (args.length == 0) {
        IntegrationTestSuite.pathTestWorkspace = Paths.get(System.getProperty("user.dir"))
                .resolve("test-workspace");
        System.out.println(
                "Test workspace directory not specified. Using \"test-workspace\" subdirectory of current directory "
                        + IntegrationTestSuite.pathTestWorkspace + '.');
    } else {
        IntegrationTestSuite.pathTestWorkspace = Paths.get(args[0]);
        System.out.println(
                "Using specified test workspace directory " + IntegrationTestSuite.pathTestWorkspace + '.');

        args = Arrays.copyOfRange(args, 1, args.length);
    }

    setTestCategory = new HashSet<String>(Arrays.asList(args));
    indAllTests = setTestCategory.contains("all");

    if (indAllTests || setTestCategory.contains("DragomToolInvoker")) {
        IntegrationTestSuiteDragomToolInvoker.testDragomToolInvoker();
    }

    if (indAllTests || setTestCategory.contains("ExecContextManagerTool")) {
        IntegrationTestSuiteExecContextManagerTool.testExecContextManagerTool();
    }

    if (indAllTests || setTestCategory.contains("RootManagerTool")) {
        IntegrationTestSuiteRootManagerTool.testRootManagerTool();
    }

    if (indAllTests || setTestCategory.contains("CredentialManagerTool")) {
        IntegrationTestSuiteCredentialManagerTool.testCredentialManagerTool();
    }

    if (indAllTests || setTestCategory.contains("GenericRootModuleVersionJobInvokerTool")) {
        IntegrationTestSuiteGenericRootModuleVersionJobInvokerTool.testGenericRootModuleVersionJobInvokerTool();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolBase")) {
        IntegrationTestSuiteCheckoutToolBase.testCheckoutToolBase();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolConflict")) {
        IntegrationTestSuiteCheckoutToolConflict.testCheckoutToolConflict();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolSwitch")) {
        IntegrationTestSuiteCheckoutToolSwitch.testCheckoutToolSwitch();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolMultipleBase")) {
        IntegrationTestSuiteCheckoutToolMultipleBase.testCheckoutToolMultipleBase();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolMultipleConflict")) {
        IntegrationTestSuiteCheckoutToolMultipleConflict.testCheckoutToolMultipleConflict();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolMultipleSwitch")) {
        IntegrationTestSuiteCheckoutToolMultipleSwitch.testCheckoutToolMultipleSwitch();
    }

    if (indAllTests || setTestCategory.contains("CheckoutToolMultipleVersions")) {
        IntegrationTestSuiteCheckoutToolMultipleVersions.testCheckoutToolMultipleVersions();
    }

    if (indAllTests || setTestCategory.contains("WorkspaceManagerToolBase")) {
        IntegrationTestSuiteWorkspaceManagerToolBase.testWorkspaceManagerToolBase();
    }

    if (indAllTests || setTestCategory.contains("WorkspaceManagerToolStatusUpdateCommit")) {
        IntegrationTestSuiteWorkspaceManagerToolStatusUpdateCommit.testWorkspaceManagerToolStatusUpdateCommit();
    }

    if (indAllTests || setTestCategory.contains("WorkspaceManagerToolClean")) {
        IntegrationTestSuiteWorkspaceManagerToolClean.testWorkspaceManagerToolClean();
    }

    if (indAllTests || setTestCategory.contains("WorkspaceManagerToolBuildClean")) {
        IntegrationTestSuiteWorkspaceManagerToolBuildClean.testWorkspaceManagerToolBuildClean();
    }

    if (indAllTests || setTestCategory.contains("BuildToolBase")) {
        IntegrationTestSuiteBuildToolBase.testBuildToolBase();
    }

    if (indAllTests || setTestCategory.contains("BuildToolUserSystemMode")) {
        IntegrationTestSuiteBuildToolUserSystemMode.testBuildToolUserSystemMode();
    }

    if (indAllTests || setTestCategory.contains("BuildToolMavenBuilderPluginImplConfig")) {
        IntegrationTestSuiteBuildToolMavenBuilderPluginImplConfig.testBuildToolMavenBuilderPluginImplConfig();
    }

    if (indAllTests || setTestCategory.contains("ReferenceGraphReportToolBase")) {
        IntegrationTestSuiteReferenceGraphReportToolBase.testReferenceGraphReportToolBase();
    }

    if (indAllTests || setTestCategory.contains("ReferenceGraphReportToolReport")) {
        IntegrationTestSuiteReferenceGraphReportToolReport.testReferenceGraphReportToolReport();
    }

    if (indAllTests || setTestCategory.contains("SwitchToDynamicVersionToolBase")) {
        IntegrationTestSuiteSwitchToDynamicVersionToolBase.testSwitchToDynamicVersionToolBase();
    }

    if (indAllTests || setTestCategory.contains("SwitchToDynamicVersionToolRecurse")) {
        IntegrationTestSuiteSwitchToDynamicVersionToolRecurse.testSwitchToDynamicVersionToolRecurse();
    }

    if (indAllTests || setTestCategory.contains("SwitchToDynamicVersionToolReferenceChange")) {
        IntegrationTestSuiteSwitchToDynamicVersionToolReferenceChange
                .testSwitchToDynamicVersionToolReferenceChange();
    }

    if (indAllTests || setTestCategory.contains("SwitchToDynamicVersionToolHotfix")) {
        IntegrationTestSuiteSwitchToDynamicVersionToolHotfix.testSwitchToDynamicVersionToolHotfix();
    }

    if (indAllTests || setTestCategory.contains("SwitchToDynamicVersionToolPhase")) {
        IntegrationTestSuiteSwitchToDynamicVersionToolPhase.testSwitchToDynamicVersionToolPhase();
    }

    if (indAllTests || setTestCategory.contains("ReleaseToolBase")) {
        IntegrationTestSuiteReleaseToolBase.testReleaseToolBase();
    }

    if (indAllTests || setTestCategory.contains("ReleaseVersionToolRecurse")) {
        IntegrationTestSuiteReleaseToolRecurse.testReleaseToolRecurse();
    }

    if (indAllTests || setTestCategory.contains("ReleaseVersionToolSemantic")) {
        IntegrationTestSuiteReleaseToolSemantic.testReleaseToolSemantic();
        //??? incomplete. ANd there seems to be a bug with main workspace directory concept.
    }
    /*
    TODO:
        if (indAllTests || setTestCategory.contains("ReleaseVersionToolPhase")) {
          IntegrationTestSuiteCreateStaticVersionToolPhase.testCreateStaticVersionToolPhase();
        }
    */

    if (indAllTests || setTestCategory.contains("ReleaseToolMainModuleVersion")) {
        //TODO:
        IntegrationTestSuiteReleaseToolMainModuleVersion.testReleaseToolMainModuleVersion();
    }

    if (indAllTests || setTestCategory.contains("ReleaseToolMainModuleVersion")) {
        //TODO:
        IntegrationTestSuiteReleaseToolMainModuleVersion.testReleaseToolMainModuleVersion();
    }

    if (indAllTests || setTestCategory.contains("MergeMainToolBase")) {
        IntegrationTestSuiteMergeMainToolBase.testMergeMainToolBase();
    }

    if (indAllTests || setTestCategory.contains("SetupJenkinsJobsToolBase")) {
        IntegrationTestSuiteSetupJenkinsJobsToolBase.testSetupJenkinsJobsToolBase();
    }

    if (indAllTests || setTestCategory.contains("MutableModelSimpleConfig")) {
        IntegrationTestSuiteMutableModelSimpleConfig.testMutableModelSimpleConfig();
    }

    //    build-remote
    //    change-reference-to-module-version
    //    merge-main
    //    merge-reference-graph
}

From source file:org.codehaus.mojo.antlr.AbstractAntlrMojo.java

protected void performGeneration(GenerationPlan plan, Artifact antlrArtifact) throws MojoExecutionException {
    if (!plan.getGenerationDirectory().getParentFile().exists()) {
        plan.getGenerationDirectory().getParentFile().mkdirs();
    }//from   w w w.  j av a 2  s  . c o m

    // ----------------------------------------------------------------------
    // Wrap arguments
    // Note: grammar file should be last
    // ----------------------------------------------------------------------

    List arguments = new LinkedList();
    addArgIf(arguments, debug, "-debug");
    addArgIf(arguments, diagnostic, "-diagnostic");
    addArgIf(arguments, trace, "-trace");
    addArgIf(arguments, traceParser, "-traceParser");
    addArgIf(arguments, traceLexer, "-traceLexer");
    addArgIf(arguments, traceTreeParser, "-traceTreeParser");

    addArgs(arguments);

    arguments.add("-o");
    arguments.add(plan.getGenerationDirectory().getPath());

    if (plan.getCollectedSuperGrammarIds().size() > 0) {
        arguments.add("-glib");
        StringBuffer buffer = new StringBuffer();
        Iterator ids = plan.getCollectedSuperGrammarIds().iterator();
        while (ids.hasNext()) {
            buffer.append(new File(sourceDirectory, (String) ids.next()));
            if (ids.hasNext()) {
                buffer.append(';');
            }
        }
        arguments.add(buffer.toString());
    }

    arguments.add(plan.getSource().getPath());

    String[] args = (String[]) arguments.toArray(new String[arguments.size()]);

    if (plan.getImportVocabTokenTypesDirectory() != null
            && !plan.getImportVocabTokenTypesDirectory().equals(plan.getGenerationDirectory())) {
        // we need to spawn a new process to properly set up PWD
        CommandLine commandLine = new CommandLine("java");
        commandLine.addArgument("-classpath", false);
        commandLine.addArgument(generateClasspathForProcessSpawning(antlrArtifact), true);
        commandLine.addArgument("antlr.Tool", false);
        commandLine.addArguments(args, true);
        DefaultExecutor executor = new DefaultExecutor();
        executor.setWorkingDirectory(plan.getImportVocabTokenTypesDirectory());
        try {
            executor.execute(commandLine);
        } catch (IOException e) {
            getLog().warn("Error spawning process to execute antlr tool : " + e.getMessage());
        }

        return;
    }

    // ----------------------------------------------------------------------
    // Call Antlr
    // ----------------------------------------------------------------------

    if (getLog().isDebugEnabled()) {
        getLog().debug("antlr args=\n" + StringUtils.join(args, "\n"));
    }

    boolean failedSetManager = false;
    SecurityManager oldSm = null;
    try {
        oldSm = System.getSecurityManager();
        System.setSecurityManager(NoExitSecurityManager.INSTANCE);
    } catch (SecurityException ex) {
        // ANTLR-12
        oldSm = null;
        failedSetManager = true;
        // ignore, in embedded environment the security manager can already be set.
        // in such a case assume the exit call is handled properly..
        getLog().warn("Cannot set custom SecurityManager. "
                + "Antlr's call to System.exit() can cause application shutdown "
                + "if not handled by the current SecurityManager.");
    }

    String originalUserDir = null;
    if (plan.getImportVocabTokenTypesDirectory() != null) {
        originalUserDir = System.getProperty("user.dir");
        System.setProperty("user.dir", plan.getImportVocabTokenTypesDirectory().getPath());
    }

    PrintStream oldErr = System.err;

    OutputStream errOS = new StringOutputStream();
    PrintStream err = new PrintStream(errOS);
    System.setErr(err);

    try {
        executeAntlrInIsolatedClassLoader((String[]) arguments.toArray(new String[0]), antlrArtifact);
    } catch (SecurityException e) {
        if (e.getMessage().equals("exitVM-0")
                || e.getClass().getName().equals("org.netbeans.core.execution.ExitSecurityException")) // netbeans
                                                                                                                                             // IDE Sec
                                                                                                                                             // Manager.
        {
            // ANTLR-12
            // now basically every secutiry manager could set different message, how to handle in generic way?
            // probably only by external execution
            // / in case of NetBeans SecurityManager, it's not possible to distinguish exit codes, rather swallow
            // than fail.
            getLog().debug(e);
        } else {
            throw new MojoExecutionException(
                    "Antlr execution failed: " + e.getMessage() + "\n Error output:\n" + errOS, e);
        }
    } finally {
        if (originalUserDir != null) {
            System.setProperty("user.dir", originalUserDir);
        }
        if (!failedSetManager) {
            System.setSecurityManager(oldSm);
        }
        System.setErr(oldErr);
        System.err.println(errOS.toString());
    }
}