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:com.ixora.rms.ui.RMSFrame.java

/**
 * Display the main window of the application to the user.
 * @throws FailedToSaveConfiguration/*from  w  w  w .j av a 2 s . c o m*/
 * @throws SocketException
 * @throws RMSException
 */
private static void initApplication() throws SocketException, FailedToSaveConfiguration, RMSException {
    // first thing to do:
    // initialize the message repository, set the default
    // repository to the repository for the main application component
    MessageRepository.initialize(RMSComponent.NAME);

    // assign a public IP address for the console to use
    String currentConsoleIpAddress = ConfigurationMgr.getString(RMSComponent.NAME,
            RMSConfigurationConstants.NETWORK_ADDRESS);
    if (Utils.isEmptyString(currentConsoleIpAddress)) {
        // tell RMI to use the fully qualified name for this host
        // for object references
        System.setProperty("java.rmi.server.useLocalHostname", "true");
    } else {
        System.setProperty("java.rmi.server.hostname", currentConsoleIpAddress);
    }

    // register deployment modules with the update manager
    UpdateMgr.registerModule(new IxoraCommonModule());
    UpdateMgr.registerModule(new RMSModule());
    UpdateMgr.registerNodeModule(new IxoraCommonModule());
    UpdateMgr.registerNodeModule(new RMSModule());

    // ConfigurationMgr.makeConfigurationEditable(PreferencesConfigurationConstants.PREFERENCES);
    ConfigurationMgr.makeConfigurationEditable(RMSComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(DataViewBoardComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(ChartsBoardComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(TablesBoardComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(PropertiesBoardComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(LogBoardComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(LogComponent.NAME);
    //      ConfigurationMgr.makeConfigurationEditable(LogComponentDB.NAME);
    // ConfigurationMgr.makeConfigurationEditable(LogComponentXML.NAME);
    ConfigurationMgr.makeConfigurationEditable(MonitoringSessionRepositoryComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(JobsComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(ReactionsComponent.NAME);
    ConfigurationMgr.makeConfigurationEditable(ReactionsEmailComponent.NAME);
    // ConfigurationMgr.makeConfigurationEditable(UpdateComponent.NAME);

    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new java.rmi.RMISecurityManager());
    }

    try {
        // initialize RMS
        RMS.initialize();
    } catch (Exception e) {
        // this could happen if a special IP address has been assigned to
        // the console has changed since last time the app was started
        if (e.getCause() instanceof ExportException || Utils.getTrace(e).toString().contains("Port")) {
            logger.error("Ignoring the ip address assigned to the console " + currentConsoleIpAddress
                    + " as it seems to be invalid.");
            resetConsoleIpAddress();
            // try again
            RMS.initialize();
        } else {
            throw new AppRuntimeException(e);
        }
    }

    // do a quick ping to website to check for updates
    UpdateMgr.checkForUpdates();

    // build the GUI on the event dispatch thread
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                // install UI factory in the commons library
                UIFactoryMgr.installUIFactory(new RMSUIFactory());
                // JDialog.setDefaultLookAndFeelDecorated(true);
                // JFrame.setDefaultLookAndFeelDecorated(true);
                // Toolkit.getDefaultToolkit().setDynamicLayout(true);
                Toolkit.getDefaultToolkit().setDynamicLayout(false);
                AppFrameParameters params = new AppFrameParameters();
                params.setString(AppFrameParameters.LOOK_AND_FEEL_CLASS,
                        "javax.swing.plaf.metal.MetalLookAndFeel");
                //"com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
                params.setString(AppFrameParameters.FEEDBACK_URL,
                        "http://spreadsheets.google.com/formResponse");
                JFrame frame = new RMSFrame(params);
                UIUtils.maximizeFrameAndShow(frame);
            } catch (Throwable e) {
                logger.error(e);
                System.exit(1);
            }
        }
    });
}

From source file:com.symbian.driver.launch.DriverLaunch.java

/**
 * creatJob : create an eclipse Job//from  ww w . j a  v a  2  s. c  om
 * 
 * @param Task
 *            aTask : The root task to run
 * @param int
 *            aNumberOfTasks : the number of tasks to run
 * @param boolean
 *            aIsBuild : true = build, false = run
 * 
 * @param boolean
 *            aClearConsole : clear the console. This will be used for
 *            build+run to keep the console between jobs.
 * @return Job
 */
public Job createJob(final ILaunchConfiguration aLaunchConfig, final boolean aIsBuild,
        final boolean aCleanConsole, final boolean aKeepLog) {

    final Job lJob = new Job("Test Driver Job") {

        private Logger LOGGER;

        private Task lTask = null;

        protected IStatus run(final IProgressMonitor aProgressMonitor) {

            class ProgressMonitorThread extends Thread {

                private IProgressMonitor iProgressMonitor = aProgressMonitor;
                private boolean isDone = false;

                public void run() {
                    while (!isDone) {
                        if (iProgressMonitor.isCanceled()) {
                            DeviceUtils.stopPoll();
                            break;
                        }
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException ignore) {
                        }
                    }
                }

                public void done() {
                    isDone = true;
                }
            }
            ;

            ProgressMonitorThread lProgressCancel = new ProgressMonitorThread();
            lProgressCancel.start();

            // configure logging again this will happen when the job starts
            TDGUIConfigLogging lLogConf = TDGUIConfigLogging.getInstance();
            lLogConf.configureLogging(aKeepLog);

            UIUtils.getDisplay().asyncExec(new ShowView());

            LOGGER = Logger.getLogger(Job.class.getName());

            LOGGER.info("\n\n*******Starting Job : " + this.getName());

            // configure TestDriver from Preferences and launch
            // configuration
            try {
                TestDriverConfigurator.configTestDriver(aLaunchConfig);
            } catch (ParseException lParseException) {
                return new Status(IStatus.ERROR, DriverEditorPlugin.ID, IStatus.ERROR,
                        this.getName() + " failed to set TestDriver configuration, see TestDriver log file.",
                        lParseException);
            }

            TDConfig CONFIG = TDConfig.newInstance();

            try {
                CONFIG.printConfig(true);
            } catch (IOException lException) {
                LOGGER.log(Level.SEVERE, lException.getMessage(), lException);
            }

            // try to load the driver file and get the task for real.
            try {
                ResourceLoader.resetResourceSet();
                lTask = ResourceLoader.load();
            } catch (ParseException lPex) {
                // log and error and finish the Job
                LOGGER.log(Level.SEVERE, "Failed to load resource : " + lPex.getMessage(), lPex);
                return new Status(IStatus.ERROR, DriverEditorPlugin.ID, IStatus.ERROR,
                        this.getName() + " failed to load the driver file, please check your configuration.",
                        lPex);
            }

            if (lTask == null) {
                return new Status(IStatus.ERROR, DriverEditorPlugin.ID, IStatus.ERROR,
                        this.getName()
                                + " --- failed to find the requested suite, please check your configuration.",
                        null);
            }
            int lNumberOfTasks = 1;

            for (Iterator lTaskIter = lTask.eAllContents(); lTaskIter.hasNext();) {
                Object lObject = lTaskIter.next();
                // this list must much the visitor listerners we are passing
                // in the job.
                if (aIsBuild) {
                    if (lObject instanceof Task || lObject instanceof CmdPC || lObject instanceof Build
                            || lObject instanceof TestExecuteScript || lObject instanceof Transfer
                            || lObject instanceof Reference || lObject instanceof CmdSymbian
                            || lObject instanceof Rtest) {
                        lNumberOfTasks++;
                    }
                } else {
                    if (lObject instanceof Task || lObject instanceof TestExecuteScript
                            || lObject instanceof Transfer || lObject instanceof Reference
                            || lObject instanceof CmdSymbian || lObject instanceof Rtest) {
                        lNumberOfTasks++;
                    }
                }
            }
            // add parent levels
            lNumberOfTasks = lNumberOfTasks + lTask.getLevel();

            aProgressMonitor.beginTask((aIsBuild ? "Building" : "Running") + " task " + lTask.getName(),
                    lNumberOfTasks);

            final Visitor lVisitor;

            if (aIsBuild) {
                lVisitor = new PCVisitor();
                ((PCVisitor) lVisitor).setRBuild(iRBuild);
            } else {
                lVisitor = new SymbianVisitor();
            }

            // show the Test Result view

            UIUtils.getDisplay().asyncExec(new Runnable() {
                public void run() {
                    TestViewer.getInstance().setInput(lVisitor.getResult().getReport());
                }
            });

            lVisitor.addVisitorListener(new IVisitorEventListener() {

                public void taskFinished(TaskFinishedEvent aVisitorEvent) {

                    EObject lVisitObject = aVisitorEvent.getEObject();
                    if (lVisitObject instanceof Task) {
                        aProgressMonitor.subTask("Finished task: " + ((Task) lVisitObject).getName());
                    } else if (lVisitObject instanceof CmdPC) {
                        aProgressMonitor
                                .subTask("Finished Running PC command: " + ((CmdPC) lVisitObject).getURI());
                    } else if (lVisitObject instanceof Build) {
                        aProgressMonitor
                                .subTask("Finished Building group dir: " + ((Build) lVisitObject).getURI());
                    } else if (lVisitObject instanceof TestExecuteScript) {
                        if (aIsBuild) {
                            aProgressMonitor.subTask("Finished Copying TEF Script to repository: "
                                    + ((TestExecuteScript) lVisitObject).getPCPath());
                        } else {
                            aProgressMonitor.subTask("Finished Running TEF Script: "
                                    + ((TestExecuteScript) lVisitObject).getPCPath());
                        }
                    } else if (lVisitObject instanceof Transfer) {
                        if (aIsBuild) {
                            aProgressMonitor.subTask("Finished Copying Transfer file to repository: "
                                    + ((Transfer) lVisitObject).getPCPath());
                        } else {
                            aProgressMonitor.subTask("Finished Retrieve file to results: "
                                    + ((Transfer) lVisitObject).getPCPath());
                        }
                    } else if (lVisitObject instanceof Reference) {
                        aProgressMonitor.subTask(
                                "Finished Reference: " + ((Reference) lVisitObject).getUri().getName());
                    } else if (lVisitObject instanceof CmdSymbian) {
                        aProgressMonitor.subTask("Finished Running Symbian command: "
                                + ((CmdSymbian) lVisitObject).getStatCommand().getLiteral());
                    } else if (lVisitObject instanceof Rtest) {
                        aProgressMonitor
                                .subTask("Finished Running RTest: " + ((Rtest) lVisitObject).getSymbianPath());
                    }

                    aProgressMonitor.worked(1);
                    // if the job has been canceled, ask the visistor to
                    // stop at the end of the task
                    if (aProgressMonitor.isCanceled()) {
                        lVisitor.stop();
                    }

                }

                public void taskStarted(TaskStartedEvent aVisitorEvent) {
                    EObject lVisitObject = aVisitorEvent.getEObject();
                    if (lVisitObject instanceof Task) {
                        aProgressMonitor.subTask("Started task: " + ((Task) lVisitObject).getName());
                    } else if (lVisitObject instanceof CmdPC) {
                        aProgressMonitor
                                .subTask("Started Running PC command: " + ((CmdPC) lVisitObject).getURI());
                    } else if (lVisitObject instanceof Build) {
                        aProgressMonitor
                                .subTask("Started Building group dir: " + ((Build) lVisitObject).getURI());
                    } else if (lVisitObject instanceof TestExecuteScript) {
                        if (aIsBuild) {
                            aProgressMonitor.subTask("Started Copying TEF Script to repository: "
                                    + ((TestExecuteScript) lVisitObject).getPCPath());
                        } else {
                            aProgressMonitor.subTask("Started Running TEF Script: "
                                    + ((TestExecuteScript) lVisitObject).getPCPath());
                        }
                    } else if (lVisitObject instanceof Transfer) {
                        if (aIsBuild) {
                            aProgressMonitor.subTask("Started Copying Transfer file to repository: "
                                    + ((Transfer) lVisitObject).getPCPath());
                        } else {
                            aProgressMonitor.subTask("Started Retrieve file to results: "
                                    + ((Transfer) lVisitObject).getPCPath());
                        }
                    } else if (lVisitObject instanceof Reference) {
                        aProgressMonitor
                                .subTask("Started Reference: " + ((Reference) lVisitObject).getUri().getName());
                    } else if (lVisitObject instanceof CmdSymbian) {
                        aProgressMonitor.subTask("Started Running Symbian command: "
                                + ((CmdSymbian) lVisitObject).getStatCommand().getLiteral());
                    } else if (lVisitObject instanceof Rtest) {
                        aProgressMonitor
                                .subTask("Started Running RTest: " + ((Rtest) lVisitObject).getSymbianPath());
                    }
                }
            });

            try {
                // set our security manager to disallow TestDriver to kill the
                // JVM with system.exit()

                SecurityManager lSec = System.getSecurityManager();
                LOGGER.fine("Installing Security Manager around Test Driver.");
                System.setSecurityManager(new TestDriverRunnerSecurityManager());
                lVisitor.start(lTask);

                // remove security manager
                LOGGER.fine("Removing Security Manager");
                System.setSecurityManager(lSec);

            } catch (SecurityException lSecException) {
                // ignore security exception. TestDriver has System.exit()
            }

            aProgressMonitor.done();
            lProgressCancel.done();

            return new Status(IStatus.OK, DriverEditorPlugin.ID, IStatus.OK,
                    "TestDriver " + (aIsBuild ? "Build" : "Run") + " Finished ", null);
        }
    };

    lJob.setUser(true);
    lJob.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);

    return lJob;
}

From source file:helma.main.Server.java

/**
 *  The main method of the Server. Basically, we set up Applications and than
 *  periodically check for changes in the apps.properties file, shutting down
 *  apps or starting new ones.//w ww . ja  va2  s  .  c o m
 */
public void run() {
    try {
        if (config.hasXmlrpcPort()) {
            InetSocketAddress xmlrpcPort = config.getXmlrpcPort();
            String xmlparser = sysProps.getProperty("xmlparser");

            if (xmlparser != null) {
                XmlRpc.setDriver(xmlparser);
            }

            if (xmlrpcPort.getAddress() != null) {
                xmlrpc = new WebServer(xmlrpcPort.getPort(), xmlrpcPort.getAddress());
            } else {
                xmlrpc = new WebServer(xmlrpcPort.getPort());
            }

            if (paranoid) {
                xmlrpc.setParanoid(true);

                String xallow = sysProps.getProperty("allowXmlRpc");

                if (xallow != null) {
                    StringTokenizer st = new StringTokenizer(xallow, " ,;");

                    while (st.hasMoreTokens())
                        xmlrpc.acceptClient(st.nextToken());
                }
            }
            xmlrpc.start();
            logger.info("Starting XML-RPC server on port " + (xmlrpcPort));
        }

        appManager = new ApplicationManager(appsProps, this);

        if (xmlrpc != null) {
            xmlrpc.addHandler("$default", appManager);
        }

        // add shutdown hook to close running apps and servers on exit
        shutdownhook = new HelmaShutdownHook();
        Runtime.getRuntime().addShutdownHook(shutdownhook);
    } catch (Exception x) {
        throw new RuntimeException("Error setting up Server", x);
    }

    // set the security manager.
    // the default implementation is helma.main.HelmaSecurityManager.
    try {
        String secManClass = sysProps.getProperty("securityManager");

        if (secManClass != null) {
            SecurityManager secMan = (SecurityManager) Class.forName(secManClass).newInstance();

            System.setSecurityManager(secMan);
            logger.info("Setting security manager to " + secManClass);
        }
    } catch (Exception x) {
        logger.error("Error setting security manager", x);
    }

    // start embedded web server
    if (jetty != null) {
        try {
            jetty.start();
        } catch (Exception m) {
            throw new RuntimeException("Error starting embedded web server", m);
        }
    }

    // start applications
    appManager.startAll();

    while (Thread.currentThread() == mainThread) {
        try {
            Thread.sleep(3000L);
        } catch (InterruptedException ie) {
        }

        try {
            appManager.checkForChanges();
        } catch (Exception x) {
            logger.warn("Caught in app manager loop: " + x);
        }
    }
}

From source file:axiom.main.Server.java

/**
 *  The main method of the Server. Basically, we set up Applications and than
 *  periodically check for changes in the apps.properties file, shutting down
 *  apps or starting new ones./*from   w ww .ja v  a2  s  .  co  m*/
 */
public void run() {
    try {
        if ((websrvPort != null)) {
            File f = new File(this.axiomHome, "axiom-config.xml");
            if (f.exists() && f.canRead() && f.isFile()) {
                try {
                    http = new org.mortbay.jetty.Server();
                    XmlConfiguration config = new XmlConfiguration(f.toURI().toURL());
                    config.configure(http);
                } catch (Exception ex) {
                    ex.printStackTrace();
                    logger.error(ErrorReporter.errorMsg(this.getClass(), "run"), ex);
                    throw new RuntimeException("Could not setup the web server, errors in axiom-config.xml");
                }
            } else {
                http = new org.mortbay.jetty.Server(Integer.valueOf(websrvPort).intValue());

            }
            http.setHandler(handlers);
        }

        appManager = new ApplicationManager(this, 0);

        // add shutdown hook to close running apps and servers on exit
        shutdownhook = new AxiomShutdownHook();
        Runtime.getRuntime().addShutdownHook(shutdownhook);
    } catch (Exception x) {
        logger.error(ErrorReporter.errorMsg(this.getClass(), "run"), x);
        throw new RuntimeException("Error setting up Server", x);
    }
    // set the security manager.
    // the default implementation is axiom.main.AxiomSecurityManager.
    try {
        String secManClass = sysProps.getProperty("securityManager");

        if (secManClass != null) {
            SecurityManager secMan = (SecurityManager) Class.forName(secManClass).newInstance();

            System.setSecurityManager(secMan);
            logger.info("Setting security manager to " + secManClass);
        }
    } catch (Exception x) {
        logger.error(ErrorReporter.errorMsg(this.getClass(), "run"), x);
        logger.error("Error setting security manager", x);
    }

    // start embedded web server
    if (http != null) {
        try {
            http.start();
        } catch (MultiException m) {
            logger.error(ErrorReporter.errorMsg(this.getClass(), "run"), m);
            throw new RuntimeException("Error starting embedded web server", m);
        } catch (Exception e) {
            System.out.println(e);
            logger.error(ErrorReporter.errorMsg(this.getClass(), "run"), e);
            throw new RuntimeException("Error starting embedded web server", e);
        }
    }

    // start applications
    appManager.startAll();

    while (Thread.currentThread() == mainThread) {
        try {
            Thread.sleep(7000L);
        } catch (InterruptedException ie) {
        }

        try {
            appManager.startAll();
        } catch (Exception x) {
            logger.warn("Caught in app manager loop: " + x);
        }
    }

}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * Creates and displays the main application window.
 * //from   www  .ja v a2  s .c  om
 * @param args the arguments from the command line
 */
static void createAndInitGUI(String[] args) {
    assert SwingUtilities.isEventDispatchThread();

    // Some of the stuff in this method could be run on the main thread,
    // but running it in the EDT seems to not hurt. Creating new Canvas
    // instances combined with PropertyChangeListeners is definitely
    // unsafe in the main thread and has caused real problems.

    checkWebStart(args);

    /*
     * Remove security manager, because all permissions
     * are required. This is especially critical when
     * running from the Java Web Start. (Otherwise
     * all classes loaded by our own class loaders
     * will have default sandbox permissions.)
     */
    System.setSecurityManager(null);

    checkJavaVersion();

    String directory = RuntimeProperties.getWorkingDirectory();

    logger.info("Working directory: {}", directory);

    RuntimeProperties.init();

    Look.getInstance().initDefaultLnF();

    final Editor window = new Editor();
    s_instance = window;

    if (!RuntimeProperties.isFromWebstart() && args.length > 0) {

        if (args[0].equals("-p")) {

            String dir = (args.length == 3) ? directory + args[2] + File.separator : directory;

            Synthesizer.parseFromCommandLine(dir, args[1]);

        } else {

            logger.info(args[0] + " read from command line.");

            File file = new File(directory + args[0]);

            if (file.exists()) {
                window.openNewCanvasWithPackage(file);
            }
        }

    } else {

        for (String packageFile : RuntimeProperties.getPrevOpenPackages()) {

            File f = new File(packageFile);

            if (f.exists()) {
                logger.debug("Found package file name {} from the configuration file.", packageFile);
                window.openNewCanvasWithPackage(f);
            }
        }

    }

    window.setTitle(WINDOW_TITLE);

    //restore window location, size and state
    final String[] bs = RuntimeProperties.getSchemeEditorWindowProps().split(";");

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            int x = bs[0] != null && bs[0].length() > 0 ? Integer.parseInt(bs[0])
                    : window.getLocationOnScreen().x;
            int y = bs[1] != null && bs[1].length() > 0 ? Integer.parseInt(bs[1])
                    : window.getLocationOnScreen().y;
            int w = bs[2] != null && bs[2].length() > 0 ? Integer.parseInt(bs[2]) : window.getSize().width;
            int h = bs[3] != null && bs[3].length() > 0 ? Integer.parseInt(bs[3]) : window.getSize().height;
            int s = bs[4] != null && bs[4].length() > 0 ? Integer.parseInt(bs[4]) : window.getState();

            window.setBounds(x, y, w, h);

            window.setExtendedState(s);
        }
    });

    window.setVisible(true);

    /* ******************** Init Factories ******************** */
    SpecGenerator.init();
    XMLSpecGenerator.init();
}

From source file:edu.stanford.epadd.launcher.Splash.java

private static void parseOptions(String[] args) throws ParseException {
    // set javawebstart.version to a dummy value if not already set (might happen when running with java -jar from cmd line)
    // exit.jsp doesn't allow us to showdown unless this prop is set
    if (System.getProperty("javawebstart.version") == null)
        System.setProperty("javawebstart.version", "UNKNOWN");

    if (args.length > 0) {
        out.print(args.length + " argument(s): ");
        for (int i = 0; i < args.length; i++)
            out.print(args[i] + " ");
        out.println();//w ww.  ja v  a  2 s . c  o m
    }

    Options options = getOpt();
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("ePADD batch mode", options);
        return;
    }

    debug = false;
    if (cmd.hasOption("debug")) {
        URL url = ClassLoader.getSystemResource("log4j.properties.debug");
        out.println("Loading logging configuration from url: " + url);
        PropertyConfigurator.configure(url);
        debug = true;
    } else if (cmd.hasOption("debug-address-book")) {
        URL url = ClassLoader.getSystemResource("log4j.properties.debug.ab");
        out.println("Loading logging configuration from url: " + url);
        PropertyConfigurator.configure(url);
        debug = false;
    } else if (cmd.hasOption("debug-groups")) {
        URL url = ClassLoader.getSystemResource("log4j.properties.debug.groups");
        out.println("Loading logging configuration from url: " + url);
        PropertyConfigurator.configure(url);
        debug = false;
    }

    if (cmd.hasOption("no-browser-open") || System.getProperty("nobrowseropen") != null)
        browserOpen = false;

    if (cmd.hasOption("port")) {
        String portStr = cmd.getOptionValue('p');
        try {
            PORT = Integer.parseInt(portStr);
            String mesg = " Running on port: " + PORT;
            out.println(mesg);
        } catch (NumberFormatException nfe) {
            out.println("invalid port number " + portStr);
        }
    }

    if (cmd.hasOption("start-page"))
        startPage = cmd.getOptionValue("start-page");

    /*
      if (!cmd.hasOption("no-shutdown")) {
      // arrange to kill Muse after a period of time, we don't want the server to run forever
              
      // i clearly have too much time on my hands right now...
      long secs = KILL_AFTER_MILLIS/1000;
      long hh = secs/3600;
      long mm = (secs%3600)/60;
      long ss = secs % (60);
      out.print ("ePADD will shut down automatically after ");
      if (hh != 0)
      out.print (hh  + " hours ");
      if (mm != 0 || (hh != 0 && ss != 0))
      out.print (mm + " minutes");
      if (ss != 0)
      out.print (ss + " seconds");
      out.println();
              
      Timer timer = new Timer(); 
      TimerTask tt = new ShutdownTimerTask();
      timer.schedule (tt, KILL_AFTER_MILLIS);
      }
    */
    System.setSecurityManager(null); // this is important   
}

From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.TestConsoleRSAKeyPairGenerator.java

@Test(expected = ThisExceptionMeansTestSucceededException.class)
public void testMain01() {
    SecurityManager securityManager = new MockPermissiveSecurityManager() {
        private boolean active = true;

        @Override//from   w w  w. j a  va2s . c  om
        public void checkExit(int status) {
            if (this.active) {
                this.active = false;
                assertEquals("The exit status is not correct.", 0, status);
                throw new ThisExceptionMeansTestSucceededException();
            }
        }
    };

    EasyMock.replay(this.generator, this.device);

    System.setSecurityManager(securityManager);

    ConsoleRSAKeyPairGenerator.main("-help");

    System.setSecurityManager(null);
}

From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.TestConsoleLicenseGenerator.java

@Test(expected = ThisExceptionMeansTestSucceededException.class)
public void testMain01() {
    SecurityManager securityManager = new MockPermissiveSecurityManager() {
        private boolean active = true;

        @Override/*from ww w . j  a v  a2  s .c o  m*/
        public void checkExit(int status) {
            if (this.active) {
                this.active = false;
                assertEquals("The exit status is not correct.", 0, status);
                throw new ThisExceptionMeansTestSucceededException();
            }
        }
    };

    EasyMock.replay(this.device);

    System.setSecurityManager(securityManager);

    ConsoleLicenseGenerator.main("-help");

    System.setSecurityManager(null);
}

From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.TestConsoleRSAKeyPairGenerator.java

@Test(expected = ThisExceptionMeansTestSucceededException.class)
public void testMain02() {
    SecurityManager securityManager = new MockPermissiveSecurityManager() {
        private boolean active = true;

        @Override/*from  ww w.j  ava  2  s  .  c  o m*/
        public void checkExit(int status) {
            if (this.active) {
                this.active = false;
                assertEquals("The exit status is not correct.", 1, status);
                throw new ThisExceptionMeansTestSucceededException();
            }
        }
    };

    EasyMock.replay(this.generator, this.device);

    System.setSecurityManager(securityManager);

    ConsoleRSAKeyPairGenerator.main("-private");

    System.setSecurityManager(null);
}

From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.TestConsoleLicenseGenerator.java

@Test(expected = ThisExceptionMeansTestSucceededException.class)
public void testMain02() {
    SecurityManager securityManager = new MockPermissiveSecurityManager() {
        private boolean active = true;

        @Override//from  w  w  w.j a  va2s  .  c o  m
        public void checkExit(int status) {
            if (this.active) {
                this.active = false;
                assertEquals("The exit status is not correct.", 1, status);
                throw new ThisExceptionMeansTestSucceededException();
            }
        }
    };

    EasyMock.replay(this.device);

    System.setSecurityManager(securityManager);

    ConsoleLicenseGenerator.main("-badOption");

    System.setSecurityManager(null);
}