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:de.xirp.plugin.ViewerBase.java

/**
 * Gets the value for a given getter from the data
 * /*from   w w w  .j a va 2s . c om*/
 * @param getterName
 *            the name of the getter in the data
 * @return the value or <code>null</code> if the method was not
 *         found or another problem occurred.
 */
private Object get(String getterName) {
    try {
        Method method = data.getClass().getMethod(getterName, new Class[0]);
        Object test = method.invoke(data, new Object[0]);

        return test;
    } catch (SecurityException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    } catch (NoSuchMethodException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    } catch (IllegalArgumentException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    } catch (IllegalAccessException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    } catch (InvocationTargetException e) {
        logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$
    }

    return null;
}

From source file:org.apache.myfaces.custom.skin.SkinRenderer.java

protected void _setIconDirection(FacesContext context, UIComponent component, SkinRenderingContext arc,
        String styleClass, String getProperty, String setProperty) {

    //This case is something strange. The style properties that
    //i set throught component.getAttributes.put(....) works, but
    //the image properties like in HtmlTree NOT!!!!

    Method method;/*w ww.  j  a v  a2s .  co m*/
    String oldIcon = null;
    // Check it has a getStyleClass property
    try {
        method = component.getClass().getMethod(getProperty, (Class[]) null);
        oldIcon = (String) method.invoke(component, (Object[]) null);
    } catch (SecurityException e) {
        log.debug("SecurityException" + e.getMessage());
        return;
    } catch (NoSuchMethodException e) {
        // Nothing happends
        // e.printStackTrace();
        log.debug("NoSuchMethodException" + e.getMessage());
        return;
    } catch (InvocationTargetException e) {
        // Nothing happends
        log.debug("InvocationTargetException" + e.getMessage());
        return;
    } catch (IllegalAccessException e) {
        // Nothing happends
        log.debug("IllegalAccessException" + e.getMessage());
        return;
    }

    // if the user specified a icon path for this property
    if (oldIcon == null) {
        //log.info("ICON NULO:"+arc.getIcon(styleClass)+" "+arc.getSkin().getIcon(styleClass));
        Icon icon = arc.getIcon(styleClass);
        if (icon != null) {
            String value = null;
            String baseContextPath = context.getExternalContext().getRequestContextPath() + '/';

            //For now i substract the request context path
            if (icon instanceof ContextImageIcon) {
                value = (String) icon.getImageURI(context, arc);
                if (value.startsWith(baseContextPath)) {
                    value = value.substring(baseContextPath.length() - 1);
                }
            } else {
                value = (String) icon.getImageURI(context, arc);
            }
            //log.info("ICON PATH:"+value);

            //I have to substract the base 

            // Check it has a getStyleClass property
            try {
                Class[] classes = new Class[] { String.class };
                method = component.getClass().getMethod(setProperty, classes);
                Object[] params = new Object[] { value };
                method.invoke(component, params);
            } catch (SecurityException e) {
                log.debug("SecurityException" + e.getMessage());
                return;
            } catch (NoSuchMethodException e) {
                // Nothing happends
                // e.printStackTrace();
                log.debug("NoSuchMethodException" + e.getMessage());
                return;
            } catch (InvocationTargetException e) {
                // Nothing happends
                log.debug("InvocationTargetException" + e.getMessage());
                return;
            } catch (IllegalAccessException e) {
                // Nothing happends
                log.debug("IllegalAccessException" + e.getMessage());
                return;
            }
        }
    }
}

From source file:org.sakaiproject.kernel.webapp.filter.SakaiRequestFilter.java

/**
 * {@inheritDoc}// w  w  w  .ja  v a2s.  co m
 *
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
 *      javax.servlet.ServletResponse, javax.servlet.FilterChain)
 */
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest hrequest = (HttpServletRequest) request;
    String requestedSessionID = hrequest.getRequestedSessionId();
    if (noSession) {
        request.setAttribute(SakaiServletRequest.NO_SESSION_USE, "true");
    }
    SakaiServletRequest wrequest = new SakaiServletRequest(request, response, userResolverService,
            sessionManagerService);
    SakaiServletResponse wresponse = new SakaiServletResponse(response);
    sessionManagerService.bindRequest(wrequest);
    try {
        begin();
        if (timeOn) {
            long start = System.currentTimeMillis();
            try {
                chain.doFilter(wrequest, wresponse);

            } finally {
                long end = System.currentTimeMillis();
                LOG.info("Request took " + hrequest.getMethod() + " " + hrequest.getPathInfo() + " "
                        + (end - start) + " ms");
            }
        } else {
            chain.doFilter(wrequest, wresponse);
        }
        try {
            if (jcrService.hasActiveSession()) {
                Session session = jcrService.getSession();
                session.save();
            }
        } catch (AccessDeniedException e) {
            throw new SecurityException(e.getMessage(), e);
        } catch (Exception e) {
            LOG.warn(e);
        }
        commit();
    } catch (SecurityException se) {
        se.printStackTrace();
        rollback();
        // catch any Security exceptions and send a 401
        wresponse.reset();
        wresponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, se.getMessage());
    } catch (UnauthorizedException ape) {
        rollback();
        // catch any Unauthorized exceptions and send a 401
        wresponse.reset();
        wresponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, ape.getMessage());
    } catch (PermissionDeniedException pde) {
        rollback();
        // catch any permission denied exceptions, and send a 403
        wresponse.reset();
        wresponse.sendError(HttpServletResponse.SC_FORBIDDEN, pde.getMessage());
    } catch (RuntimeException e) {
        rollback();
        throw e;
    } catch (IOException e) {
        rollback();
        throw e;
    } catch (ServletException e) {
        rollback();
        throw e;
    } catch (Throwable t) {
        rollback();
        throw new ServletException(t.getMessage(), t);
    } finally {
        wresponse.commitStatus(sessionManagerService);
        cacheManagerService.unbind(CacheScope.REQUEST);
    }
    if (debug) {
        HttpSession hsession = hrequest.getSession(false);
        if (hsession != null && !hsession.getId().equals(requestedSessionID)) {
            LOG.debug("New Session Created with ID " + hsession.getId());
        }
    }

}

From source file:org.cloudifysource.shell.validators.PortAvailabilityValidator.java

private void validateFreePorts(final String portOrRange) throws CLIValidationException {
    try {//from   w  w w  . jav a2  s .c o  m
        if (IPUtils.isValidPortRange(portOrRange)) {
            int lowestPort = IPUtils.getMinimumPort(portOrRange);
            int highestPort = IPUtils.getMaximumPort(portOrRange);
            IPUtils.validatePortIsFreeInRange(Constants.getHostAddress(), lowestPort, highestPort);
        } else {
            try {
                int port = Integer.parseInt(portOrRange);
                if (IPUtils.isValidPortNumber(port)) {
                    IPUtils.validatePortIsFree(Constants.getHostAddress(), port);
                } else {
                    throw new IllegalArgumentException("Invalid port or range: " + portOrRange);
                }
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("Invalid port or range: " + portOrRange);
            }
        }
    } catch (UnknownHostException uhe) {
        // thrown if the IP address of the host could not be determined.
        throw new CLIValidationException(uhe, 124,
                CloudifyErrorMessages.PORT_VALIDATION_ABORTED_UNKNOWN_HOST.getName(), uhe.getMessage());
    } catch (IOException ioe) {
        // thrown if an I/O error occurs when creating the socket or connecting.
        throw new CLIValidationException(ioe, 125,
                CloudifyErrorMessages.PORT_VALIDATION_ABORTED_IO_ERROR.getName(), ioe.getMessage());
    } catch (SecurityException se) {
        // thrown if a security manager exists and permission to resolve the host name is denied.
        throw new CLIValidationException(se, 126,
                CloudifyErrorMessages.PORT_VALIDATION_ABORTED_NO_PERMISSION.getName(), se.getMessage());
    }
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningActivity.java

/**
 * Try to get the last known location from the Google Api Client location api
 *//*from   w  w w  .ja v a 2  s  . c om*/
private void getLastKnownLocation() {
    if (mGoogleApiClient.isConnected()) {
        try {
            mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
            if (mCurrentLocation != null) {
                setLocation();
            }
        } catch (SecurityException e) {
            Utility.log(getApplicationContext(), LOG_TAG,
                    "getLastLocation SecurityException: " + e.getMessage());
        }
    }
}

From source file:org.xchain.namespaces.hibernate.test.TestCriteriaEntityPermission.java

@Test
public void testOnlyRootCriteria() throws Exception {
    Session session = HibernateLifecycle.getCurrentSession();
    IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername()));
    UserNote instance = (UserNote) userList.get(0).getUserNoteSet().toArray()[0];
    Transaction t = session.beginTransaction();
    Criteria notesCriteria = session.createCriteria(UserNote.class);
    notesCriteria.setProjection(Projections.projectionList().add(Projections.count("text")));
    CriteriaEntityPermission p = new CriteriaEntityPermission(EntityOperation.LOAD, UserNote.class,
            notesCriteria, null, null, null, null);
    EntityPermission<UserNote> instancePermission = new EntityPermission<UserNote>(EntityOperation.LOAD,
            instance.getId(), instance);
    try {/*from w  ww  .j a v  a2  s  .  c  o m*/
        SecurityManager.instance().checkPermission(instancePermission);
        fail();
    } catch (SecurityException e) {
    }
    try {
        IdentityManager.instance().getIdentity().getPermissions().add(p);
        SecurityManager.instance().checkPermission(instancePermission);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    t.rollback();
}

From source file:org.xchain.namespaces.hibernate.test.TestCriteriaEntityPermission.java

@Test
public void testRootAndPrincipalAreSameCriteria() throws Exception {
    Session session = HibernateLifecycle.getCurrentSession();
    IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername()));
    User instance = userList.get(0);/*from w  ww .j av a2  s  .c o  m*/
    Transaction t = session.beginTransaction();
    Criteria userCriteria = session.createCriteria(User.class);
    userCriteria.setProjection(Projections.projectionList().add(Projections.count("username")));
    CriteriaEntityPermission p = new CriteriaEntityPermission(EntityOperation.LOAD, User.class, userCriteria,
            userCriteria, null, "username", "id");
    EntityPermission<User> instancePermission = new EntityPermission<User>(EntityOperation.LOAD,
            instance.getUsername(), instance);
    try {
        SecurityManager.instance().checkPermission(instancePermission);
        fail();
    } catch (SecurityException e) {
    }
    try {
        IdentityManager.instance().getIdentity().getPermissions().add(p);
        SecurityManager.instance().checkPermission(instancePermission);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    t.rollback();
}

From source file:org.xchain.namespaces.hibernate.test.TestCriteriaEntityPermission.java

@Test
public void testAllCriteriaAreSame() throws Exception {
    Session session = HibernateLifecycle.getCurrentSession();
    IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername()));
    User instance = userList.get(0);/*from  w w  w .  j a  v  a2 s . c  om*/
    Transaction t = session.beginTransaction();
    Criteria userCriteria = session.createCriteria(User.class);
    userCriteria.setProjection(Projections.projectionList().add(Projections.count("username")));
    CriteriaEntityPermission p = new CriteriaEntityPermission(EntityOperation.LOAD, User.class, userCriteria,
            userCriteria, userCriteria, "username", "id");
    EntityPermission<User> instancePermission = new EntityPermission<User>(EntityOperation.LOAD,
            instance.getUsername(), instance);
    try {
        SecurityManager.instance().checkPermission(instancePermission);
        fail();
    } catch (SecurityException e) {
    }
    try {
        IdentityManager.instance().getIdentity().getPermissions().add(p);
        SecurityManager.instance().checkPermission(instancePermission);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    t.rollback();
}

From source file:org.xchain.namespaces.hibernate.test.TestCriteriaEntityPermission.java

@Test
public void testRootAndEntityAreSameCriteria() throws Exception {
    Session session = HibernateLifecycle.getCurrentSession();
    IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername()));
    UserNote instance = (UserNote) userList.get(0).getUserNoteSet().toArray()[0];
    Transaction t = session.beginTransaction();
    Criteria notesCriteria = session.createCriteria(UserNote.class);
    notesCriteria.setProjection(Projections.projectionList().add(Projections.count("text")));
    Criteria userCriteria = notesCriteria.createCriteria("user");
    CriteriaEntityPermission p = new CriteriaEntityPermission(EntityOperation.LOAD, UserNote.class,
            notesCriteria, userCriteria, notesCriteria, "username", "id");
    EntityPermission<UserNote> instancePermission = new EntityPermission<UserNote>(EntityOperation.LOAD,
            instance.getId(), instance);
    try {/*from   ww w  . j av a  2s .c  o m*/
        SecurityManager.instance().checkPermission(instancePermission);
        fail();
    } catch (SecurityException e) {
    }
    try {
        IdentityManager.instance().getIdentity().getPermissions().add(p);
        SecurityManager.instance().checkPermission(instancePermission);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    t.rollback();
}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningActivity.java

/**
 * Request the location api of the Google Api Client to start sending location update events
 *//*  w  w  w  .  j  av  a 2s .co  m*/
protected void startLocationUpdates() {
    if (mGoogleApiClient.isConnected() && !mRequestingLocationUpdates) {
        try {
            LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
            mRequestingLocationUpdates = true;
        } catch (SecurityException e) {
            Utility.log(getApplicationContext(), LOG_TAG,
                    "requestLocationUpdates SecurityException: " + e.getMessage());
        }
    }
}