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.appcelerator.titanium.view.TiUIView.java

private void disableHWAcceleration() {
    if (nativeView == null) {
        return;//from w w w.j av  a 2  s. c  o m
    }
    Log.d(TAG, "Disabling hardware acceleration for instance of " + nativeView.getClass().getSimpleName(),
            Log.DEBUG_MODE);
    if (mSetLayerTypeMethod == null) {
        try {
            Class<? extends View> c = nativeView.getClass();
            mSetLayerTypeMethod = c.getMethod("setLayerType", int.class, Paint.class);
        } catch (SecurityException e) {
            Log.e(TAG, "SecurityException trying to get View.setLayerType to disable hardware acceleration.", e,
                    Log.DEBUG_MODE);
        } catch (NoSuchMethodException e) {
            Log.e(TAG,
                    "NoSuchMethodException trying to get View.setLayerType to disable hardware acceleration.",
                    e, Log.DEBUG_MODE);
        }
    }

    if (mSetLayerTypeMethod == null) {
        return;
    }
    try {
        mSetLayerTypeMethod.invoke(nativeView, LAYER_TYPE_SOFTWARE, null);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, e.getMessage(), e);
    } catch (IllegalAccessException e) {
        Log.e(TAG, e.getMessage(), e);
    } catch (InvocationTargetException e) {
        Log.e(TAG, e.getMessage(), e);
    }
}

From source file:semlink.apps.uvig.Generator.java

/**
 * Executes a method in the {@link uvi.Sweeper} class based on a node tag name
 * (i.e.&nbsp;'VNCLASS') and a 'start' or 'end' flag.  Each of the methods in Sweeper,
 * startVNCLASS, endVNCLASS, startMEMBERS, endMEMBERS, etc., produce HTML code.
 * This method just calls the right method based on the current node being
 * processed by {@link uvi.Generator#processNode(Node)}.
 *
 * @param which either the value 'start' or 'end', the string to prepend to the
 *        tag name when locating the method in {@link uvi.Sweeper}
 * @param n the node whose tag name should be located in the Sweeper methods
 * @see uvi.Sweeper/*from   ww  w .j a  v  a 2s.c  om*/
 */
private static void executeHTMLMethod(String fileName, String which, Node n) {

    // Verify flag is a valid token.
    if (!which.equals("start") && !which.equals("end")) {
        eprintln("ERROR: Invalid \"which\" parameter.  Possible values are \"start\" and \"end\".");
        return;
    }

    // Use the appropriate reflection methods to execute the desired method.
    try {
        Class<?>[] classes = { Node.class };

        Method m = Sweeper.class.getDeclaredMethod(which + n.getNodeName(), classes);

        Object[] args = { n };

        m.invoke(null, args);
    } catch (NoSuchMethodException nsme) {
        // Do nothing - this is not an error condition.  It merely means the developer has not
        // specified any action for this node at this point (i.e. 'start' or 'end').
    } catch (SecurityException se) {
        eprintln("ERROR: [" + fileName + "; Security/refl] " + se.getMessage() + ".");
    } catch (Exception e) {
        e.printStackTrace();
        eprintln("ERROR: [" + fileName + "; Generic/refl] " + e.getMessage() + ".");
    } catch (Error err) {
        eprintln("ERROR: [" + fileName + "; Generic/refl-err] " + err.getMessage() + ".");
    }
}

From source file:org.apache.jackrabbit.core.RepositoryImpl.java

/**
 * Tries to add Principals to a given subject:
 * First Access the Subject from the current AccessControlContext,
 * If Subject is found the LoginContext is evoked for it, in order
 * to possibly allow for extension of preauthenticated Subject.<br>
 * In contrast to a login with Credentials, a Session is created, even if the
 * Authentication failed.<br>/*from ww  w. j  a  v a 2s  .c  o m*/
 * If the {@link Subject} is marked to be unmodificable or if the
 * authentication of the the Subject failed Session is build for unchanged
 * Subject.
 *
 * @param workspaceName must not be null
 * @return if a Subject is exsting null else
 * @throws RepositoryException
 * @throws AccessDeniedException
 */
private Session extendAuthentication(String workspaceName) throws RepositoryException, AccessDeniedException {

    Subject subject = null;
    try {
        AccessControlContext acc = AccessController.getContext();
        subject = Subject.getSubject(acc);
    } catch (SecurityException e) {
        log.warn("Can't check for preauthentication. Reason:", e.getMessage());
    }
    if (subject == null) {
        log.debug("No preauthenticated subject found -> return null.");
        return null;
    }

    Session s;
    if (subject.isReadOnly()) {
        log.debug("Preauthenticated Subject is read-only -> create Session");
        s = createSession(subject, workspaceName);
    } else {
        log.debug("Found preauthenticated Subject, try to extend authentication");
        // login either using JAAS or custom LoginModule
        AuthContext authCtx = getSecurityManager().getAuthContext(null, subject);
        try {
            authCtx.login();
            s = createSession(authCtx, workspaceName);
        } catch (javax.security.auth.login.LoginException e) {
            // subject could not be extended
            log.debug("Preauthentication could not be extended");
            s = createSession(subject, workspaceName);
        }
    }
    return s;
}

From source file:com.zimbra.cs.util.ProxyConfOverride.java

public static void expandTemplate(File tFile, File wFile) throws ProxyConfException {
    BufferedReader r = null;//from   www  . j av  a 2s. c  o  m
    BufferedWriter w = null;
    try {
        String tf = tFile.getAbsolutePath();
        String wf = wFile.getAbsolutePath();

        if (mDryRun) {
            mLog.info("Would expand template:" + tf + " to file:" + wf);
            return;
        }

        mLog.info("Expanding template:" + tf + " to file:" + wf);

        if (!tFile.exists()) {
            throw new ProxyConfException("Template file " + tf + " does not exist");
        }
        r = new BufferedReader(new FileReader(tf));
        w = new BufferedWriter(new FileWriter(wf));

        String line;

        //for the first line of template, check the custom header command
        r.mark(100); //assume the first line won't beyond 100
        line = r.readLine();

        //only for back compability
        if (line.equalsIgnoreCase("!{explode vhn_vip_ssl}")) {
            expandTemplateExplodeSSLConfigsForAllVhnsAndVIPs(r, w);
            return;
        }
        Matcher cmdMatcher = cmdPattern.matcher(line);
        if (cmdMatcher.matches()) {
            //the command is found
            String[] cmd_arg = cmdMatcher.group(2).split("[ \t]+", 2);
            //command selection can be extracted if more commands are introduced
            if (cmd_arg.length == 2 && cmd_arg[0].compareTo("explode") == 0) {

                if (!mGenConfPerVhn) { // explode only when GenConfPerVhn is enabled
                    return;
                }

                if (cmd_arg[1].startsWith("domain(") && cmd_arg[1].endsWith(")")) {
                    //extract the args in "domain(arg1, arg2, ...)
                    String arglist = cmd_arg[1].substring("domain(".length(), cmd_arg[1].length() - 1);
                    String[] args;
                    if (arglist.equals("")) {
                        args = new String[0];
                    } else {
                        args = arglist.split(",( |\t)*");
                    }
                    expandTemplateByExplodeDomain(r, w, args);
                } else {
                    throw new ProxyConfException("Illegal custom header command: " + cmdMatcher.group(2));
                }
            } else {
                throw new ProxyConfException("Illegal custom header command: " + cmdMatcher.group(2));
            }
        } else {
            r.reset(); //reset to read the first line
            expandTemplateSimple(r, w);
        }

    } catch (IOException ie) {
        throw new ProxyConfException("Cannot expand template file: " + ie.getMessage());

    } catch (SecurityException se) {
        throw new ProxyConfException("Cannot expand template: " + se.getMessage());
    } finally {
        try {
            if (w != null)
                w.close();
            if (r != null)
                r.close();
        } catch (IOException e) {
            throw new ProxyConfException("Cannot expand template file: " + e.getMessage());
        }
    }
}

From source file:au.org.theark.core.service.ArkCommonServiceImpl.java

/**
 * {@inheritDoc}/*from ww  w.  j ava  2  s.  com*/
 */
public void createArkFileAttachmentDirectoy(String directoryName) throws ArkSystemException {
    File fileDir = new File(directoryName);

    if (!fileDir.exists()) {
        try {
            fileDir.mkdirs();
        } catch (SecurityException se) {
            log.error("Do not have the sufficient permission to access the file directory " + directoryName,
                    se);
            throw new ArkSystemException(se.getMessage());
        }
    }
}

From source file:org.apache.jackrabbit.core.RepositoryImpl.java

/**
 * Tries to add Principals to a given subject:
 * First Access the Subject from the current AccessControlContext,
 * If Subject is found the LoginContext is evoked for it, in order
 * to possibly allow for extension of preauthenticated Subject.<br>
 * In contrast to a login with Credentials, a Session is created, even if the
 * Authentication failed.<br>/*from   www.  j  av  a 2  s  .  com*/
 * If the {@link Subject} is marked to be unmodificable or if the
 * authentication of the the Subject failed Session is build for unchanged
 * Subject.
 *
 * @param workspaceName must not be null
 * @return if a Subject is exsting null else
 * @throws RepositoryException
 * @throws AccessDeniedException
 */
private Session extendAuthentication(String workspaceName) throws RepositoryException, AccessDeniedException {

    Subject subject = null;
    try {
        AccessControlContext acc = AccessController.getContext();
        subject = Subject.getSubject(acc);
    } catch (SecurityException e) {
        log.warn("Can't check for preauthentication. Reason: {}", e.getMessage());
    }
    if (subject == null) {
        log.debug("No preauthenticated subject found -> return null.");
        return null;
    }

    Session s;
    if (subject.isReadOnly()) {
        log.debug("Preauthenticated Subject is read-only -> create Session");
        s = createSession(subject, workspaceName);
    } else {
        log.debug("Found preauthenticated Subject, try to extend authentication");
        // login either using JAAS or custom LoginModule
        AuthContext authCtx = context.getSecurityManager().getAuthContext(null, subject, workspaceName);
        try {
            authCtx.login();
            s = createSession(authCtx, workspaceName);
        } catch (javax.security.auth.login.LoginException e) {
            // subject could not be extended
            log.debug("Preauthentication could not be extended");
            s = createSession(subject, workspaceName);
        }
    }
    return s;
}

From source file:org.apache.hadoop.mapred.ClientServiceDelegate.java

private synchronized Object invoke(String method, Class argClass, Object args) throws IOException {
    Method methodOb = null;/*from ww w.  j a  v  a  2  s.co  m*/
    try {
        methodOb = MRClientProtocol.class.getMethod(method, argClass);
    } catch (SecurityException e) {
        throw new YarnRuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new YarnRuntimeException("Method name mismatch", e);
    }
    maxClientRetry = this.conf.getInt(MRJobConfig.MR_CLIENT_MAX_RETRIES,
            MRJobConfig.DEFAULT_MR_CLIENT_MAX_RETRIES);
    IOException lastException = null;
    while (maxClientRetry > 0) {
        MRClientProtocol MRClientProxy = null;
        try {
            MRClientProxy = getProxy();
            return methodOb.invoke(MRClientProxy, args);
        } catch (InvocationTargetException e) {
            // Will not throw out YarnException anymore
            LOG.debug("Failed to contact AM/History for job " + jobId + " retrying..", e.getTargetException());
            // Force reconnection by setting the proxy to null.
            realProxy = null;
            // HS/AMS shut down

            if (e.getCause() instanceof AuthorizationException) {
                throw new IOException(e.getTargetException());
            }

            // if it's AM shut down, do not decrement maxClientRetry as we wait for
            // AM to be restarted.
            if (!usingAMProxy.get()) {
                maxClientRetry--;
            }
            usingAMProxy.set(false);
            lastException = new IOException(e.getTargetException());
            try {
                Thread.sleep(100);
            } catch (InterruptedException ie) {
                LOG.warn("ClientServiceDelegate invoke call interrupted", ie);
                throw new YarnRuntimeException(ie);
            }
        } catch (Exception e) {
            LOG.debug("Failed to contact AM/History for job " + jobId + "  Will retry..", e);
            // Force reconnection by setting the proxy to null.
            realProxy = null;
            // RM shutdown
            maxClientRetry--;
            lastException = new IOException(e.getMessage());
            try {
                Thread.sleep(100);
            } catch (InterruptedException ie) {
                LOG.warn("ClientServiceDelegate invoke call interrupted", ie);
                throw new YarnRuntimeException(ie);
            }
        }
    }
    throw lastException;
}

From source file:org.openremote.modeler.cache.LocalFileCache.java

/**
 * Tests for existence of a Beehive archive in the user's cache directory (as specified
 * by {@link #BEEHIVE_ARCHIVE_NAME} constant}.
 *
 * @see #getCachedArchive/*from   w  ww  .  jav a2s  . c o m*/
 *
 * @return    true if Beehive archive is present in user account's cache folder, false
 *            otherwise
 *
 * @throws ConfigurationException
 *            if file read access is denied by security manager
 */
private boolean hasCachedArchive() throws ConfigurationException {
    File f = getCachedArchive();

    try {
        return f.exists();
    }

    catch (SecurityException e) {
        throw new ConfigurationException("Security manager has denied read access to ''{0}'' : {1}", e,
                f.getAbsolutePath(), e.getMessage());
    }
}

From source file:eu.semlibproject.annotationserver.restapis.NotebooksAPI.java

/**
 * Search for all annotation metadata according to specific parameters within a specified Notebook.
 * //from  ww  w  .  j  ava2  s  .  c o m
 * @param callback      callback function for JSONP
 * @param queryParams   parameters (JSON format), encoded
 * @param accept        the accepted format (n3, application/rdf+xml or application/json)
 * @param limit         max number of annotation to retrieve
 * @param offset        offset for annotations retrieval
 * @param orderby       property for order by
 * @param orderingMode  1/0 (desc/asc) for orderby
 * @return              HTTP Response Status Code:
 *                      <ul>
 *                          <li>"200 OK" annotation metadata</li>
 *                          <li>"204 No Content" if there are no annotation metadata for the specified parameters</li>
 *                          <li>"400 Bad Request" if the specified parameters or the request are incorrect</li>
 *                          <li>"403 Forbidden" if the current logged user has not the correct rights to access to the specified Notebook</li>
 *                          <li>"500 Internal Server Error" in case of error</li>
 *                      </ul>
 */
@GET
@Path("{notebook-id}/search")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_RDFXML, MediaType.TEXT_RDFN3,
        MediaType.APPLICATION_JAVASCRIPT, MediaType.TEXT_HTML })
public Response searchAnnotationMetadataInNotebooks(@QueryParam(SemlibConstants.JSONP_PARAM) String callback,
        @PathParam("notebook-id") String notebookID,
        @QueryParam(SemlibConstants.QUERY_PARAM) String queryParams,
        @HeaderParam(SemlibConstants.HTTP_HEADER_ACCEPT) String accepts,
        @QueryParam(SemlibConstants.LIMIT_PARAM) String limit,
        @QueryParam(SemlibConstants.OFFSET_PARAM) String offset,
        @QueryParam(SemlibConstants.ORDERBY_PARAM) String orderby,
        @QueryParam(SemlibConstants.DESC_PARAM) String orderingMode) {

    if (queryParams == null || queryParams.length() == 0) {
        return Response.status(Status.BAD_REQUEST).build();
    }

    User currentLoggedUser = super.getCurrentLoggedUserOrAnonUser();

    try {
        PermissionsManager permManager = eu.semlibproject.annotationserver.managers.SecurityManager
                .getInstance().getPermissionManager();

        boolean rightsOk = permManager.canReadNotebook(currentLoggedUser.getUserID(), notebookID);
        if (!rightsOk) {
            return Response.status(Status.FORBIDDEN).build();
        }
    } catch (eu.semlibproject.annotationserver.security.SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
        return Response.status(ex.getStatusCode()).build();
    }

    int qLimit = UtilsManager.getInstance().parseLimitOrOffset(limit);
    int qOffset = UtilsManager.getInstance().parseLimitOrOffset(offset);
    boolean desc = false;

    if (orderingMode != null && orderingMode.equals("1")) {
        desc = true;
    }

    Status notebookIDStatus = super.checkNotebookID(notebookID, false);
    if (notebookIDStatus != Status.OK) {
        return Response.status(notebookIDStatus).build();
    }

    UtilsManager utilsManager = UtilsManager.getInstance();
    String cAccepts = utilsManager.getCorrectAcceptValue(callback, accepts);
    String tripleFormat = utilsManager.getCorrectTripleFormat(callback, accepts, cAccepts);

    List<String> notebookIDsList = new ArrayList<String>();
    notebookIDsList.add(notebookID);

    String annotationMetadata = null;
    try {
        annotationMetadata = RepositoryManager.getInstance().getCurrentRDFRepository()
                .searchMetadataWithParameters(queryParams, qLimit, qOffset, orderby, desc, tripleFormat,
                        notebookIDsList);
    } catch (RepositoryException ex) {
        logger.log(Level.SEVERE, ex.getMessage().toString(), ex);
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }

    if (annotationMetadata != null) {
        if (StringUtils.isBlank(annotationMetadata)) {
            return Response.status(Status.NO_CONTENT).build();
        } else {
            return super.createFinalResponseForNotebooksAPI(Response.Status.OK, callback, cAccepts,
                    annotationMetadata, null);
        }
    } else {
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }
}

From source file:org.openremote.modeler.cache.LocalFileCache.java

/**
 * TODO : http://jira.openremote.org/browse/MODELER-285
 *
 * Checks for the existence of a latest daily backup copy of this account's Beehive
 * archive./*from  www  .  j av a 2 s .  co  m*/
 *
 * @see #getNewestDailyBackupFile
 *
 * @return    true if what is marked as the most recent copy of the account's Beehive archive
 *            exists in the backup directory, false otherwise
 *
 * @throws ConfigurationException
 *            if read access to the latest daily backup copy has been denied
 */
private boolean hasNewestDailyBackup() throws ConfigurationException {
    File cacheFolder = getBackupFolder();
    File newestDaily = getNewestDailyBackupFile();

    try {
        return newestDaily.exists();
    }

    catch (SecurityException e) {
        throw new ConfigurationException("Security manager has denied read access to ''{0}'' in ''{1}'' : {2}",
                e, newestDaily, cacheFolder.getAbsolutePath(), e.getMessage());
    }
}