Package org.xulfactory.gliese.message

Examples of org.xulfactory.gliese.message.SSHMessage


  }

  public SSHMessage readMessage(String namespace, int... ids)
    throws SSHException
  {
    SSHMessage m = readMessage(namespace);
    for (int id: ids) {
      if (id == m.getID()) {
        return m;
      }
    }
    throw new SSHException("Unexpected message type: " + m.getID());
  }
View Full Code Here


   * @return the message
   * @throws SSHException if an error occurred
   */
  public SSHMessage readMessage(String namespace) throws SSHException
  {
    SSHMessage m;
    do {
      try {
        m = factory.readMessage(namespace);
      } catch (SSHException se) {
        close();
        throw se;
      }
      if (m.getID() == DisconnectMessage.ID) {
        DisconnectMessage msg = (DisconnectMessage)m;
        GlieseLogger.LOGGER.info("Disconnect message received: " + msg);
        close();
        throw new SSHException(String.format(
          "%s (reason code=%d)", msg.getMessage(),
          msg.getReasonCode()));
      } else if (m.getID() == DebugMessage.ID) {
        DebugMessage msg = (DebugMessage)m;
        if (msg.isAlwaysDisplay()) {
          GlieseLogger.LOGGER.info("Debug message: " + msg.getMessage());
        } else {
          GlieseLogger.LOGGER.debug("Debug message: " + msg.getMessage());
View Full Code Here

  private AuthenticationResult sendAuthentication(AuthenticationDialog cb)
    throws SSHException
  {
    AuthenticationResult result = null;
    SSHMessage msg = null;
    while (result == null) {
      transport.writeMessage(cb.interact(msg));
      msg = transport.readMessage(cb.getMethod()); //FIXME
      switch (msg.getID()) {
      case UserAuthBannerMessage.ID:
        String message = ((UserAuthBannerMessage)msg).getMessage();
        System.out.println(message);
        break;
      case UserAuthFailureMessage.ID:
        result = generateFailure((UserAuthFailureMessage)msg);
        break;
      case UserAuthSuccessMessage.ID:
        result = AuthenticationResult.success();
        authenticated = true;
        break;
      default:
        if (msg.getID() < 60 || msg.getID() > 69) {
          GlieseLogger.LOGGER.error(String.format("Unexpected server message with ID=%d", msg.getID()));
          throw new SSHException("Unexpected server message");
        }
      }
    }
    return result;
View Full Code Here

  }

  public void channelLoop() throws SSHException
  {
    SSHChannel chann = null;
    SSHMessage msg = transport.readMessage();
    switch (msg.getID()) {
    case ChannelSuccessMessage.ID:
      ChannelSuccessMessage m5 = (ChannelSuccessMessage)msg;
      chann = locals.get(m5.getChannelId());
      synchronized (chann.LOCK) {
        chann.lastReqSuccess = true;
        chann.LOCK.notify();
      }
      break;
    case ChannelFailureMessage.ID:
      ChannelFailureMessage m6 = (ChannelFailureMessage)msg;
      chann = locals.get(m6.getChannelId());
      synchronized (chann.LOCK) {
        chann.lastReqSuccess = false;
        chann.LOCK.notify();
      }
      break;
    case ChannelRequestMessage.ID:
      ChannelRequestMessage m0 = (ChannelRequestMessage)msg;
      chann = locals.get(m0.getChannelId());
      chann.handleRequest(m0.getRequest(), m0.getWantReply());
      break;
    case ChannelWindowsAdjustMessage.ID:
      ChannelWindowsAdjustMessage m7
        = (ChannelWindowsAdjustMessage)msg;
      chann = locals.get(m7.getChannelId());
      chann.adjustRemoteWindow(m7.getBytesToAdd());
      break;
    case ChannelEOFMessage.ID:
      ChannelEOFMessage m2 = (ChannelEOFMessage)msg;
      chann = locals.get(m2.getChannelId());
      chann.eof();
      break;
    case ChannelDataMessage.ID:
      ChannelDataMessage m1 = (ChannelDataMessage)msg;
      chann = locals.get(m1.getChannelId());
      chann.pushData(m1.getData());
      break;
    case ChannelExtendedDataMessage.ID:
      ChannelExtendedDataMessage m3 =
        (ChannelExtendedDataMessage)msg;
      chann = locals.get(m3.getChannelId());
      chann.pushExtendedData(m3.getData(), m3.getDataType());
      break;
    case ChannelOpenConfirmationMessage.ID:
      try {
        queue.put(msg);
      } catch (InterruptedException ex) {
        ex.printStackTrace();
      }
      break;
    case ChannelCloseMessage.ID:
      ChannelCloseMessage m4 = (ChannelCloseMessage)msg;
      chann = locals.get(m4.getChannelId());
      chann.peerClose();
      break;
    default:
      GlieseLogger.LOGGER.error(String.format(
        "Unexpected message type: %d", msg.getID()));
    }
  }
View Full Code Here

    } else {
      GlieseLogger.LOGGER.warn("Unsupported channel request: "
        + request.getRequestType());
    }
    if (wantReply) {
      SSHMessage msg;
      if (success) {
        msg = new ChannelSuccessMessage(remoteId);
      } else {
        msg = new ChannelFailureMessage(remoteId);
      }
View Full Code Here

TOP

Related Classes of org.xulfactory.gliese.message.SSHMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.