当前位置: 首页>>代码示例>>Java>>正文


Java ServerException类代码示例

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


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

示例1: wrapException

import java.rmi.ServerException; //导入依赖的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: executeFunction

import java.rmi.ServerException; //导入依赖的package包/类
public static void executeFunction() throws ServerException, InterruptedException {

    Region region = cache.getRegion(PartitionedRegionName);
    assertNotNull(region);
    final HashSet testKeysSet = new HashSet();
    for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
      testKeysSet.add("execKey-" + i);
    }
    DistributedSystem.setThreadsSocketPolicy(false);
    Function function = new TestFunction(true, TEST_FUNCTION2);
    FunctionService.registerFunction(function);
    Execution dataSet = FunctionService.onRegion(region);
    try {
      ResultCollector rc1 =
          dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(function.getId());
      List l = ((List) rc1.getResult());
      LogWriterUtils.getLogWriter().info("Result size : " + l.size());
      assertEquals(3, l.size());

      for (Iterator i = l.iterator(); i.hasNext();) {
        assertEquals(Boolean.TRUE, i.next());
      }
    } catch (CacheClosedException e) {
      // okay - ignore
    }
  }
 
开发者ID:ampool,项目名称:monarch,代码行数:27,代码来源:PRClientServerRegionFunctionExecutionDUnitTest.java

示例3: put

import java.rmi.ServerException; //导入依赖的package包/类
@Override
public final int put(final List<O> tasks, final int from, final int to)
throws EOFException, ServerException {
	if(!isStarted()) {
		throw new EOFException();
	}
	int i = from;
	O nextTask;
	while(i < to && isStarted()) {
		nextTask = tasks.get(i);
		prepareIoTask(nextTask);
		if(inTasksQueue.offer(tasks.get(i))) {
			i ++;
		} else {
			break;
		}
	}
	final int n = i - from;
	scheduledTaskCount.add(n);
	return n;
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:22,代码来源:StorageDriverBase.java

示例4: prepareIoTask

import java.rmi.ServerException; //导入依赖的package包/类
protected void prepareIoTask(final O ioTask)
throws ServerException {
	ioTask.reset();
	if(ioTask instanceof DataIoTask) {
		((DataIoTask) ioTask).getItem().setDataInput(itemDataInput);
	}
	final String dstPath = ioTask.getDstPath();
	final Credential credential = ioTask.getCredential();
	if(credential != null) {
		pathToCredMap.putIfAbsent(dstPath == null ? "" : dstPath, credential);
		if(requestAuthTokenFunc != null) {
			authTokens.computeIfAbsent(credential, requestAuthTokenFunc);
		}
	}
	if(requestNewPathFunc != null) {
		// NOTE: in the distributed mode null dstPath becomes empty one
		if(dstPath != null && !dstPath.isEmpty()) {
			if(null == pathMap.computeIfAbsent(dstPath, requestNewPathFunc)) {
				Loggers.ERR.debug(
					"Failed to compute the destination path for the I/O task {}", ioTask
				);
				ioTask.setStatus(IoTask.Status.FAIL_UNKNOWN);
			}
		}
	}
}
 
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:27,代码来源:StorageDriverBase.java

示例5: readParams

import java.rmi.ServerException; //导入依赖的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

示例6: listVolumesOnFiler

import java.rmi.ServerException; //导入依赖的package包/类
/**
 * This method lists all the volumes by pool name
 * @param poolName
 * @return -- volumes in that pool
 */
@Override
public List<NetappVolumeVO> listVolumesOnFiler(String poolName) {

    List<NetappVolumeVO> vols = _volumeDao.listVolumesAscending(poolName);

    for (NetappVolumeVO vol : vols) {
        try {
            String snapScheduleOnFiler = returnSnapshotSchedule(vol);
            vol.setSnapshotPolicy(snapScheduleOnFiler);

        } catch (ServerException e) {
            s_logger.warn("Error trying to get snapshot schedule for volume" + vol.getVolumeName());
        }
    }
    return vols;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:22,代码来源:NetappManagerImpl.java

示例7: canAttackEndpoint

import java.rmi.ServerException; //导入依赖的package包/类
/*******************
 * Check if the given endpoint can be attacked.
 * 
 * This check is performed by executing a dummy attack against the
 * endpoint and observing the resulting exception.
 * 
 * @param ep An enumerated RMI endpoint.
 * @return True if we can attack it.
 ******************/
public boolean canAttackEndpoint(RMIEndpoint ep) {
	RMIBindExploitProxy proxy = null;
	Registry reg;
	
	//Execute a dummy attack
	try {
		//Start a bind exploit proxy
		proxy = new RMIBindExploitProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options, this._dummyPayload);
		proxy.startProxy();
		
		//Get a proxied RMI registry reference
		reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());
		
		//Bind a dummy object in an attempt to trigger the vulnerability
		reg.bind(this.generateRandomString(), new BaRMIeBindExploit());
	} catch(BaRMIeException | UnknownHostException | RemoteException | AlreadyBoundException ex) {
		//An up to date RMI registry will, by default, reject the dummy object
		if(ex instanceof ServerException && ex.getCause() != null && ex.getCause() instanceof UnmarshalException && ex.getCause().getCause() != null && ex.getCause().getCause() instanceof InvalidClassException) {
			//Check for "filter status: REJECTED"
			if(ex.getCause().getCause().toString().contains("filter status: REJECTED")) {
				//Test payload was filtered, likely this attack isn't possible
				return false;
			}
		}
	} finally {
		//Stop the proxy
		if(proxy != null) {
			proxy.stopProxy(true);
		}
	}
	
	//In all other cases we should be able to attack the registry
	return true;
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:44,代码来源:IllegalRegistryBind.java

示例8: checkDeserException

import java.rmi.ServerException; //导入依赖的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

示例9: getBuildService

import java.rmi.ServerException; //导入依赖的package包/类
/**
 * Helper method to return build service.
 *
 * @param buildID
 * @return return build service.
 */
private BuildService getBuildService(final int buildID) throws ServerException {
  final BuildListService buildListService = ServiceManager.getInstance().getBuildListService();
  final BuildService build = buildListService.getBuild(buildID);
  if (build == null) {
    throw new ServerException("Requested build ID \"" + buildID + "\" not found.");
  }
  return build;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:ParabuildSoapBindingImpl.java

示例10: newSQLException

import java.rmi.ServerException; //导入依赖的package包/类
public static SQLException newSQLException(GFXDException gfxde) {
  GFXDExceptionData payload = gfxde.getExceptionData();
  SQLException sqle = newSQLException(payload, gfxde.getCause(),
      gfxde.getServerInfo());
  // since GFXDException is always a wrapper, no need to record the stack
  sqle.setStackTrace(gfxde.getStackTrace());
  // build next exceptions
  List<GFXDExceptionData> nextList = gfxde.getNextExceptions();
  SQLException current = sqle, next;
  if (nextList != null) {
    for (GFXDExceptionData nextData : nextList) {
      // check for server stack indicator
      if (SQLState.GFXD_SERVER_STACK_INDICATOR.equals(
          nextData.getSqlState())) {
        Throwable cause = sqle;
        while (cause.getCause() != null) {
          cause = cause.getCause();
        }
        cause.initCause(new ServerException(nextData.getReason()));
      }
      else {
        next = newSQLException(nextData, null, null);
        current.setNextException(next);
        current = next;
      }
    }
  }
  return sqle;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:30,代码来源:ThriftExceptionUtil.java

示例11: executeFunction

import java.rmi.ServerException; //导入依赖的package包/类
public static void executeFunction() throws ServerException,
    InterruptedException {

  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final HashSet testKeysSet = new HashSet();
  for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
    testKeysSet.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  Function function = new TestFunction(true,TEST_FUNCTION2);
  FunctionService.registerFunction(function);
  Execution dataSet = FunctionService.onRegion(region);
  try {
    ResultCollector rc1 = dataSet.withFilter(testKeysSet).withArgs(Boolean.TRUE).execute(
        function.getId());
    List l = ((List)rc1.getResult());
    getLogWriter().info("Result size : " + l.size());
    assertEquals(3, l.size());

    for (Iterator i = l.iterator(); i.hasNext();) {
      assertEquals(Boolean.TRUE, i.next());
    }
  }
  catch (Exception e) {
    getLogWriter().info("Got an exception : " + e.getMessage());
    assertTrue(e instanceof EOFException || e instanceof SocketException
        || e instanceof SocketTimeoutException
        || e instanceof ServerException || e instanceof IOException
        || e instanceof CacheClosedException);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:33,代码来源:PRClientServerRegionFunctionExecutionDUnitTest.java

示例12: postConstruct

import java.rmi.ServerException; //导入依赖的package包/类
@PostConstruct
private void postConstruct() throws ServerException {
    try {
        migrationShardTblDao = ContainerLoader.getDefaultContainer().lookup(MigrationShardTblDao.class);
    } catch (ComponentLookupException e) {
        throw new ServerException("Cannot construct dao.");
    }
}
 
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:9,代码来源:MigrationServiceImpl.java

示例13: sendNotification

import java.rmi.ServerException; //导入依赖的package包/类
public void sendNotification(String userName, String userEmail, boolean withPassword)
    throws IOException, ApiException {
  final URL urlEndpoint = new URL(apiEndpoint);
  final String masterEndpoint = urlEndpoint.getProtocol() + "://" + urlEndpoint.getHost();
  final Template template =
      withPassword
          ? templateWithPassword(masterEndpoint, userEmail, userName)
          : templateWithoutPassword(masterEndpoint, userName);
  final EmailBean emailBean =
      new EmailBean()
          .withBody(doProcessTemplate(template))
          .withFrom(mailFrom)
          .withTo(userEmail)
          .withReplyTo(null)
          .withMimeType(TEXT_HTML);
  if (withPassword) {
    emailBean.setSubject(accountCreatedWithPasswordMailSubject);
  } else {
    emailBean.setSubject(accountCreatedWithoutPasswordMailSubject);
  }

  try {
    mailSender.sendMail(resourceResolver.resolve(emailBean));
  } catch (SendMailException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:28,代码来源:CreationNotificationSender.java

示例14: doProcessTemplate

import java.rmi.ServerException; //导入依赖的package包/类
private String doProcessTemplate(Template template) throws ServerException {
  try {
    return templateProcessor.process(template);
  } catch (TemplateException e) {
    throw new ServerException(e.getMessage(), e);
  }
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:8,代码来源:CreationNotificationSender.java

示例15: testServerExceptionStringException

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


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