Example usage for java.lang SecurityException getMessage

List of usage examples for java.lang SecurityException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.jvnet.hudson.plugins.mavendepsupdate.MavenDependencyUpdateTrigger.java

private String getRootPomPath() {
    String rootPomPath = null;/*from w  ww  .  j  a v  a2  s.  c o  m*/

    Project<?, ?> p = (Project<?, ?>) this.job;
    for (Builder b : p.getBuilders()) {
        if (b instanceof Maven) {
            String targets = ((Maven) b).getTargets();
            String[] args = Util.tokenize(targets);

            if (args == null) {
                rootPomPath = null;
            }
            CommandLine cli = getCommandLine(args);
            if (cli != null && cli.hasOption(CLIManager.ALTERNATE_POM_FILE)) {
                rootPomPath = cli.getOptionValue(CLIManager.ALTERNATE_POM_FILE);
            }
        }
    }

    // check if there is a method called getRootPOM
    if (rootPomPath == null) {
        try {
            Method method = this.job.getClass().getMethod("getRootPOM", (Class<?>) null);
            String rootPom = (String) method.invoke(this.job, (Object[]) null);
            rootPomPath = rootPom;
        } catch (SecurityException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (NoSuchMethodException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (IllegalArgumentException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (IllegalAccessException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (InvocationTargetException e) {
            LOGGER.warning("ignore " + e.getMessage());
        }
    }

    return rootPomPath == null ? "pom.xml" : rootPomPath;
}

From source file:org.jvnet.hudson.plugins.mavendepsupdate.MavenDependencyUpdateTrigger.java

private List<String> getActiveProfiles() {
    List<String> activeProfiles = null;

    Project<?, ?> p = (Project<?, ?>) this.job;
    for (Builder b : p.getBuilders()) {
        if (b instanceof Maven) {
            String targets = ((Maven) b).getTargets();
            String[] args = Util.tokenize(targets);

            if (args == null) {
                activeProfiles = null;//ww w  .  j  a  v a2 s .  co  m
            }
            CommandLine cli = getCommandLine(args);
            if (cli != null && cli.hasOption(CLIManager.ACTIVATE_PROFILES)) {
                activeProfiles = Arrays.asList(cli.getOptionValues(CLIManager.ACTIVATE_PROFILES));
            }
        }
    }

    // check if there is a method called getGoals
    if (activeProfiles == null) {
        try {
            Method method = this.job.getClass().getMethod("getGoals", (Class<?>) null);
            String goals = (String) method.invoke(this.job, (Object[]) null);
            String[] args = Util.tokenize(goals);
            if (args == null) {
                activeProfiles = Collections.emptyList();
            }
            CommandLine cli = getCommandLine(args);
            if (cli != null && cli.hasOption(CLIManager.ACTIVATE_PROFILES)) {
                activeProfiles = Arrays.asList(cli.getOptionValues(CLIManager.ACTIVATE_PROFILES));
            }
        } catch (SecurityException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (NoSuchMethodException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (IllegalArgumentException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (IllegalAccessException e) {
            LOGGER.warning("ignore " + e.getMessage());
        } catch (InvocationTargetException e) {
            LOGGER.warning("ignore " + e.getMessage());
        }
    }
    return activeProfiles;
}

From source file:com.mycompany.cafieldwaae.WAAEexecutejil.java

private void createOutputLocationFile(String outputLocation, String content, Boolean overwriteOutput)
        throws ActionException {
    File outputDirs = new File(outputLocation);
    if (!outputDirs.exists()) {
        try {/* w  ww. j a  va2s .co  m*/
            outputDirs.mkdirs();
        } catch (SecurityException se) {
            log.error("Caught security exception while creating output location: " + outputLocation);
            throw new ActionException("Security exception while creating output location: " + se.getMessage(),
                    se);
        }
    }

    String fileName = outputLocation + File.separator + SCRIPT_OUTPUT;
    try {
        FileWriter fw = new FileWriter(fileName, !overwriteOutput);
        fw.write(content);
        fw.flush();
        fw.close();
    } catch (IOException e) {
        log.error("Caught IO exception during writing to file");
        throw new ActionException("IO exception during writing to file: " + e.getMessage(), e);
    }
}

From source file:org.coinspark.wallet.CSMessageDatabase.java

public CSMessageDatabase(String FilePrefix, CSLogger CSLog, Wallet ParentWallet) {
    dirName = FilePrefix + MESSAGE_DIR_SUFFIX + File.separator;
    fileName = dirName + MESSAGE_DATABASE_FILENAME
            + ((CSMessageDatabase.testnet3) ? TESTNET3_FILENAME_SUFFIX : ""); // H2 will add .mv.db extension itself
    csLog = CSLog;//from   w ww  .j  ava2s. c o  m
    wallet = ParentWallet;

    String folder = FilenameUtils.getFullPath(FilePrefix);
    String name = MESSAGE_BLOB_KEYSTORE_FILENAME
            + ((CSMessageDatabase.testnet3) ? TESTNET3_FILENAME_SUFFIX : "") + MESSAGE_MVSTORE_FILE_EXTENSION;
    String blobPath = FilenameUtils.concat(folder, name);
    boolean b = CSMessageDatabase.initBlobMap(blobPath);
    if (!b) {
        log.error("Message DB: Could not create BLOB storage map at: " + blobPath);
        return;
    }

    File dir = new File(dirName);
    if (!dir.exists()) {
        // Files.createDirectory(Paths.get(dirName));
        try {
            dir.mkdir();
        } catch (SecurityException ex) {
            log.error("Message DB: Cannot create files directory" + ex.getClass().getName() + " "
                    + ex.getMessage());
            return;
        }
    }

    String kvStoreFileName = dirName + MESSAGE_META_KEYSTORE_FILENAME
            + ((CSMessageDatabase.testnet3) ? TESTNET3_FILENAME_SUFFIX : "") + MESSAGE_MVSTORE_FILE_EXTENSION;
    kvStore = MVStore.open(kvStoreFileName);
    if (kvStore != null) {
        defMap = kvStore.openMap(MESSAGE_TXID_TO_META_MAP_NAME);
        errorMap = kvStore.openMap(MESSAGE_TXID_TO_ERROR_MAP_NAME);
    }

    // TODO?: This database URL could be passed in via constructor
    String databaseUrl = "jdbc:h2:file:" + fileName + ";USER=sa;PASSWORD=sa;AUTO_SERVER=TRUE";

    try {
        connectionSource = new JdbcConnectionSource(databaseUrl);
        messageDao = DaoManager.createDao(connectionSource, CSMessage.class);
        TableUtils.createTableIfNotExists(connectionSource, CSMessage.class);

        messagePartDao = DaoManager.createDao(connectionSource, CSMessagePart.class);
        TableUtils.createTableIfNotExists(connectionSource, CSMessagePart.class);

    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:org.pepstock.jem.ant.tasks.StepListener.java

/**
 * If a task locking scope is set, load resources definition and asks for locking
 * /*  ww w  .j  a v  a2 s. co  m*/
 * @param event ANT event
 */
@Override
public void taskStarted(BuildEvent event) {
    // checks if you are using a JAVA ANT task with FORK
    // this option is not allowed because with the fork
    // the application is out of secured environment,
    // that means without security manager

    // checks if is cast-able
    if (event.getTask() != null) {
        Task task = null;
        // checks if is an Unknown element
        if (event.getTask() instanceof UnknownElement) {
            // gets ANT task
            UnknownElement ue = (UnknownElement) event.getTask();
            ue.maybeConfigure();
            task = (Task) ue.getTask();
        } else if (event.getTask() instanceof Task) {
            // gets the task
            // here if the ANT task is already configured
            // mainly on sequential, parallel and JEM procedure
            task = (Task) event.getTask();
        }
        // if is a ANT JAVA TASK
        if (task instanceof Java && !(task instanceof StepJava)) {
            // gets AJAV task
            Java java = (Java) task;
            boolean isFork = true;
            try {
                // reflection to understand if the attribute fork is set to true
                // unfortunately ANT java task don't have any get method to have fork value
                Field f = java.getClass().getDeclaredField(ANT_JAVA_TASK_FORK_ATTRIBUTE_NAME);
                isFork = (Boolean) FieldUtils.readField(f, java, true);
            } catch (SecurityException e) {
                LogAppl.getInstance().ignore(e.getMessage(), e);
            } catch (NoSuchFieldException e) {
                LogAppl.getInstance().ignore(e.getMessage(), e);
            } catch (IllegalAccessException e) {
                LogAppl.getInstance().ignore(e.getMessage(), e);
            }
            // and force FORK to false
            java.setFork(false);
            if (isFork) {
                // shows the message of the force of fork.
                event.getProject().log(
                        AntMessage.JEMA077W.toMessage().getFormattedMessage(event.getTask().getTaskName()));
            }
        }

    }

    // if task locking scope is set, locks resources
    if (isTaskLockingScope()) {
        loadForLock(event.getTask());
        checkProcedure();
        try {
            locker.lock();
        } catch (AntException e) {
            throw new BuildException(e);
        }
    }

}

From source file:org.sakaiproject.iclicker.logic.IClickerLogicImplTest.java

public void testRemoveItem() {
    try {/* www  . j a  va2s . c  o  m*/
        logicImpl.removeItem(tdp.adminitem); // user cannot delete this
        fail("Should have thrown SecurityException");
    } catch (SecurityException e) {
        assertNotNull(e.getMessage());
    }

    try {
        logicImpl.removeItem(tdp.adminitem); // permed user cannot delete this
        fail("Should have thrown SecurityException");
    } catch (SecurityException e) {
        assertNotNull(e.getMessage());
    }

    try {
        // normal user cannot remove
        logicImpl.removeItem(tdp.item1);
        fail("Should have thrown SecurityException");
    } catch (SecurityException e) {
        assertNotNull(e.getMessage());
    }

    externalLogic.currentUserId = FakeDataPreload.ADMIN_USER_ID;
    logicImpl.removeItem(tdp.item1); // admin user can delete this
    ClickerRegistration item = logicImpl.getItemById(tdp.item1.getId());
    assertNull(item);
}

From source file:org.air.standard.web.presentation.FileUploadHandler.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 *      response)/*from  w w w  . j av a 2 s .  c  om*/
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    _logger.debug("FileUploadhandler fired!");

    String initParameterFileType = getServletConfig().getInitParameter("fileType");

    String ooExecPath = null;
    String ooSpreadsheetPath = null;
    File uploadedFile = null;

    try {
        InitialContext context = new InitialContext();

        ooExecPath = request.getSession().getServletContext().getInitParameter("ooExecPath");
        ooSpreadsheetPath = request.getSession().getServletContext().getInitParameter("ooSpreadsheetPath");
        //          ooExecPath = container.getInitParameter("ooExecPath");
        //          ooSpreadsheetPath = container.getInitParameter("ooSpreadsheetPath");
        //         ooExecPath = (String) context.lookup("java:comp/env/ooExecPath");
        //         ooSpreadsheetPath = (String) context
        //               .lookup("java:comp/env/ooSpreadsheetPath");

        boolean isMultipart = ServletFileUpload.isMultipartContent(request);
        // LoggerFactory.LogInfo("TEST File upload MANAGER", getClass());
        if (isMultipart) {
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);

            try {
                // Parse the request
                _logger.debug("Before parseRequest");
                List items = upload.parseRequest(request);
                Iterator iterator = items.iterator();
                BufferedInputStream buf = null;
                ServletOutputStream stream = null;
                while (iterator.hasNext()) {
                    FileItem item = (FileItem) iterator.next();
                    if (!item.isFormField()) {
                        String fileName = item.getName();
                        if (fileName.isEmpty())
                            throw new InvalidArgumentException("File to Upload ", "not empty");
                        _logger.debug("Parsed file file " + fileName);
                        File uploadDirectory = new File(ooSpreadsheetPath);
                        if (!uploadDirectory.exists()) {
                            boolean status = uploadDirectory.mkdirs();
                        }
                        if (!uploadDirectory.exists())
                            throw new ContentStandardException(
                                    "Problems accessing " + ooSpreadsheetPath + "server directory");
                        // just so that we do not have a name clash
                        // we will prefix the current time stamp to the file
                        // name.
                        Date date = new Date();

                        String filePath = ooSpreadsheetPath + "/" + date.getTime() + fileName;
                        uploadedFile = new File(filePath);
                        /*if (!uploadedFile.canWrite()
                              || !uploadedFile.canRead())
                           throw new ContentStandardException(
                                 "Problem with read or write access to files in "
                            + ooSpreadsheetPath
                            + " server directory");
                            */
                        /*
                         * System.out.println(uploadedFile.getAbsolutePath())
                         * ;
                         */
                        item.write(uploadedFile);
                        _logger.debug("Wrote temp file " + uploadedFile.getAbsolutePath());

                    }
                }
            } catch (SecurityException se) {
                // can be thrown by canWrite, canRead, exists, mkdirs calls
                // if server is not configured with correct access rights
                _logger.error("Problem with access rights to " + ooSpreadsheetPath + " service directory. "
                        + se.getMessage());

                displayError(se, response);
                return;
            } catch (ContentStandardException cse) {
                _logger.error(cse.getMessage());
                displayError(cse, response);
                return;
            } catch (InvalidArgumentException iae) {
                // EF: do not use displayError because it sets
                // SC_INTERNAL_SERVLET_ERROR and this is not the case!
                _logger.error("FileUploadException: " + iae.getMessage());
                ReturnStatus<Exception> status = new ReturnStatus<Exception>("failed");
                status.setPayload(null);
                status.appendToErrors(iae.getMessage());

                ObjectMapper mapper = new ObjectMapper();
                String statusJson = mapper.writeValueAsString(status);
                // serialize the status object.
                response.setContentType("application/json");
                response.getOutputStream().print(statusJson);
                return;

            } catch (FileUploadException e) {
                e.printStackTrace();
                _logger.error("FileUpload Exception: " + e.getMessage());
                displayError(e, response);
                return;
            } catch (Exception e) {
                _logger.error("Problem parsing request/creating temp file : " + e.getMessage());
                e.printStackTrace();
                displayError(e, response);
                return;
            }

        }
        /* System.out.println("CONFIG FILE:::" + ooExecPath); */
    } catch (NamingException ex) {
        /* System.out.println("exception in jndi lookup"); */
        _logger.error("NamingException in jndi lookup" + ex.getMessage());
        displayError(ex, response);
        return;
    }

    ObjectMapper mapper = new ObjectMapper();
    String statusJson = null;
    try {
        ReturnStatus<String> status = new ReturnStatus<String>("success");
        //TODO Shiva how to get the bean factory here so that we can remove (new WebUserInformation()) and call the bean instead?
        String sessionKey = (new WebUserInformation()).getSessionKey();
        // clear out existing staging tables for this session key.
        LoaderTablesDAO dao = new LoaderTablesDAO();
        dao.loaderClear(sessionKey);

        // tell DB what kind of upload we are doing - full or partial.
        PublicationDAO publicationDAO = new PublicationDAO();
        if (initParameterFileType.equalsIgnoreCase("full")) {
            publicationDAO.importPublication(sessionKey);

        } else if (initParameterFileType.equalsIgnoreCase("partial")) {
            publicationDAO.partialImportPublication(sessionKey);
        }

        _logger.debug("About to call importFromFile for " + uploadedFile.getAbsolutePath());
        OpenOfficeImporter openOfficeImporter = new OpenOfficeImporter();

        openOfficeImporter.importFromFile(ooExecPath, uploadedFile.getAbsolutePath(), sessionKey, status);
        _logger.debug("Finished importFromFile  for" + uploadedFile.getAbsolutePath() + " status is "
                + status.getStatus());
        statusJson = mapper.writeValueAsString(status);
        // serialize the status object.
        response.setContentType("application/json");
        response.getOutputStream().print(statusJson);
        _logger.debug("Sent json response ");

    } catch (Exception exp) {
        _logger.error("Exception after temp file created " + exp.getMessage());
        exp.printStackTrace();
        displayError(exp, response);
    }
}

From source file:edu.pdx.cecs.orcycle.MyApplication.java

/**
 * Connects the recording service to the Application object
 *//*w  w  w .j  a v a2 s.co  m*/
private void ConnectRecordingService() {

    try {
        Intent intent = new Intent(this, RecordingService.class);
        bindService(intent, recordingServiceServiceConnection, Context.BIND_AUTO_CREATE);
    } catch (SecurityException ex) {
        Log.d(MODULE_TAG, ex.getMessage());
    }
}

From source file:org.hyperic.hq.plugin.jboss.JBossDetector.java

@Override
protected List<ServiceResource> discoverServices(ConfigResponse serverConfig) throws PluginException {

    try {/*from  w  w w .  j  av a2 s.co m*/
        return discoverJBossServices(serverConfig);
    } catch (SecurityException e) {
        throw new PluginException(e.getMessage(), e);
    }
}

From source file:com.symbian.utils.config.ConfigUtils.java

/**
 * Print the Configuration setting/*  w  w w.j av a 2  s.  co  m*/
 * 
 * @param aLogger
 *            If <code>true</code> then prints to logger, else if
 *            <code>false</code> then prints to STDOUT.
 * @throws IOException
 */
public void printConfig(final boolean aLogger) throws IOException {
    try {

        StringBuffer lOutput = new StringBuffer();

        lOutput.append("\n");

        TreeSet<String> sortedKeys = new TreeSet<String>();
        sortedKeys.addAll(iSavedConfig.keySet());

        //sortedKeys.addAll(Arrays.asList(iPrefrences.keys()));

        for (Iterator lConfigIter = sortedKeys.iterator(); lConfigIter.hasNext();) {
            String lKey = (String) lConfigIter.next();
            //for lite version enhancement. Depreciate "sysbin", instead use "statLite"
            if (lKey.equalsIgnoreCase("platsec")) //PlatSec will not be used and should not be displayed to user
                continue;
            String lKeyDisplayName = lKey.equalsIgnoreCase("sysbin") ? "statlite" : lKey;
            String lMessage = "Preference " + lKeyDisplayName + ":"
                    + (lKeyDisplayName.length() < 12 ? "\t\t" : "\t") + iSavedConfig.get(lKey);
            if (aLogger) {
                lOutput.append(lMessage + "\n");
            } else {
                System.out.println(lMessage);
            }
        }

        if (aLogger) {
            LOGGER.info(lOutput.toString());
        }

    } catch (SecurityException lSecurityException) {
        throw new IOException("Security exception: " + lSecurityException.getMessage());
    }
}