Example usage for java.lang SecurityException getLocalizedMessage

List of usage examples for java.lang SecurityException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:es.juntadeandalucia.panelGestion.negocio.utiles.PanelSettings.java

private static void readDataBaseTypes(Document xmlConfiguration) {
    dataBaseTypes = new HashMap<String, Integer>();

    Element doc = xmlConfiguration.getDocumentElement();
    NodeList nodesDataBaseTypes = doc.getElementsByTagName("dataBaseType");

    // iterate over the data base types
    for (int i = 0; i < nodesDataBaseTypes.getLength(); i++) {
        // get the data base type node
        Node dataBaseType = nodesDataBaseTypes.item(i);

        if (dataBaseType instanceof Element) {
            Element dataBaseTypeElem = (Element) dataBaseType;

            String dataBaseTypeLabel = getStringNodeValue("label", dataBaseTypeElem);
            String sqlTypeStr = getStringNodeValue("sqlType", dataBaseTypeElem);
            Integer sqlType = null;
            if (!StringUtils.isEmpty(sqlTypeStr)) {
                Field typeField;//from w  ww.jav a2  s.  com
                try {
                    typeField = Types.class.getDeclaredField(sqlTypeStr);
                    if (typeField != null) {
                        sqlType = typeField.getInt(null);
                    }
                } catch (SecurityException e) {
                    log.error(
                            "Error al intentar obtener los tipos de base de datos del fichero de configuracin: "
                                    + e.getLocalizedMessage());
                } catch (NoSuchFieldException e) {
                    log.error(
                            "Error al intentar obtener los tipos de base de datos del fichero de configuracin: "
                                    + e.getLocalizedMessage());
                } catch (IllegalArgumentException e) {
                    log.error(
                            "Error al intentar obtener los tipos de base de datos del fichero de configuracin: "
                                    + e.getLocalizedMessage());
                } catch (IllegalAccessException e) {
                    log.error(
                            "Error al intentar obtener los tipos de base de datos del fichero de configuracin: "
                                    + e.getLocalizedMessage());
                }
            }
            dataBaseTypes.put(dataBaseTypeLabel, sqlType);
        }
    }
}

From source file:dev.drsoran.moloko.auth.AuthenticatorActivity.java

/**
 * Response is received from the server for authentication request. Sets the AccountAuthenticatorResult which is sent
 * back to the caller. Also sets the authToken in AccountManager for this account.
 *///from   w w  w.j  av  a 2  s . co  m
@Override
public void onAuthenticationFinished(RtmAuth rtmAuth) {
    final Account account = new Account(rtmAuth.getUser().getUsername(), Constants.ACCOUNT_TYPE);
    try {
        boolean ok = true;

        if (isNewAccount) {
            ok = accountManager.addAccountExplicitly(account, rtmAuth.getToken(), null);
            if (ok) {
                ContentResolver.setSyncAutomatically(account, Rtm.AUTHORITY, true);
            }
        }

        if (ok) {
            accountManager.setUserData(account, Constants.FEAT_API_KEY, MolokoApp.getRtmApiKey(this));
            accountManager.setUserData(account, Constants.FEAT_SHARED_SECRET,
                    MolokoApp.getRtmSharedSecret(this));
            accountManager.setUserData(account, Constants.FEAT_PERMISSION, rtmAuth.getPerms().toString());
            accountManager.setUserData(account, Constants.ACCOUNT_USER_ID, rtmAuth.getUser().getId());
            accountManager.setUserData(account, Constants.ACCOUNT_FULLNAME, rtmAuth.getUser().getFullname());

            final Intent intent = new Intent();

            intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, rtmAuth.getUser().getUsername());
            // We store the authToken as password
            intent.putExtra(AccountManager.KEY_PASSWORD, rtmAuth.getToken());
            intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
            intent.putExtra(AccountManager.KEY_AUTHTOKEN, rtmAuth.getToken());

            intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, true);

            setAccountAuthenticatorResult(intent.getExtras());
            setResult(RESULT_OK, intent);
        }
    } catch (SecurityException e) {
        MolokoApp.Log.e(getClass(), e.getLocalizedMessage());
        onAuthenticationFailed(getString(R.string.auth_err_cause_scurity));
    } finally {
        finish();
    }
}

From source file:org.opentaps.common.reporting.ChartViewHandler.java

public void render(String name, String page, String info, String contentType, String encoding,
        HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {

    /*//  w  ww .  ja v a  2s. co m
     * Looks for parameter "chart" first. Send this temporary image files
     * to client if it exists and return.
     */
    String chartFileName = UtilCommon.getParameter(request, "chart");
    if (UtilValidate.isNotEmpty(chartFileName)) {
        try {
            ServletUtilities.sendTempFile(chartFileName, response);
            if (chartFileName.indexOf(ServletUtilities.getTempOneTimeFilePrefix()) != -1) {
                // delete temporary file
                File file = new File(System.getProperty("java.io.tmpdir"), chartFileName);
                file.delete();
            }
        } catch (IOException ioe) {
            Debug.logError(ioe.getLocalizedMessage(), module);
        }
        return;
    }

    /*
     * Next option eliminate need to store chart in file system. Some event handler
     * included in request chain prior to this view handler can prepare ready to use
     * instance of JFreeChart and place it to request attribute chartContext.
     * Currently chartContext should be Map<String, Object> and we expect to see in it:
     *   "charObject"       : JFreeChart
     *   "width"            : positive Integer
     *   "height"           : positive Integer
     *   "encodeAlpha"      : Boolean (optional)
     *   "compressRatio"    : Integer in range 0-9 (optional)
     */
    Map<String, Object> chartContext = (Map<String, Object>) request.getAttribute("chartContext");
    if (UtilValidate.isNotEmpty(chartContext)) {
        try {
            sendChart(chartContext, response);
        } catch (IOException ioe) {
            Debug.logError(ioe.getLocalizedMessage(), module);
        }
        return;
    }

    /*
     * Prepare context for next options
     */
    Map<String, Object> callContext = FastMap.newInstance();
    callContext.put("parameters", UtilHttp.getParameterMap(request));
    callContext.put("delegator", request.getAttribute("delegator"));
    callContext.put("dispatcher", request.getAttribute("dispatcher"));
    callContext.put("userLogin", request.getSession().getAttribute("userLogin"));
    callContext.put("locale", UtilHttp.getLocale(request));

    /*
     * view-map attribute "page" may contain BeanShell script in component
     * URL format that should return chartContext map.
     */
    if (UtilValidate.isNotEmpty(page) && UtilValidate.isUrl(page) && page.endsWith(".bsh")) {
        try {
            chartContext = (Map<String, Object>) BshUtil.runBshAtLocation(page, callContext);
            if (UtilValidate.isNotEmpty(chartContext)) {
                sendChart(chartContext, response);
            }
        } catch (GeneralException ge) {
            Debug.logError(ge.getLocalizedMessage(), module);
        } catch (IOException ioe) {
            Debug.logError(ioe.getLocalizedMessage(), module);
        }
        return;
    }

    /*
     * As last resort we can decide that "page" attribute contains class name and "info"
     * contains method Map<String, Object> getSomeChart(Map<String, Object> context).
     * There are parameters, delegator, dispatcher, userLogin and locale in the context.
     * Should return chartContext.
     */
    if (UtilValidate.isNotEmpty(page) && UtilValidate.isNotEmpty(info)) {
        Class handler = null;
        synchronized (this) {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            try {
                handler = loader.loadClass(page);
                if (handler != null) {
                    Method runMethod = handler.getMethod(info, new Class[] { Map.class });
                    chartContext = (Map<String, Object>) runMethod.invoke(null, callContext);
                    if (UtilValidate.isNotEmpty(chartContext)) {
                        sendChart(chartContext, response);
                    }
                }
            } catch (ClassNotFoundException cnfe) {
                Debug.logError(cnfe.getLocalizedMessage(), module);
            } catch (SecurityException se) {
                Debug.logError(se.getLocalizedMessage(), module);
            } catch (NoSuchMethodException nsme) {
                Debug.logError(nsme.getLocalizedMessage(), module);
            } catch (IllegalArgumentException iae) {
                Debug.logError(iae.getLocalizedMessage(), module);
            } catch (IllegalAccessException iace) {
                Debug.logError(iace.getLocalizedMessage(), module);
            } catch (InvocationTargetException ite) {
                Debug.logError(ite.getLocalizedMessage(), module);
            } catch (IOException ioe) {
                Debug.logError(ioe.getLocalizedMessage(), module);
            }
        }
    }

    // Why you disturb me?
    throw new ViewHandlerException(
            "In order to generate chart you have to provide chart object or file name. There are no such data in request. Please read comments to ChartViewHandler class.");
}

From source file:org.deegree.services.config.servlet.ConfigServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String path = req.getPathInfo();
    if (path == null || path.equals("/")) {
        StringBuilder data = new StringBuilder("No action specified.\n\nAvailable actions:\n");
        data.append(/*w  ww.  j  a  va2  s .  c  o m*/
                "GET /config/download[/path]                                  - download currently running workspace or file in workspace\n");
        data.append(
                "GET /config/download/wsname[/path]                           - download workspace with name <wsname> or file in workspace\n");
        data.append(
                "GET /config/restart                                          - restart currently running workspace\n");
        data.append(
                "GET /config/restart[/path]                                   - restarts all resources connected to the specified one\n");
        data.append(
                "GET /config/restart/wsname                                   - restart with workspace <wsname>\n");
        data.append(
                "GET /config/listworkspaces                                   - list available workspace names\n");
        data.append(
                "GET /config/list[/path]                                      - list currently running workspace or directory in workspace\n");
        data.append(
                "GET /config/list/wsname[/path]                               - list workspace with name <wsname> or directory in workspace\n");
        data.append(
                "GET /config/invalidate/datasources/tile/id/matrixset[?bbox=] - invalidate part or all of a tile store cache's tile matrix set\n");
        data.append(
                "GET /config/crs/list                                         - list available CRS definitions\n");
        data.append(
                "POST /config/crs/getcodes with wkt=<wkt>                     - retrieves a list of CRS codes corresponding to the WKT (POSTed KVP)\n");
        data.append(
                "GET /config/crs/<code>                                       - checks if a CRS definition is available, returns true/false\n");
        data.append(
                "PUT /config/upload/wsname.zip                                - upload workspace <wsname>\n");
        data.append(
                "PUT /config/upload/path/file                                 - upload file into current workspace\n");
        data.append(
                "PUT /config/upload/wsname/path/file                          - upload file into workspace with name <wsname>\n");
        data.append(
                "DELETE /config/delete[/path]                                 - delete currently running workspace or file in workspace\n");
        data.append(
                "DELETE /config/delete/wsname[/path]                          - delete workspace with name <wsname> or file in workspace\n");
        data.append("\nHTTP response codes used:\n");
        data.append("200 - ok\n");
        data.append("403 - if you tried something you shouldn't have\n");
        data.append("404 - if a file or directory needed to fulfill a request was not found\n");
        data.append("500 - if something serious went wrong on the server side\n");
        IOUtils.write(data.toString(), resp.getOutputStream());
        return;
    }

    try {
        dispatch(path, req, resp);
    } catch (SecurityException e) {
        resp.setStatus(403);
        IOUtils.write("There were security concerns: " + e.getLocalizedMessage() + "\n",
                resp.getOutputStream());
    } catch (Throwable e) {
        resp.setStatus(500);
        IOUtils.write("Error while processing request: " + e.getLocalizedMessage() + "\n",
                resp.getOutputStream());
    }
}

From source file:info.magnolia.jcr.util.ContentMap.java

public ContentMap(Node content) {
    if (content == null) {
        throw new NullPointerException("ContentMap doesn't accept null content");
    }//from  w  w w.j  a v  a 2s.  co m

    this.content = content;

    // Supported special types are: @nodeType @name, @path @depth (and their deprecated forms - see
    // convertDeprecatedProps() for details)
    Class<? extends Node> clazz = content.getClass();
    try {
        specialProperties.put("name", clazz.getMethod("getName", (Class<?>[]) null));
        specialProperties.put("id", clazz.getMethod("getIdentifier", (Class<?>[]) null));
        specialProperties.put("path", clazz.getMethod("getPath", (Class<?>[]) null));
        specialProperties.put("depth", clazz.getMethod("getDepth", (Class<?>[]) null));
        specialProperties.put("nodeType", clazz.getMethod("getPrimaryNodeType", (Class<?>[]) null));
    } catch (SecurityException e) {
        log.debug("Failed to gain access to Node get***() method. Check VM security settings. "
                + e.getLocalizedMessage(), e);
    } catch (NoSuchMethodException e) {
        log.debug(
                "Failed to retrieve get***() method of Node class. Check the classpath for conflicting version of JCR classes. "
                        + e.getLocalizedMessage(),
                e);
    }
}

From source file:edu.usf.cutr.fdot7.main.Test.java

/**
 * Download file method//w  w  w.j av a 2  s.com
 * @param downloadUrl - URL of the file to be downloaded
 * @return A string of data
 * @throws IOException
 */
private String downloadFileFromUrl(URL downloadUrl) throws IOException {
    String filename = "gtfs.zip";
    File downloadedFolder = new File("GTFS_Temp");
    String downloadedLocation = downloadedFolder.getAbsolutePath() + System.getProperty("file.separator"); //"\\"; //temporary folder to store downloaded files
    String full_path = downloadedLocation + filename;
    try {
        downloadedFolder.mkdir(); //create the directory if not already created
    } catch (SecurityException ex) {
        _log.info("Unable to create temporary directory to download the GTFS data to. \n"
                + ex.getLocalizedMessage());
        return null;
    }
    if (downloadedFolder.listFiles().length > 0) { //if the folder has old files in it
        for (File f : downloadedFolder.listFiles()) {
            f.delete(); //delete all the old files
        }
    }

    BufferedInputStream in = new BufferedInputStream(downloadUrl.openStream());

    byte[] buffer = new byte[1024];
    int count;

    FileOutputStream out = new FileOutputStream(full_path);

    while ((count = in.read(buffer, 0, 1024)) > 0) {
        out.write(buffer, 0, count);
    }

    out.close();

    return full_path;
}

From source file:com.landenlabs.all_devtool.GpsFragment.java

private void showProviders() {
    GpsInfo gpsInfo = m_list.get(s_providersRow);
    ItemList itemList = gpsInfo.getList();
    itemList.clear();/*ww  w .  j a  va  2s.co m*/

    List<String> gpsProviders = m_locMgr.getAllProviders();
    int idx = 1;
    for (String providerName : gpsProviders) {
        if (ActivityCompat.checkSelfPermission(getContext(),
                Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                || ActivityCompat.checkSelfPermission(getContext(),
                        Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            try {
                LocationProvider provider = m_locMgr.getProvider(providerName);
                if (null != provider) {
                    int color = getProviderColor(providerName);
                    String msg = String.format("%-10s %3s Accuracy:%d Pwr:%d", providerName,
                            (m_locMgr.isProviderEnabled(providerName) ? "On" : "Off"), provider.getAccuracy(),
                            provider.getPowerRequirement());
                    itemList.add(new GpsItem(s_noTime, msg, color));
                }
            } catch (SecurityException ex) {
                m_log.e(ex.getLocalizedMessage());
                m_gpsTv.setEnabled(false);
                addMsgToDetailRow(s_colorMsg, "GPS not available");
                addMsgToDetailRow(s_colorMsg, ex.getLocalizedMessage());
            }
        }
    }
    listChanged();

    if (m_locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER))
        m_statusIcon.setImageResource(R.drawable.gps_satellite);
    else if (m_locMgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
        m_statusIcon.setImageResource(R.drawable.gps_tower);
    else if (m_locMgr.isProviderEnabled(LocationManager.PASSIVE_PROVIDER))
        m_statusIcon.setImageResource(R.drawable.gps_passive);
    else
        m_statusIcon.setImageResource(R.drawable.gps_off);
}

From source file:org.eclipse.jubula.communication.Communicator.java

/**
 * establish the connection, either connecting to a server or accepting
 * connections. This method will not block. If a connection could not made,
 * the listeners are notified with connectingFailed() and acceptingFailed
 * respectively.// w ww.  j  a  v  a  2  s  .com
 * 
 * @return the Thread responsible for accepting connections, or 
 *         <code>null</code> if the the receiver is acting as a client.
 * @throws SecurityException
 *             if the security manager does not allow connections.
 * @throws JBVersionException
 *             in case of version error between Client and AutStarter
 */
public synchronized Thread run() throws SecurityException, JBVersionException {

    Thread acceptingThread = null;
    if (m_serverSocket != null && !isAccepting()) {
        // it's a server that hasn't yet started accepting connections
        setAccepting(true);
        acceptingThread = new AcceptingThread();
        acceptingThread.start();
    } else if (m_inetAddress != null) {
        // it's a client
        try {
            DefaultSocket socket = new DefaultSocket(m_inetAddress, m_port, m_initConnectionTimeout * THOUSAND);
            if (socket.isConnectionEstablished()) {
                setup(socket);
            } else {
                log.info("connecting failed with server state: " //$NON-NLS-1$
                        + String.valueOf(socket.getState()));
                fireConnectingFailed(m_inetAddress, m_port);
            }
        } catch (IllegalArgumentException iae) {
            log.debug(iae.getLocalizedMessage(), iae);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (IOException ioe) {
            log.debug(ioe.getLocalizedMessage(), ioe);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (SecurityException se) {
            log.debug(se.getLocalizedMessage(), se);
            fireConnectingFailed(m_inetAddress, m_port);
            throw se;
        }
    }

    return acceptingThread;
}

From source file:org.eclipse.jubula.communication.internal.Communicator.java

/**
 * establish the connection, either connecting to a server or accepting
 * connections. This method will not block. If a connection could not made,
 * the listeners are notified with connectingFailed() and acceptingFailed
 * respectively./*from   w ww  .j a va2  s.  c  o m*/
 * 
 * @return the Thread responsible for accepting connections, or 
 *         <code>null</code> if the the receiver is acting as a client.
 * @throws SecurityException
 *             if the security manager does not allow connections.
 * @throws JBVersionException
 *             in case of version error between Client and AutStarter
 */
public synchronized Thread run() throws SecurityException, JBVersionException {

    Thread acceptingThread = null;
    if (m_serverSocket != null && !isAccepting()) {
        // it's a server that hasn't yet started accepting connections
        setAccepting(true);
        acceptingThread = new AcceptingThread();
        acceptingThread.start();
    } else if (m_inetAddress != null) {
        // it's a client
        try {
            DefaultClientSocket socket = new DefaultClientSocket(m_inetAddress, m_port,
                    DEFAULT_CONNECTING_TIMEOUT * THOUSAND);
            if (socket.isConnectionEstablished()) {
                setup(socket);
            } else {
                log.info("connecting failed with server state: " //$NON-NLS-1$
                        + String.valueOf(socket.getState()));
                fireConnectingFailed(m_inetAddress, m_port);
            }
        } catch (IllegalArgumentException iae) {
            log.debug(iae.getLocalizedMessage(), iae);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (IOException ioe) {
            log.debug(ioe.getLocalizedMessage(), ioe);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (SecurityException se) {
            log.debug(se.getLocalizedMessage(), se);
            fireConnectingFailed(m_inetAddress, m_port);
            throw se;
        }
    }

    return acceptingThread;
}