• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServerError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中java.rmi.ServerError的典型用法代码示例。如果您正苦于以下问题:Java ServerError类的具体用法?Java ServerError怎么用?Java ServerError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerError类属于java.rmi包,在下文中一共展示了ServerError类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: wrapException

import java.rmi.ServerError; //导入依赖的package包/类
/**
 * Wraps an exception thrown by an implementation
 * method.  It returns the corresponding client-side exception.
 * @param orig the exception to wrap.
 * @return the wrapped exception.
 */
public RemoteException wrapException(Throwable orig)
{
    if (orig instanceof SystemException) {
        return mapSystemException((SystemException)orig);
    }

    if (orig instanceof Error) {
        return new ServerError("Error occurred in server thread",(Error)orig);
    } else if (orig instanceof RemoteException) {
        return new ServerException("RemoteException occurred in server thread",
                                   (Exception)orig);
    } else if (orig instanceof RuntimeException) {
        throw (RuntimeException) orig;
    }

    if (orig instanceof Exception)
        return new UnexpectedException( orig.toString(), (Exception)orig );
    else
        return new UnexpectedException( orig.toString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:Util.java


示例2: invokeRemote

import java.rmi.ServerError; //导入依赖的package包/类
private static Object invokeRemote(@NotNull Method localMethod,
                                   @NotNull Method remoteMethod,
                                   @NotNull Object remoteObj,
                                   @Nullable Object[] args,
                                   @Nullable ClassLoader loader,
                                   boolean substituteClassLoader)
  throws Exception {
  boolean canThrowError = false;
  try {
    Object result = remoteMethod.invoke(remoteObj, args);
    canThrowError = true;
    return handleRemoteResult(result, localMethod.getReturnType(), loader, substituteClassLoader);
  }
  catch (InvocationTargetException e) {
    Throwable cause = e.getCause(); // root cause may go deeper than we need, so leave it like this
    if (cause instanceof ServerError) cause = ObjectUtils.chooseNotNull(cause.getCause(), cause);
    if (cause instanceof RuntimeException) throw (RuntimeException)cause;
    else if (canThrowError && cause instanceof Error || cause instanceof LinkageError) throw (Error)cause;
    else if (canThrow(cause, localMethod)) throw (Exception)cause;
    throw new RuntimeException(cause);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RemoteUtil.java


示例3: readParams

import java.rmi.ServerError; //导入依赖的package包/类
private Object[] readParams(Method m, RMIObjectInputStream oin)
        throws RemoteException {
    Class[] paramTypes = m.getParameterTypes();
    Object[] params = new Object[paramTypes.length];

    try {
        for (int i = 0; i < paramTypes.length; ++i) {
            params[i] = oin.readRMIObject(paramTypes[i]);
        }
    } catch (RemoteException re) {
        // rmi.69=RemoteException occurred while unmarshalling arguments
        throw new ServerException(Messages.getString("rmi.69"), re); //$NON-NLS-1$
    } catch (IOException ioe) {
        // rmi.6A=IOException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6A"), ioe); //$NON-NLS-1$
    } catch (ClassNotFoundException cnfe) {
        // rmi.6B=ClassNotFoundException occurred while unmarshalling arguments
        throw new UnmarshalException(Messages.getString("rmi.6B"), cnfe); //$NON-NLS-1$
    } catch (Error er) {
        // rmi.6C=Error occurred while unmarshalling arguments
        throw new ServerError(Messages.getString("rmi.6C"), er); //$NON-NLS-1$
    }
    return params;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:UnicastServerRef.java


示例4: invoke

import java.rmi.ServerError; //导入依赖的package包/类
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (method.getDeclaringClass() == Object.class) {
    return method.invoke(myRemote, args);
  }
  else {
    Method m = ourRemoteToLocalMap.get(Pair.<Class<?>, Class<?>>create(myRemote.getClass(), myClazz)).get(method);
    if (m == null) throw new NoSuchMethodError(method.getName() + " in " + myRemote.getClass());
    try {
      return handleRemoteResult(m.invoke(myRemote, args), method.getReturnType(), myLoader, false);
    }
    catch (InvocationTargetException e) {
      Throwable cause = e.getCause(); // root cause may go deeper than we need, so leave it like this
      if (cause instanceof ServerError) cause = ObjectUtils.chooseNotNull(cause.getCause(), cause);
      if (cause instanceof RuntimeException) throw cause;
      if (cause instanceof Error) throw cause;
      if (canThrow(cause, method)) throw cause;
      throw new RuntimeException(cause);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:RemoteUtil.java


示例5: invoke

import java.rmi.ServerError; //导入依赖的package包/类
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (method.getDeclaringClass() == Object.class) {
    return method.invoke(myRemote, args);
  }
  else {
    Method m = ourRemoteToLocalMap.get(Pair.<Class<?>, Class<?>>create(myRemote.getClass(), myClazz)).get(method);
    if (m == null) throw new NoSuchMethodError(method.getName() + " in " + myRemote.getClass());
    try {
      return handleRemoteResult(m.invoke(myRemote, args), method.getReturnType(), myLoader, false);
    }
    catch (InvocationTargetException e) {
      Throwable cause = e.getCause(); // root cause may go deeper than we need, so leave it like this
      if (cause instanceof ServerError) cause = ObjectUtil.chooseNotNull(cause.getCause(), cause);
      if (cause instanceof RuntimeException) throw cause;
      if (cause instanceof Error) throw cause;
      if (canThrow(cause, method)) throw cause;
      throw new RuntimeException(cause);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:RemoteUtil.java


示例6: checkDeserException

import java.rmi.ServerError; //导入依赖的package包/类
/*******************
 * Helper method which checks exceptions triggered by a deserialization
 * attacks and attempts to provide additional output to guide the user.
 * 
 * If a ServerException was caused by a ClassNotFoundException then we can
 * safely assume that the chosen gadget chain is not available on the
 * server.
 * 
 * If a ServerError was caused by an IOException which has "Cannot run
 * program" in the message then we can safely assume that the chosen gadget
 * chain is present, but the command wasn't available.
 * 
 * @param ex 
 ******************/
protected final void checkDeserException(Throwable t) {
	boolean responded = false;
	
	//Check for server-side ClassNotFoundException, indicating that the payload is no use
	if(t instanceof ServerException) {
		while(t.getCause() != null) {
			t = t.getCause();
			if(t instanceof ClassNotFoundException) {
				System.out.println("\n[-] The chosen deserialization payload is not available at the server side.");
				responded = true;
				break;
			}
		}
	}
	
	//Check for server-side IOException saying that the program could not be run, indicating a successful attack but unavailable target program
	if(t instanceof ServerError) {
		while(t.getCause() != null) {
			t = t.getCause();
			if(t instanceof IOException && t.getMessage().contains("Cannot run program")) {
				System.out.println("\n[+] The attack was successful, however the chosen command was not available.");
				responded = true;
				break;
			}
		}
	}
	
	//Print generic response if we can't work anything out from the exception
	if(responded == false) {
		System.out.println("\n[~] Attack completed but success could not be verified.");
	}
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:47,代码来源:RMIDeserAttack.java


示例7: testServerError

import java.rmi.ServerError; //导入依赖的package包/类
/**
 * {@link java.rmi.ServerError#ServerError(java.lang.String, java.lang.Error)}.
 */
public void testServerError() {
    Error t = new Error();
    ServerError e = new ServerError("fixture", t);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(t, e.getCause());
    assertSame(t, e.detail);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:ServerErrorTest.java


示例8: wrapException

import java.rmi.ServerError; //导入依赖的package包/类
/**
 * Converts the exception that was thrown by the implementation method on a
 * server side into RemoteException that can be transferred and re-thrown on a
 * client side. The method converts exceptions as defined in the following
 * table: <table border = "1">
 * <tr>
 * <th>Exception to map (or subclass)</th>
 * <th>Maps into</th>
 * </tr>
 * <tr>
 * <td>{@link Error}</td>
 * <td>{@link ServerError}</td>
 * </tr>
 * <tr>
 * <td>{@link RemoteException}</td>
 * <td>{@link ServerException}</td>
 * </tr>
 * <tr>
 * <td>{@link SystemException}</td>
 * <td>wrapException({@link #mapSystemException})</td>
 * </tr>
 * <tr>
 * <td>{@link RuntimeException}</td>
 * <td><b>rethrows</b></td>
 * </tr>
 * <tr>
 * <td>Any other exception</td>
 * <td>{@link UnexpectedException}</td>
 * </tr>
 * </table>
 *
 * @param ex an exception that was thrown on a server side implementation.
 *
 * @return the corresponding RemoteException unless it is a RuntimeException.
 *
 * @throws RuntimeException the passed exception if it is an instance of
 * RuntimeException.
 *
 * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0.
 */
public RemoteException wrapException(Throwable ex)
  throws RuntimeException
{
  if (ex instanceof RuntimeException)
    throw (RuntimeException) ex;
  else if (ex instanceof Error)
    return new ServerError(ex.getMessage(), (Error) ex);
  else if (ex instanceof RemoteException)
    return new ServerException(ex.getMessage(), (Exception) ex);
  else if (ex instanceof SystemException)
    return wrapException(mapSystemException((SystemException) ex));
  else
    return new UnexpectedException("Unexpected", (Exception) ex);
}
 
开发者ID:vilie,项目名称:javify,代码行数:55,代码来源:UtilDelegateImpl.java


示例9: wrapException

import java.rmi.ServerError; //导入依赖的package包/类
/**
 * Converts the exception that was thrown by the implementation method on a
 * server side into RemoteException that can be transferred and re-thrown on a
 * client side. The method converts exceptions as defined in the following
 * table: <table border = "1">
 * <tr>
 * <th>Exception to map (or subclass)</th>
 * <th>Maps into</th>
 * </tr>
 * <tr>
 * <td>{@link Error}</td>
 * <td>{@link ServerError}</td>
 * </tr>
 * <tr>
 * <td>{@link RemoteException}</td>
 * <td>{@link ServerException}</td>
 * </tr>
 * <tr>
 * <td>{@link SystemException}</td>
 * <td>wrapException({@link #mapSystemException})</td>
 * </tr>
 * <tr>
 * <td>{@link RuntimeException}</td>
 * <td><b>rethrows</b></td>
 * </tr>
 * <tr>
 * <td>Any other exception</td>
 * <td>{@link UnexpectedException}</td>
 * </tr>
 * </table>
 * 
 * @param ex an exception that was thrown on a server side implementation.
 * 
 * @return the corresponding RemoteException unless it is a RuntimeException.
 * 
 * @throws RuntimeException the passed exception if it is an instance of
 * RuntimeException.
 * 
 * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0.
 */
public RemoteException wrapException(Throwable ex)
  throws RuntimeException
{
  if (ex instanceof RuntimeException)
    throw (RuntimeException) ex;
  else if (ex instanceof Error)
    return new ServerError(ex.getMessage(), (Error) ex);
  else if (ex instanceof RemoteException)
    return new ServerException(ex.getMessage(), (Exception) ex);
  else if (ex instanceof SystemException)
    return wrapException(mapSystemException((SystemException) ex));
  else
    return new UnexpectedException("Unexpected", (Exception) ex);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:55,代码来源:UtilDelegateImpl.java



注:本文中的java.rmi.ServerError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConfigurationImpl类代码示例发布时间:2022-05-21
下一篇:
Java SAMLVersion类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap