List of usage examples for java.lang SecurityException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.gwtwidgets.server.spring.GWTRPCServiceExporter.java
/** * Handles an exception which is raised when a method invocation with bad * arguments is attempted. This implementation throws a * {@link SecurityException}. For details on arguments please consult * {@link #invokeMethodOnService(Object, Method, Object[], RPCRequest)}. * //from w w w . j av a 2 s . c o m * @param e * Exception thrown * @param service * @param targetMethod * @return RPC encoded response (such as an RPC client exception) */ protected String handleIllegalArgumentException(IllegalArgumentException e, Object service, Method targetMethod, RPCRequest rpcRequest) { SecurityException securityException = new SecurityException( "Blocked attempt to invoke method " + targetMethod); securityException.initCause(e); throw securityException; }
From source file:org.gwtwidgets.server.spring.GWTRPCServiceExporter.java
/** * Handles an exception which is raised when a method access is attempted to * a method which is not part of the RPC interface. This method is invoked * by {@link #processCall(String)}. This implementation throws a * {@link SecurityException}. For details on arguments please consult * {@link #invokeMethodOnService(Object, Method, Object[], RPCRequest)}. * /*w w w . java 2s.c o m*/ * @param e * Exception thrown * @param service * @param targetMethod * @return RPC encoded response (such as an RPC client exception) */ protected String handleIllegalAccessException(IllegalAccessException e, Object service, Method targetMethod, RPCRequest rpcRequest) { SecurityException securityException = new SecurityException("Blocked attempt to access inaccessible method " + targetMethod + (service != null ? " on service " + service : "")); securityException.initCause(e); throw securityException; }
From source file:org.spring4gwt.server.RpcHelper.java
/** * Invoke the method on targeted object and encode received response. * * @param target the target object * @param serviceMethod the service method * @param args the args of method * @param serializationPolicy the serialization policy * @param flags the flags/*from w w w .java2s . co m*/ * @throws SerializationException the serialization exception */ public static String invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } String responsePayload; try { Object result = serviceMethod.invoke(target, args); responsePayload = RPC.encodeResponseForSuccess(serviceMethod, result, serializationPolicy, flags); } catch (IllegalAccessException ex) { SecurityException securityException = new SecurityException( formatIllegalAccessErrorMessage(target, serviceMethod)); securityException.initCause(ex); throw securityException; } catch (IllegalArgumentException ex) { SecurityException securityException = new SecurityException( formatIllegalArgumentErrorMessage(target, serviceMethod, args)); securityException.initCause(ex); throw securityException; } catch (InvocationTargetException ex) { // Try to encode the caught exception // Throwable cause = ex.getCause(); LOG.error("Unexpected exception occured while invoking service method - " + serviceMethod.getName(), ex); responsePayload = RPC.encodeResponseForFailure(serviceMethod, cause, serializationPolicy, flags); } return responsePayload; }