Package ch.ethz.ssh2

Examples of ch.ethz.ssh2.StreamGobbler


            "Authentication method keyboard-interactive not supported by the server at this stage.");

      if (submethods == null)
        submethods = new String[0];

      PacketUserauthRequestInteractive ua = new PacketUserauthRequestInteractive("ssh-connection", user,
          submethods);

      tm.sendMessage(ua.getPayload());

      while (true)
      {
        byte[] ar = getNextMessage();
View Full Code Here


      tm.registerMessageHandler(this, 0, 255);

      PacketServiceRequest sr = new PacketServiceRequest("ssh-userauth");
      tm.sendMessage(sr.getPayload());

      PacketUserauthRequestNone urn = new PacketUserauthRequestNone("ssh-connection", user);
      tm.sendMessage(urn.getPayload());

      byte[] msg = getNextMessage();
      new PacketServiceAccept(msg, 0, msg.length);
      msg = getNextMessage();
View Full Code Here

  public void msgChannelOpenFailure(byte[] msg, int msglen) throws IOException
  {
    if (msglen < 5)
      throw new IOException("SSH_MSG_CHANNEL_OPEN_FAILURE message has wrong size (" + msglen + ")");

    TypesReader tr = new TypesReader(msg, 0, msglen);

    tr.readByte(); // skip packet type
    int id = tr.readUINT32(); /* sender channel */

    Channel c = getChannel(id);

    if (c == null)
      throw new IOException("Unexpected SSH_MSG_CHANNEL_OPEN_FAILURE message for non-existent channel " + id);

    int reasonCode = tr.readUINT32();
    String description = tr.readString("UTF-8");

    String reasonCodeSymbolicName = null;

    switch (reasonCode)
    {
View Full Code Here

  public void msgGlobalRequest(byte[] msg, int msglen) throws IOException
  {
    /* Currently we do not support any kind of global request */

    TypesReader tr = new TypesReader(msg, 0, msglen);

    tr.readByte(); // skip packet type
    String requestName = tr.readString();
    boolean wantReply = tr.readBoolean();

    if (wantReply)
    {
      byte[] reply_failure = new byte[1];
      reply_failure[0] = Packets.SSH_MSG_REQUEST_FAILURE;
View Full Code Here

    {
      debug.println("Got REPLY.");
      debug.flush();
    }

    TypesReader tr = new TypesReader(resp);

    int t = tr.readByte();

    int rep_id = tr.readUINT32();
    if (rep_id != req_id)
      throw new IOException("The server sent an invalid id field.");

    if (t == Packet.SSH_FXP_ATTRS)
    {
      return readAttrs(tr);
    }

    if (t != Packet.SSH_FXP_STATUS)
      throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

    int errorCode = tr.readUINT32();

    throw new SFTPException(tr.readString(), errorCode);
  }
View Full Code Here

    {
      debug.println("Got REPLY.");
      debug.flush();
    }

    TypesReader tr = new TypesReader(resp);

    int t = tr.readByte();

    int rep_id = tr.readUINT32();
    if (rep_id != req_id)
      throw new IOException("The server sent an invalid id field.");

    if (t == Packet.SSH_FXP_ATTRS)
    {
      return readAttrs(tr);
    }

    if (t != Packet.SSH_FXP_STATUS)
      throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

    int errorCode = tr.readUINT32();

    throw new SFTPException(tr.readString(), errorCode);
  }
View Full Code Here

    {
      debug.println("Got REPLY.");
      debug.flush();
    }

    TypesReader tr = new TypesReader(resp);

    int t = tr.readByte();

    int rep_id = tr.readUINT32();
    if (rep_id != req_id)
      throw new IOException("The server sent an invalid id field.");

    if (t == Packet.SSH_FXP_NAME)
    {
      int count = tr.readUINT32();

      if (count != 1)
        throw new IOException("The server sent an invalid SSH_FXP_NAME packet.");

      return tr.readString(charsetName);
    }

    if (t != Packet.SSH_FXP_STATUS)
      throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

    int errorCode = tr.readUINT32();

    throw new SFTPException(tr.readString(), errorCode);
  }
View Full Code Here

    {
      debug.println("Got REPLY.");
      debug.flush();
    }

    TypesReader tr = new TypesReader(resp);

    int t = tr.readByte();

    int rep_id = tr.readUINT32();
    if (rep_id != id)
      throw new IOException("The server sent an invalid id field.");

    if (t != Packet.SSH_FXP_STATUS)
      throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

    int errorCode = tr.readUINT32();

    if (errorCode == ErrorCodes.SSH_FX_OK)
      return;

    throw new SFTPException(tr.readString(), errorCode);
  }
View Full Code Here

    {
      debug.println("Got REPLY.");
      debug.flush();
    }

    TypesReader tr = new TypesReader(resp);

    int t = tr.readByte();

    int rep_id = tr.readUINT32();
    if (rep_id != req_id)
      throw new IOException("The server sent an invalid id field.");

    if (t == Packet.SSH_FXP_NAME)
    {
      int count = tr.readUINT32();

      if (count != 1)
        throw new IOException("The server sent an invalid SSH_FXP_NAME packet.");

      return tr.readString(charsetName);
    }

    if (t != Packet.SSH_FXP_STATUS)
      throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

    int errorCode = tr.readUINT32();

    throw new SFTPException(tr.readString(), errorCode);
  }
View Full Code Here

      {
        debug.println("Got REPLY.");
        debug.flush();
      }

      TypesReader tr = new TypesReader(resp);

      int t = tr.readByte();

      int rep_id = tr.readUINT32();
      if (rep_id != req_id)
        throw new IOException("The server sent an invalid id field.");

      if (t == Packet.SSH_FXP_NAME)
      {
        int count = tr.readUINT32();

        if (debug != null)
          debug.println("Parsing " + count + " name entries...");

        while (count > 0)
        {
          SFTPv3DirectoryEntry dirEnt = new SFTPv3DirectoryEntry();

          dirEnt.filename = tr.readString(charsetName);
          dirEnt.longEntry = tr.readString(charsetName);

          dirEnt.attributes = readAttrs(tr);
          files.addElement(dirEnt);

          if (debug != null)
            debug.println("File: '" + dirEnt.filename + "'");
          count--;
        }
        continue;
      }

      if (t != Packet.SSH_FXP_STATUS)
        throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

      int errorCode = tr.readUINT32();

      if (errorCode == ErrorCodes.SSH_FX_EOF)
        return files;

      throw new SFTPException(tr.readString(), errorCode);
    }
  }
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.StreamGobbler

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.