Example usage for java.lang SecurityException printStackTrace

List of usage examples for java.lang SecurityException printStackTrace

Introduction

In this page you can find the example usage for java.lang SecurityException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:GetGenericInterfaces.java

public static void main(String[] args) {
    try {// w  w w. jav  a  2  s.co m
        Type[] ts = SAXSource.class.getGenericInterfaces();
        for (int i = 0; i < ts.length; i++) {
            System.out.println(ts[i]);
        }
    } catch (SecurityException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    Constructor[] cs = String.class.getConstructors();
    for (int i = 0; i < cs.length; i++) {
        System.out.println(cs[i]);
    }//w  w w. j  a va2s .  c om
    try {
        Constructor c = String.class.getConstructor(new Class[] { String.class });
        System.out.println(c);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    System.setProperty("java.version", "data");

    try {//from w ww  .  j  a  v  a 2 s . c  o m
        SecurityManager sm = new SecurityManager();
        System.setSecurityManager(sm);
    } catch (SecurityException se) {
        se.printStackTrace();
    }

    // no longer possible; an AccessControlException is thrown
    System.setProperty("java.version", "malicious data");
}

From source file:GetGenericSuperclass.java

public static void main(String[] args) {
    try {/*from w  ww. ja va 2 s . c  om*/
        Class<? super SAXSource> ts = SAXSource.class.getSuperclass();
        System.out.println(ts);
    } catch (SecurityException e) {
        e.printStackTrace();
    }
    try {
        Type t = ArrayList.class.getGenericSuperclass();
        System.out.println(t);
    } catch (SecurityException e) {
        e.printStackTrace();
    }
    try {
        Class[] is = SAXSource.class.getInterfaces();
        for (int i = 0; i < is.length; i++) {
            System.out.println(is[i]);
        }
    } catch (SecurityException e) {
        e.printStackTrace();
    }
}

From source file:org.g_node.App.java

/**
 * Main method of the crawler-to-rdf framework. Registers all so far available tools and
 * selects and runs the appropriate crawler or RDF to RDF converter dependent on commandline input.
 * @param args User provided {@link CommandLine} arguments.
 *///from   w w w. ja va2s . com
public static void main(final String[] args) {

    App.LOGGER.info(
            String.join("", AppUtils.getTimeStamp("dd.MM.yyyy HH:mm"), ", Starting RDF crawler logfile."));
    App.LOGGER.info(String.join("", "Input arguments: '", String.join(" ", args), "'"));

    try {
        final App currApp = new App();
        currApp.register();
        currApp.run(args);
    } catch (SecurityException e) {
        e.printStackTrace();
    }
}

From source file:dk.netarkivet.deploy.DeployApplication.java

/**
 * Run deploy./*from w w w . j  a  va  2  s .c  o m*/
 *
 * @param args The Command-line arguments in no particular order:
 *
 * -C The deploy configuration file (ends with .xml). -Z The NetarchiveSuite file to be unpacked (ends with .zip).
 * -S The security policy file (ends with .policy). -L The logging property file (ends with .prop). -O [OPTIONAL]
 * The output directory -D [OPTIONAL] The harvest definition database -T [OPTIONAL] The test arguments
 * (httpportoffset, port, environmentName, mailReceiver) -R [OPTIONAL] For resetting the tempDir (takes arguments
 * 'y' or 'yes') -E [OPTIONAL] Evaluating the deployConfig file (arguments: 'y' or 'yes') -A [OPTIONAL] For archive
 * database. -J [OPTIONAL] For deploying with external jar files. Must be the total path to the directory containing
 * jar-files. These external files will be placed on every machine, and they have to manually be put into the
 * classpath, where they should be used.
 */
public static void main(String[] args) {
    try {
        // Make sure the arguments can be parsed.
        if (!ap.parseParameters(args)) {
            System.err.print(Constants.MSG_ERROR_PARSE_ARGUMENTS);
            System.out.println(ap.listArguments());
            System.exit(1);
        }

        // Check arguments
        if (ap.getCommandLine().getOptions().length < Constants.ARGUMENTS_REQUIRED) {
            System.err.print(Constants.MSG_ERROR_NOT_ENOUGH_ARGUMENTS);
            System.out.println();
            System.out.println("Use DeployApplication with following arguments:");
            System.out.println(ap.listArguments());
            System.out.println("outputdir defaults to ./environmentName (set in config file)");
            System.exit(1);
        }
        // test if more arguments than options is given
        if (args.length > ap.getOptions().getOptions().size()) {
            System.err.print(Constants.MSG_ERROR_TOO_MANY_ARGUMENTS);
            System.out.println();
            System.out.println("Maximum " + ap.getOptions().getOptions().size() + "arguments.");
            System.exit(1);
        }

        // Retrieving the configuration filename
        String deployConfigFileName = ap.getCommandLine().getOptionValue(Constants.ARG_CONFIG_FILE);
        // Retrieving the NetarchiveSuite filename
        String netarchiveSuiteFileName = ap.getCommandLine()
                .getOptionValue(Constants.ARG_NETARCHIVE_SUITE_FILE);
        // Retrieving the security policy filename
        String secPolicyFileName = ap.getCommandLine().getOptionValue(Constants.ARG_SECURITY_FILE);
        // Retrieving the SLF4J xml filename
        String slf4jConfigFileName = ap.getCommandLine().getOptionValue(Constants.ARG_SLF4J_CONFIG_FILE);
        // Retrieving the output directory name
        String outputDir = ap.getCommandLine().getOptionValue(Constants.ARG_OUTPUT_DIRECTORY);
        // Retrieving the database filename
        String databaseFileName = ap.getCommandLine().getOptionValue(Constants.ARG_DATABASE_FILE);
        // Retrieving the test arguments
        String testArguments = ap.getCommandLine().getOptionValue(Constants.ARG_TEST);
        // Retrieving the reset argument
        String resetArgument = ap.getCommandLine().getOptionValue(Constants.ARG_RESET);
        // Retrieving the evaluate argument
        String evaluateArgument = ap.getCommandLine().getOptionValue(Constants.ARG_EVALUATE);
        // Retrieve the archive database filename.
        String arcDbFileName = ap.getCommandLine().getOptionValue(Constants.ARG_ARC_DB);
        // Retrieves the jar-folder name.
        String jarFolderName = ap.getCommandLine().getOptionValue(Constants.ARG_JAR_FOLDER);

        // Retrieves the source encoding.
        // If not specified get system default
        String sourceEncoding = ap.getCommandLine().getOptionValue(Constants.ARG_SOURCE_ENCODING);
        String msgTail = "";
        if (sourceEncoding == null || sourceEncoding.isEmpty()) {
            sourceEncoding = Charset.defaultCharset().name();
            msgTail = " (defaulted)";
        }
        System.out.println("Will read source files using encoding '" + sourceEncoding + "'" + msgTail);

        // check deployConfigFileName and retrieve the corresponding file
        initConfigFile(deployConfigFileName);

        // check netarchiveSuiteFileName and retrieve the corresponding file
        initNetarchiveSuiteFile(netarchiveSuiteFileName);

        // check secPolicyFileName and retrieve the corresponding file
        initSecPolicyFile(secPolicyFileName);

        initSLF4JXmlFile(slf4jConfigFileName);

        // check database
        initDatabase(databaseFileName);

        // check and apply the test arguments
        initTestArguments(testArguments);

        // check reset arguments.
        initReset(resetArgument);

        // evaluates the config file
        initEvaluate(evaluateArgument, sourceEncoding);

        // check the archive database
        initArchiveDatabase(arcDbFileName);

        // check the external jar-files library folder.
        initJarFolder(jarFolderName);

        //initBundlerZip(Optional.ofNullable(
        //        ap.getCommandLine().getOptionValue(Constants.ARG_DEFAULT_BUNDLER_ZIP)));
        initBundlerZip(ap.getCommandLine().getOptionValue(Constants.ARG_DEFAULT_BUNDLER_ZIP));

        // Make the configuration based on the input data
        deployConfig = new DeployConfiguration(deployConfigFile, netarchiveSuiteFile, secPolicyFile,
                slf4jConfigFile, outputDir, dbFile, arcDbFile, resetDirectory, externalJarFolder,
                sourceEncoding, defaultBundlerZip);

        // Write the scripts, directories and everything
        deployConfig.write();
    } catch (SecurityException e) {
        // This problem should only occur in tests -> thus not err message.
        System.out.println("SECURITY ERROR: ");
        e.printStackTrace();
    } catch (Throwable e) {
        System.err.println("DEPLOY APPLICATION ERROR: ");
        e.printStackTrace();
    }
}

From source file:shuffle.fwk.ShuffleController.java

/**
 * The main which starts the program.//ww  w  .j av a2s .co  m
 * 
 * @param args
 *           unused.
 */
public static void main(String... args) {
    String userHomeArg = null;
    String levelToSetArg = null;

    if (args != null && args.length > 0) {
        userHomeArg = args[0];
        if (args.length > 1) {
            levelToSetArg = args[1];
        }
    }

    if (userHomeArg == null) {
        userHomeArg = System.getProperty("user.home") + File.separator + "Shuffle-Move";
    }
    setUserHome(userHomeArg);
    try {
        FileHandler handler = new FileHandler();
        Logger toRoot = LOG;
        while (toRoot.getParent() != null) {
            toRoot = toRoot.getParent();
        }
        toRoot.addHandler(handler);
    } catch (SecurityException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    if (levelToSetArg != null) {
        try {
            Level levelToSet = Level.parse(args[1]);
            Logger.getLogger(SimulationTask.class.getName()).setLevel(levelToSet);
            SimulationTask.setLogFiner(levelToSet.intValue() <= Level.FINER.intValue());
            Logger.getLogger(ShuffleModel.class.getName()).setLevel(levelToSet);
        } catch (Exception e) {
            LOG.fine("Cannot set simulation logging to that level: " + StringUtils.join(args));
        }
    }

    ShuffleController ctrl = new ShuffleController();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ctrl.getFrame().launch();
        }
    });
}

From source file:Main.java

public static Field getDeclaredField(Class clazz, String name) {
    try {//from   w  w w.  j a v a 2s  .  co m
        return clazz.getDeclaredField(name);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static Field getDeclaredField(Class<?> clazz, String name) {
    try {//from   www.j a v a  2s  .  c  o  m
        return clazz.getDeclaredField(name);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static void printAllInform(Class clsShow) {
    try {/* w  w w. j  a v a2  s. co  m*/
        int i;
        for (i = 0; i < clsShow.getMethods().length; i++) {
        }
        for (i = 0; i < clsShow.getFields().length; i++) {
        }
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e2) {
        e2.printStackTrace();
    } catch (Exception e3) {
        e3.printStackTrace();
    }
}