Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.mb.framework.util.SecurityUtil.java

/**
 * Thisis main method to run program//from ww  w. j  a v  a2 s.  com
 * 
 * @param args
 *            []
 */
public static void main(String args[]) {

    try {
        Security.addProvider(new com.sun.crypto.provider.SunJCE());// step 1
        // PasswordUtil passwordEncryptAgent = new PasswordUtil("ASCII");
        String password = "Abcd@1234";
        System.out.println("Plain Password : " + password + "\n");

        /******************************* START - MD5 *****************************************/
        System.out.println("MD5 - Encrypted Password:  " + encryptMd5(password) + "\n");
        /******************************* END - MD5 *******************************************/

        /******************************* START - ASE_ALGO ************************************/
        String passwordEnc = encryptAES(password);
        String passwordDec = decryptAES(passwordEnc);

        System.out.println("ASE - Encrypted Password : " + passwordEnc);
        System.out.println("ASE - Decrypted Password : " + passwordDec + "\n");
        /******************************* END - ASE_ALGO ************************************/

        /****** START - 256-bit AES/CBC/PKCS5Padding (based on PKCS#5s PBKDF2) ************/

        String encryptedText = encryptAESPBKDF2(password);
        System.out.println(
                "256-bit AES/CBC/PKCS5Padding (based on PKCS#5s PBKDF2) - Encrypted string:" + encryptedText);
        System.out.println("256-bit AES/CBC/PKCS5Padding (based on PKCS#5s PBKDF2) - Decrypted string:"
                + decryptAESPBKDF2(encryptedText));

        /******** END - 256-bit AES/CBC/PKCS5Padding (based on PKCS#5s PBKDF2) ************/
    } catch (Exception ex) {
        LOGGER.error("error " + ex.getMessage());
    }

}

From source file:com.microsoft.azure.management.network.samples.ManageApplicationGateway.java

/**
 * Main entry point./*from   w  ww  .  jav a2 s  .c  o m*/
 * @param args parameters
 */

public static void main(String[] args) {
    try {

        //=============================================================
        // Authenticate

        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));

        Azure azure = Azure.configure().withLogLevel(LogLevel.NONE).authenticate(credFile)
                .withDefaultSubscription();

        // Print selected subscription
        System.out.println("Selected subscription: " + azure.subscriptionId());

        runSample(azure);
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.genentech.chemistry.openEye.apps.SdfRMSDSphereExclusion.java

/**
 * @param args/* w ww . j  a  va 2s.com*/
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_REFFILE, true,
            "Reference file of molecules which define pre-existign exclusion spheres.");
    options.addOption(opt);

    opt = new Option(OPT_RADIUS, true, "Radius of exclusion spehre in A2.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_GROUPBY, true,
            "Group by fieldname, run sphere exclusion for consecutive groups of records with same value for this field.");
    options.addOption(opt);

    opt = new Option(OPT_DONotOpt, false,
            "If specified the RMSD is computed without trying to optimize the alignment.");
    options.addOption(opt);

    opt = new Option(OPT_PRINT_All, false, "print all molecule, check includeIdx tag");
    options.addOption(opt);

    opt = new Option(OPT_MIRROR, false, "For non-chiral molecules also try mirror image");
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    String refFile = cmd.getOptionValue(OPT_REFFILE);
    String groupBy = cmd.getOptionValue(OPT_GROUPBY);
    boolean doOptimize = !cmd.hasOption(OPT_DONotOpt);
    double radius = Double.parseDouble(cmd.getOptionValue(OPT_RADIUS));
    boolean printAll = cmd.hasOption(OPT_PRINT_All);
    boolean doMirror = cmd.hasOption(OPT_MIRROR);

    SdfRMSDSphereExclusion sphereExclusion = new SdfRMSDSphereExclusion(refFile, outFile, radius, printAll,
            doMirror, doOptimize, groupBy);

    sphereExclusion.run(inFile);
    sphereExclusion.close();
}

From source file:eu.sendregning.oxalis.Main.java

public static void main(String[] args) throws Exception {

    OptionParser optionParser = getOptionParser();

    if (args.length == 0) {
        System.out.println("");
        optionParser.printHelpOn(System.out);
        System.out.println("");
        return;//from w  w  w  .ja va 2  s.c om
    }

    OptionSet optionSet;

    try {
        optionSet = optionParser.parse(args);
    } catch (Exception e) {
        printErrorMessage(e.getMessage());
        return;
    }

    File xmlInvoice = xmlDocument.value(optionSet);

    if (!xmlInvoice.exists()) {
        printErrorMessage("XML document " + xmlInvoice + " does not exist");
        return;
    }

    String recipientId = recipient.value(optionSet);
    String senderId = sender.value(optionSet);

    try {

        System.out.println("");
        System.out.println("");

        // bootstraps the Oxalis outbound module
        OxalisOutboundModule oxalisOutboundModule = new OxalisOutboundModule();

        // creates a transmission request builder and enable tracing
        TransmissionRequestBuilder requestBuilder = oxalisOutboundModule.getTransmissionRequestBuilder();
        requestBuilder.trace(trace.value(optionSet));
        System.out.println("Trace mode of RequestBuilder: " + requestBuilder.isTraceEnabled());

        // add receiver participant
        if (recipientId != null) {
            requestBuilder.receiver(new ParticipantId(recipientId));
        }

        // add sender participant
        if (senderId != null) {
            requestBuilder.sender((new ParticipantId(senderId)));
        }

        if (docType != null && docType.value(optionSet) != null) {
            requestBuilder.documentType(PeppolDocumentTypeId.valueOf(docType.value(optionSet)));
        }

        if (profileType != null && profileType.value(optionSet) != null) {
            requestBuilder.processType(PeppolProcessTypeId.valueOf(profileType.value(optionSet)));
        }

        // Supplies the payload
        requestBuilder.payLoad(new FileInputStream(xmlInvoice));

        // Overrides the destination URL if so requested
        if (optionSet.has(destinationUrl)) {
            String destinationString = destinationUrl.value(optionSet);
            URL destination;

            try {
                destination = new URL(destinationString);
            } catch (MalformedURLException e) {
                printErrorMessage("Invalid destination URL " + destinationString);
                return;
            }

            // Fetches the transmission method, which was overridden on the command line
            BusDoxProtocol busDoxProtocol = BusDoxProtocol.instanceFrom(transmissionMethod.value(optionSet));

            if (busDoxProtocol == BusDoxProtocol.AS2) {
                String accessPointSystemIdentifier = destinationSystemId.value(optionSet);
                if (accessPointSystemIdentifier == null) {
                    throw new IllegalStateException("Must specify AS2 system identifier if using AS2 protocol");
                }
                requestBuilder.overrideAs2Endpoint(destination, accessPointSystemIdentifier);
            } else {
                throw new IllegalStateException("Unknown busDoxProtocol : " + busDoxProtocol);
            }
        }

        // Specifying the details completed, creates the transmission request
        TransmissionRequest transmissionRequest = requestBuilder.build();

        // Fetches a transmitter ...
        Transmitter transmitter = oxalisOutboundModule.getTransmitter();

        // ... and performs the transmission
        TransmissionResponse transmissionResponse = transmitter.transmit(transmissionRequest);

        // Write the transmission id and where the message was delivered
        System.out.printf("Message using messageId %s sent to %s using %s was assigned transmissionId %s\n",
                transmissionResponse.getStandardBusinessHeader().getMessageId().stringValue(),
                transmissionResponse.getURL().toExternalForm(), transmissionResponse.getProtocol().toString(),
                transmissionResponse.getTransmissionId());

        String evidenceFileName = transmissionResponse.getTransmissionId().toString() + "-evidence.dat";
        IOUtils.copy(new ByteArrayInputStream(transmissionResponse.getEvidenceBytes()),
                new FileOutputStream(evidenceFileName));
        System.out.printf("Wrote transmission receipt to " + evidenceFileName);

    } catch (Exception e) {
        System.out.println("");
        System.out.println("Message failed : " + e.getMessage());
        //e.printStackTrace();
        System.out.println("");
    }
}

From source file:edu.msu.cme.rdp.readseq.writers.StkWriter.java

public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("r", "removeref", false, "is set, do not write the GC reference sequences to output");
    options.addOption("h", "header", true,
            "the header of the output file in case a differenet stk version, default is " + STK_HEADER);
    String header = STK_HEADER;/*from  w w  w .  j a  v a2s  .com*/
    boolean removeRef = false;

    try {
        CommandLine line = new PosixParser().parse(options, args);

        if (line.hasOption("removeref")) {
            removeRef = true;
        }
        if (line.hasOption("header")) {
            header = line.getOptionValue("header");
        }

        args = line.getArgs();
        if (args.length < 2) {
            throw new Exception("Need input and output files");
        }

    } catch (Exception e) {
        new HelpFormatter().printHelp("USAGE: to-stk <input-file> <out-file>", options);
        System.err.println("ERROR: " + e.getMessage());
        System.exit(1);
        return;
    }

    SequenceReader reader = new SequenceReader(new File(args[0]));
    PrintStream out = new PrintStream(new File(args[1]));
    StkWriter writer = new StkWriter(reader, out, header);
    reader = new SequenceReader(new File(args[0]));
    Sequence seq;
    while ((seq = reader.readNextSequence()) != null) {
        if (seq.getSeqName().startsWith("#") && removeRef) {
            continue;
        }
        writer.writeSeq(seq);
    }
    writer.writeEndOfBlock();
    writer.close();
    reader.close();

}

From source file:bdsup2sub.BDSup2Sub.java

public static void main(String[] args) {
    try {//from w  w w .  j a  v  a  2 s . co  m
        new BDSup2Sub().run(args);
    } catch (Exception e) {
        fatalError(e.getMessage());
        System.exit(1);
    }
}

From source file:com.zimbra.qa.unittest.TestPreAuthServlet.java

/**
 * @param args// w w w  .j av a 2  s  . c  om
 */
public static void main(String[] args) throws Exception {
    TestUtil.cliSetup();
    try {
        TestUtil.runTest(TestPreAuthServlet.class);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}

From source file:ezbake.azkaban.manager.ScheduleManager.java

public static void main(String[] args) throws IOException, InterruptedException, TException {
    final OptionsBean bean = new OptionsBean();
    final CmdLineParser parser = new CmdLineParser(bean);

    try {//from   w  w  w .ja va  2s.c  o m
        parser.parseArgument(args);

        String time;
        if (bean.scheduleTime == null) {
            // Need to add 2 minutes because Azkaban won't actually schedule it if it's scheduled to run at the
            // current time or in the past.  If we only added one minute there's a race condition for the code
            // submitting before the clock rolls over to the next minute.
            final LocalTime now = LocalTime.now().plusMinutes(2);
            time = now.getHourOfDay() + "," + now.getMinuteOfHour() + ","
                    + ((now.getHourOfDay() > 12) ? "pm" : "am") + ","
                    + now.getChronology().getZone().toString();

            System.out.println("time option not provided.  Using: " + time);
        } else {
            time = bean.scheduleTime;
        }

        final ScheduleManager azkabanScheduler = new ScheduleManager(new URI(bean.endPoint), bean.username,
                bean.password);
        azkabanScheduler.scheduleDate = bean.scheduleDate;
        azkabanScheduler.scheduleTime = time;

        if (bean.period != null) {
            azkabanScheduler.setPeriod(bean.period);
        }

        final SchedulerResult result = azkabanScheduler.scheduleFlow(bean.name, bean.flow, bean.projectId);

        if (result.hasError()) {
            System.err.println(result.getError());
        } else {
            System.out.println(
                    "Scheduled flow <" + bean.flow + "> :" + result.getStatus() + " | " + result.getMessage());
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
        parser.printUsage(System.err);
    }
}

From source file:org.hyperic.hq.hqapi1.tools.Shell.java

public static void main(String[] args) throws Exception {
    try {/*from   ww  w .j a  va2 s.  c  o  m*/
        initConnectionProperties(args);
    } catch (Exception e) {
        System.err.println("Error parsing command line connection properties.  Cause: " + e.getMessage());
        e.printStackTrace(System.err);
        System.exit(1);
    }
    final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {
            "classpath:/META-INF/spring/hqapi-context.xml", "classpath*:/META-INF/**/*commands-context.xml" });
    try {
        final int exitCode = ((Shell) applicationContext.getBean("commandDispatcher")).dispatchCommand(args);
        System.exit(exitCode);
    } catch (Exception e) {
        System.err.println("Error running command: " + e.getMessage());
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

From source file:com.genentech.chemistry.openEye.apps.SdfRMSDNNFinder.java

public static void main(String[] args) throws IOException {
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);// w  w  w. jav a 2s.  c  o m
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_REFFILE, true, "Reference file containing poses from reference docking run. " + "If "
            + OPT_REFFILE + " not specified, program uses the input file " + "(internal NN analysis)");
    options.addOption(opt);

    opt = new Option(OPT_MOLIdTag, true, "Name of the field containing the molecule identifier. "
            + " Assumption: Ref file uses the same field name.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_DONotOpt, false,
            "If specified the RMSD is computed without trying to optimize the alignment.");
    options.addOption(opt);

    opt = new Option(OPT_MIRROR, false, "For non-chiral molecules also try mirror image");
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();
    if (args.length != 0) {
        ; //error message
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);

    String refFile = cmd.getOptionValue(OPT_REFFILE);
    boolean noRefFile = false;
    if (refFile == null) {
        if (inFile.startsWith("."))
            inFile = writeRefMolPosesToTempFile(inFile);
        refFile = inFile;
        noRefFile = true;
    }

    String molIdTag = cmd.getOptionValue(OPT_MOLIdTag);
    boolean doOptimize = !cmd.hasOption(OPT_DONotOpt);
    boolean doMirror = cmd.hasOption(OPT_MIRROR);

    SdfRMSDNNFinder nnFinder = new SdfRMSDNNFinder(refFile, outFile, molIdTag, doMirror, doOptimize, noRefFile);

    nnFinder.run(inFile);
    nnFinder.close();
}