Пример #1
0
  @Override
  public void cmdExecute(Message msg, ServerConnection servConn, long start) throws IOException {
    // requiresResponse = true; NOT NEEDED... ALWAYS SEND ERROR RESPONSE

    logger.fatal(
        LocalizedMessage.create(
            LocalizedStrings.Default_0_UNKNOWN_MESSAGE_TYPE_1_WITH_TX_2_FROM_3,
            new Object[] {
              servConn.getName(),
              MessageType.getString(msg.getMessageType()),
              Integer.valueOf(msg.getTransactionId()),
              servConn.getSocketString()
            }));
    writeErrorResponse(msg, MessageType.UNKNOWN_MESSAGE_TYPE_ERROR, servConn);
    // responded = true; NOT NEEDED... ALWAYS SEND ERROR RESPONSE
  }
 protected Object processResponse(Connection cnx, Message msg) throws Exception {
   byte[] bytes = null;
   Part part = msg.getPart(0);
   final int msgType = msg.getMessageType();
   long userId = -1;
   if (msgType == MessageType.RESPONSE) {
     bytes = (byte[]) part.getObject();
     if (bytes.length == 0) {
       cnx.getServer().setRequiresCredentials(false);
     } else {
       cnx.getServer().setRequiresCredentials(true);
       byte[] decrypted = ((ConnectionImpl) cnx).getHandShake().decryptBytes(bytes);
       DataInputStream dis = new DataInputStream(new ByteArrayInputStream(decrypted));
       userId = dis.readLong();
     }
     if (this.needsServerLocation) {
       return new Object[] {cnx.getServer(), userId};
     } else {
       return userId;
     }
   } else if (msgType == MessageType.EXCEPTION) {
     Object result = part.getObject();
     String s = "While performing a remote authenticate";
     if (result instanceof AuthenticationFailedException) {
       final AuthenticationFailedException afe = (AuthenticationFailedException) result;
       if ("REPLY_REFUSED".equals(afe.getMessage())) {
         throw new AuthenticationFailedException(s, afe.getCause());
       } else {
         throw new AuthenticationFailedException(s, afe);
       }
     } else if (result instanceof AuthenticationRequiredException) {
       throw new AuthenticationRequiredException(s, (AuthenticationRequiredException) result);
     } else if (result instanceof NotAuthorizedException) {
       throw new NotAuthorizedException(s, (NotAuthorizedException) result);
     } else {
       throw new ServerOperationException(s, (Throwable) result);
     }
     // Get the exception toString part.
     // This was added for c++ thin client and not used in java
     // Part exceptionToStringPart = msg.getPart(1);
   } else if (isErrorResponse(msgType)) {
     throw new ServerOperationException(part.getString());
   } else {
     throw new InternalGemFireError("Unexpected message type " + MessageType.getString(msgType));
   }
 }