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.amazonaws.services.dynamodbv2.online.index.integration.tests.ViolationCorrectionTest.java

@AfterClass
public static void tearDown() {
    System.setSecurityManager(securityManager);

    if (tablesToDelete != null) {
        for (String tableName : tablesToDelete) {
            tableManager.deleteTable(tableName);
        }// w ww . ja va  2  s .  c  om
    }

    // Delete the output files
    String[] fileNames = { DETECTION_OP_FILE, CORRECTION_INPUT_FILE, CORRECTION_OUTPUT_FILE };
    TestUtils.deleteFiles(fileNames);
}

From source file:com.alertlogic.aws.kinesis.test1.kcl.CountingRecordProcessorTest.java

/**
 * A test helper to prevent calls to System.exit() from existing our JVM. We need to test failure behavior and want
 * to know if System.exit() was called.//from w ww . j a  v  a 2  s .c  om
 *
 * @param testBlock A code block that is expected to call System.exit().
 */
private void expectSystemExitWhenExecuting(Callable<Void> testBlock) throws Exception {
    final SecurityException expectedPreventionOfSystemExit = new SecurityException(
            "System.exit not allowed for this test.");
    // Disable System.exit() for this test
    final SecurityManager sm = new SecurityManager() {
        @Override
        public void checkExit(int status) {
            throw expectedPreventionOfSystemExit;
        }

        @Override
        public void checkPermission(Permission perm) {
            // Do nothing, allowing this security manager to be replaced
        }
    };
    SecurityManager oldSm = System.getSecurityManager();
    System.setSecurityManager(sm);
    boolean systemExitCalled = false;
    try {
        testBlock.call();
        fail("Expected System.exit to be called and throw a SecurityException by our test SecurityManager");
    } catch (SecurityException ex) {
        assertEquals("Expected SecurityException to be thrown when System.exit called",
                expectedPreventionOfSystemExit, ex);
        systemExitCalled = true;
    } finally {
        System.setSecurityManager(oldSm);
    }
    assertTrue("Expected test to call System.exit", systemExitCalled);
}

From source file:com.thoughtworks.acceptance.SecurityManagerTest.java

public void testSerializeWithDomDriverAndPureJavaReflectionProviderAndActiveSecurityManager() {
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources"));
    sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources"));
    sm.addPermission(source, new RuntimePermission("accessDeclaredMembers"));
    sm.addPermission(source, new RuntimePermission("createClassLoader"));
    sm.addPermission(source, new RuntimePermission("fileSystemProvider"));
    sm.addPermission(source, new RuntimePermission("loadLibrary.nio"));
    sm.addPermission(source, new RuntimePermission("modifyThreadGroup"));
    sm.addPermission(source, new RuntimePermission("reflectionFactoryAccess"));
    sm.addPermission(source, new PropertyPermission(
            "com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration", "read"));
    sm.addPermission(source, new PropertyPermission("elementAttributeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("entityExpansionLimit", "read"));
    sm.addPermission(source,//from   ww w.ja v  a 2  s.c o m
            new PropertyPermission("http://java.sun.com/xml/dom/properties/ancestor-check", "read"));
    sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read"));
    sm.addPermission(source, new PropertyPermission("java.home", "read"));
    sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read"));
    sm.addPermission(source, new PropertyPermission("java.security.debug", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.parsers.DocumentBuilderFactory", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalDTD", "read"));
    sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalSchema", "read"));
    sm.addPermission(source, new PropertyPermission("jaxp.debug", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.elementAttributeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.entityExpansionLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxElementDepth", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxGeneralEntitySizeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxParameterEntitySizeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxOccurLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.maxXMLNameLimit", "read"));
    sm.addPermission(source, new PropertyPermission("jdk.xml.totalEntitySizeLimit", "read"));
    sm.addPermission(source, new PropertyPermission("maxOccurLimit", "read"));
    sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read"));
    sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read"));
    sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read"));
    sm.addPermission(source, new PropertyPermission("user.country", "read"));
    sm.addPermission(source, new PropertyPermission("user.dir", "read"));
    sm.addPermission(source, new PropertyPermission("user.timezone", "read,write"));
    sm.addPermission(source, new NetPermission("specifyStreamHandler"));
    sm.addPermission(source, new ReflectPermission("suppressAccessChecks"));
    sm.setReadOnly();
    System.setSecurityManager(sm);

    xstream = new XStream(new PureJavaReflectionProvider(), new DomDriver());
    xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName() + ".*objects.**");
    xstream.allowTypesByWildcard(this.getClass().getName() + "$*");

    assertBothWays();
}

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

private static void basicSetup(String[] args) throws org.apache.commons.cli.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");

    TIMEOUT_SECS = 60;/* w w  w  . j  av  a2 s  . com*/
    if (args.length > 0) {
        out.print(args.length + " argument(s): ");
        for (int i = 0; i < args.length; i++)
            out.print(args[i] + " ");
        out.println();
    }

    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"))
        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("base-dir"))
        baseDir = cmd.getOptionValue("base-dir");
    noShutdown = !cmd.hasOption("no-shutdown");
    System.setSecurityManager(null); // this is important   
}

From source file:com.cisco.dvbu.ps.deploytool.dao.wsapi.VCSWSDAOImpl.java

public void vcsExportCommand(String prefix, String arguments, String vcsIgnoreMessages, String propertyFile)
        throws CompositeException {

    String identifier = "VCSWSDAOImpl.vcsExportCommand"; // some unique identifier that characterizes this invocation.
    String actionName = "EXPORT";

    try {/*from  w w  w  .j  av  a  2s  .com*/
        boolean preserveQuotes = false;
        boolean initArgsList = true;
        List<String> argsList = new ArrayList<String>();
        argsList = CommonUtils.parseArguments(argsList, initArgsList, arguments, preserveQuotes, propertyFile);
        String[] args = argsList.toArray(new String[0]);

        /*
         * 2014-02-14 (mtinius): Removed the PDTool Archive capability
         */
        //         ExportCommand.startCommand(null, null, args);
        /*
         * 2014-02-14 (mtinius): Added security manager around the Composite native Archive code because
         *                    it has System.out.println and System.exit commands.  Need to trap both.
         */
        String maskedargsList = CommonUtils.getArgumentListMasked(argsList);
        if (logger.isDebugEnabled()) {
            logger.debug(identifier + "(prefix, arguments, vcsIgnoreMessages, propertyFile).  prefix=" + prefix
                    + "  arguments=[" + maskedargsList + "]" + "  vcsIgnoreMessages=" + vcsIgnoreMessages
                    + "  propertyFile=" + propertyFile);
        }

        // Get the existing security manager
        SecurityManager sm = System.getSecurityManager();
        PrintStream originalOut = System.out;
        PrintStream originalErr = System.err;
        String command = "ExportCommand.startCommand";
        try {
            // Get the offset location of the java.policy file [offset from PDTool home].
            String javaPolicyOffset = CommonConstants.javaPolicy;
            String javaPolicyLocation = CommonUtils.extractVariable(prefix,
                    CommonUtils.getFileOrSystemPropertyValue(propertyFile, "PROJECT_HOME_PHYSICAL"),
                    propertyFile, true) + javaPolicyOffset;
            // Set the java security policy
            System.getProperties().setProperty("java.security.policy", javaPolicyLocation);

            // Create a new System.out Logger
            Logger exportLogger = Logger.getLogger(ExportCommand.class);
            System.setOut(new PrintStream(new LogOutputStream(exportLogger, Level.INFO)));
            System.setErr(new PrintStream(new LogOutputStream(exportLogger, Level.ERROR)));
            // Create a new security manager
            System.setSecurityManager(new NoExitSecurityManager());

            // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation.
            if (CommonUtils.isExecOperation()) {
                // Invoke the Composite native export command.
                ExportCommand.startCommand(null, null, args);
            } else {
                logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName
                        + "] WAS NOT PERFORMED.\n");
            }
        } catch (NoExitSecurityExceptionStatusNonZero nesesnz) {
            String error = identifier + ":: Exited with exception from System.exit(): " + command
                    + "(null, null, " + maskedargsList + ")";
            logger.error(error);
            throw new CompositeException(error);
        } catch (NoExitSecurityExceptionStatusZero nesezero) {
            if (logger.isDebugEnabled()) {
                logger.debug(identifier + ":: Exited successfully from System.exit(): " + command
                        + "(null, null, " + maskedargsList + ")");
            }
        } finally {
            System.setSecurityManager(sm);
            System.setOut(originalOut);
            System.setErr(originalErr);
        }

    } catch (Exception e) {
        if (resolveExecCommandLineError(prefix, e.getMessage().toString(), vcsIgnoreMessages)) {
            ApplicationException applicationException = new ApplicationException(
                    "ExportCommand execution returned an error=" + e.getMessage().toString());
            if (logger.isErrorEnabled()) {
                logger.error(applicationException);
            }
            throw applicationException;
        }
    }
}

From source file:org.red5.server.war.RootContextLoaderServlet.java

protected void initRegistry(ServletContext ctx) {
    Registry r = null;/*from   w  w w . j  a va  2s  .  c  o m*/
    try {
        Object o = ctx.getInitParameter("rmiPort");
        if (o != null) {
            rmiPort = Integer.valueOf((String) o);
        }
        if (System.getSecurityManager() != null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        // lookup the registry
        r = LocateRegistry.getRegistry(rmiPort);
        // ensure we are not already registered with the registry
        for (String regName : r.list()) {
            logger.debug("Registry entry: " + regName);
        }
    } catch (RemoteException re) {
        logger.info("RMI Registry server was not found on port " + rmiPort);
        // if we didnt find the registry and the user wants it created
        try {
            logger.info("Starting an internal RMI registry");
            // create registry for rmi
            r = LocateRegistry.createRegistry(rmiPort);
        } catch (RemoteException e) {
            logger.info("RMI Registry server was not started on port " + rmiPort);
        }

    }
}

From source file:de.fosd.jdime.Main.java

/**
 * Dumps the given <code>FileArtifact</code> using the <code>mode</code>.
 *
 * @param artifact//from   ww  w  .  j  ava2s .  com
 *         the <code>Artifact</code> to dump
 * @param mode
 *         the dump format
 */
private static void dump(FileArtifact artifact, DumpMode mode) {

    if (mode == DumpMode.NONE) {
        return;
    }

    if (mode == DumpMode.FILE_DUMP || artifact.isDirectory()) {
        System.out.println(artifact.dump(mode));
    } else {
        SecurityManager prevSecManager = System.getSecurityManager();
        SecurityManager noExitManager = new SecurityManager() {
            @Override
            public void checkPermission(Permission perm) {
                // allow anything.
            }

            @Override
            public void checkPermission(Permission perm, Object context) {
                // allow anything.
            }

            @Override
            public void checkExit(int status) {
                super.checkExit(status);
                throw new SecurityException("Captured attempt to exit JVM.");
            }
        };

        ASTNodeArtifact astArtifact;

        System.setSecurityManager(noExitManager);

        try {
            astArtifact = new ASTNodeArtifact(artifact);
        } catch (RuntimeException e) {
            LOG.log(Level.WARNING, e, () -> "Could not parse " + artifact + " to an ASTNodeArtifact.");
            return;
        } finally {
            System.setSecurityManager(prevSecManager);
        }

        System.out.println(astArtifact.dump(mode));
    }
}

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

private static void basicSetup(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();//from w  w  w.j  av a  2  s .  c om
    }

    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("base-dir"))
        baseDir = cmd.getOptionValue("base-dir");

    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:com.cisco.dvbu.ps.deploytool.dao.wsapi.VCSWSDAOImpl.java

public void vcsDiffMergerCommand(String prefix, String arguments, String vcsIgnoreMessages, String propertyFile)
        throws CompositeException {

    String identifier = "VCSWSDAOImpl.vcsDiffMergerCommand"; // some unique identifier that characterizes this invocation.
    String actionName = "DIFF";

    try {//www .ja v a 2s. c  o m
        boolean preserveQuotes = false;
        boolean initArgsList = true;
        List<String> argsList = new ArrayList<String>();
        argsList = CommonUtils.parseArguments(argsList, initArgsList, arguments, preserveQuotes, propertyFile);

        String[] args = argsList.toArray(new String[0]);

        /*
         * 2014-06-30 (mtinius): Removed the PDTool Diffmerger capability
         */
        //         DiffMerger.startCommand(null, null, args);
        /*
         * 2014-06-30 (mtinius): Added security manager around the Composite native Diffmerger code because
         *                    it has System.out.println and System.exit commands.  Need to trap both.
         */
        String maskedargsList = CommonUtils.getArgumentListMasked(argsList);
        if (logger.isDebugEnabled()) {
            logger.debug(identifier + "(prefix, arguments, vcsIgnoreMessages, propertyFile).  prefix=" + prefix
                    + "  arguments=[" + maskedargsList + "]" + "  vcsIgnoreMessages=" + vcsIgnoreMessages
                    + "  propertyFile=" + propertyFile);
        }

        // Get the existing security manager
        SecurityManager sm = System.getSecurityManager();
        PrintStream originalOut = System.out;
        PrintStream originalErr = System.err;
        String command = "DiffMerger.startCommand";
        try {
            // Get the offset location of the java.policy file [offset from PDTool home].
            String javaPolicyOffset = CommonConstants.javaPolicy;
            String javaPolicyLocation = CommonUtils.extractVariable(prefix,
                    CommonUtils.getFileOrSystemPropertyValue(propertyFile, "PROJECT_HOME_PHYSICAL"),
                    propertyFile, true) + javaPolicyOffset;
            // Set the java security policy
            System.getProperties().setProperty("java.security.policy", javaPolicyLocation);

            // Create a new System.out Logger
            Logger exportLogger = Logger.getLogger(DiffMerger.class);
            System.setOut(new PrintStream(new LogOutputStream(exportLogger, Level.INFO)));
            System.setErr(new PrintStream(new LogOutputStream(exportLogger, Level.ERROR)));
            // Create a new security manager
            System.setSecurityManager(new NoExitSecurityManager());

            // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation.
            if (CommonUtils.isExecOperation()) {
                // Invoke the Composite native DiffMerger command.
                DiffMerger.startCommand(null, null, args);
            } else {
                logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName
                        + "] WAS NOT PERFORMED.\n");
            }
        } catch (NoExitSecurityExceptionStatusNonZero nesesnz) {
            String error = identifier + ":: Exited with exception from System.exit(): " + command
                    + "(null, null, " + maskedargsList + ")";
            logger.error(error);
            throw new CompositeException(error);
        } catch (NoExitSecurityExceptionStatusZero nesezero) {
            if (logger.isDebugEnabled()) {
                logger.debug(identifier + ":: Exited successfully from System.exit(): " + command
                        + "(null, null, " + maskedargsList + ")");
            }
        } finally {
            System.setSecurityManager(sm);
            System.setOut(originalOut);
            System.setErr(originalErr);
        }

    } catch (Exception e) {
        if (resolveExecCommandLineError(prefix, e.getMessage().toString(), vcsIgnoreMessages)) {
            ApplicationException applicationException = new ApplicationException(
                    "DiffMerger execution returned an error=" + e.getMessage().toString());
            if (logger.isErrorEnabled()) {
                logger.error(applicationException);
            }
            throw applicationException;
        }
    }
}

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

private static void basicSetup(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();//from  ww w. j a  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("base-dir"))
        baseDir = cmd.getOptionValue("base-dir");

    /*
      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   
}