Package ch.ethz.ssh2.packets

Examples of ch.ethz.ssh2.packets.PacketKexInit


  private final void closeHandle(byte[] handle) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(handle, 0, handle.length);

    sendMessage(Packet.SSH_FXP_CLOSE, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here


  {
    checkHandleValidAndOpen(handle);

    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_FSTAT...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_FSTAT, req_id, tw.getBytes());

    byte[] resp = receiveMessage(34000);

    if (debug != null)
    {
View Full Code Here

  private SFTPv3FileAttributes statBoth(String path, int statMethod) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(path, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_STAT/SSH_FXP_LSTAT...");
      debug.flush();
    }

    sendMessage(statMethod, req_id, tw.getBytes());

    byte[] resp = receiveMessage(34000);

    if (debug != null)
    {
View Full Code Here

   */
  public String readLink(String path) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(path, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_READLINK...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_READLINK, req_id, tw.getBytes());

    byte[] resp = receiveMessage(34000);

    if (debug != null)
    {
View Full Code Here

   */
  public void setstat(String path, SFTPv3FileAttributes attr) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(path, charsetName);
    tw.writeBytes(createAttrs(attr));

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_SETSTAT...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_SETSTAT, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

  {
    checkHandleValidAndOpen(handle);

    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(handle.fileHandle, 0, handle.fileHandle.length);
    tw.writeBytes(createAttrs(attr));

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_FSETSTAT...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_FSETSTAT, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

    /* Either I am too stupid to understand the SFTP draft
     * or the OpenSSH guys changed the semantics of src and target.
     */

    TypesWriter tw = new TypesWriter();
    tw.writeString(target, charsetName);
    tw.writeString(src, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_SYMLINK...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_SYMLINK, req_id, tw.getBytes());

    expectStatusOKMessage(req_id);
  }
View Full Code Here

   */
  public String canonicalPath(String path) throws IOException
  {
    int req_id = generateNextRequestID();

    TypesWriter tw = new TypesWriter();
    tw.writeString(path, charsetName);

    if (debug != null)
    {
      debug.println("Sending SSH_FXP_REALPATH...");
      debug.flush();
    }

    sendMessage(Packet.SSH_FXP_REALPATH, req_id, tw.getBytes());

    byte[] resp = receiveMessage(34000);

    if (debug != null)
    {
View Full Code Here

    if (kxs == null)
    {
      kxs = new KexState();

      kxs.dhgexParameters = nextKEXdhgexParameters;
      PacketKexInit kp = new PacketKexInit(nextKEXcryptoWishList, rnd);
      kxs.localKEX = kp;
      tm.sendKexMessage(kp.getPayload());
    }
  }
View Full Code Here

    throw new IOException("Unknown server host key algorithm '" + kxs.np.server_host_key_algo + "'");
  }

  public synchronized void handleMessage(byte[] msg, int msglen) throws IOException
  {
    PacketKexInit kip;

    if (msg == null)
    {
      synchronized (accessLock)
      {
        connectionClosed = true;
        accessLock.notifyAll();
        return;
      }
    }

    if ((kxs == null) && (msg[0] != Packets.SSH_MSG_KEXINIT))
      throw new IOException("Unexpected KEX message (type " + msg[0] + ")");

    if (ignore_next_kex_packet)
    {
      ignore_next_kex_packet = false;
      return;
    }

    if (msg[0] == Packets.SSH_MSG_KEXINIT)
    {
      if ((kxs != null) && (kxs.state != 0))
        throw new IOException("Unexpected SSH_MSG_KEXINIT message during on-going kex exchange!");

      if (kxs == null)
      {
        /*
         * Ah, OK, peer wants to do KEX. Let's be nice and play
         * together.
         */
        kxs = new KexState();
        kxs.dhgexParameters = nextKEXdhgexParameters;
        kip = new PacketKexInit(nextKEXcryptoWishList, rnd);
        kxs.localKEX = kip;
        tm.sendKexMessage(kip.getPayload());
      }

      kip = new PacketKexInit(msg, 0, msglen);
      kxs.remoteKEX = kip;

      kxs.np = mergeKexParameters(kxs.localKEX.getKexParameters(), kxs.remoteKEX.getKexParameters());

      if (kxs.np == null)
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.packets.PacketKexInit

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.