Package ch.ethz.ssh2.crypto.digest

Examples of ch.ethz.ssh2.crypto.digest.MD5


    {
      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

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

    byte[] resp = receiveMessage(34000);

    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_HANDLE)
    {
      if (debug != null)
      {
        debug.println("Got SSH_FXP_HANDLE.");
        debug.flush();
      }

      byte[] handle = tr.readByteString();
      return handle;
    }

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

    int errorCode = tr.readUINT32();
    String errorMessage = tr.readString();

    throw new SFTPException(errorMessage, errorCode);
  }
View Full Code Here

    /* Receive SSH_FXP_VERSION */

    if (debug != null)
      debug.println("Waiting for SSH_FXP_VERSION...");

    TypesReader tr = new TypesReader(receiveMessage(34000)); /* Should be enough for any reasonable server */

    int type = tr.readByte();

    if (type != Packet.SSH_FXP_VERSION)
    {
      throw new IOException("The server did not send a SSH_FXP_VERSION packet (got " + type + ")");
    }

    protocol_version = tr.readUINT32();

    if (debug != null)
      debug.println("SSH_FXP_VERSION: protocol_version = " + protocol_version);

    if (protocol_version != 3)
      throw new IOException("Server version " + protocol_version + " is currently not supported");

    /* Read and save extensions (if any) for later use */

    while (tr.remain() != 0)
    {
      String name = tr.readString();
      byte[] value = tr.readByteString();
      server_extensions.put(name, value);

      if (debug != null)
        debug.println("SSH_FXP_VERSION: extension: " + name + " = '" + expandString(value, 0, value.length)
            + "'");
View Full Code Here

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

    byte[] resp = receiveMessage(34000);

    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_HANDLE)
    {
      if (debug != null)
      {
        debug.println("Got SSH_FXP_HANDLE.");
        debug.flush();
      }

      return new SFTPv3FileHandle(this, tr.readByteString());
    }

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

    int errorCode = tr.readUINT32();
    String errorMessage = tr.readString();

    throw new SFTPException(errorMessage, errorCode);
  }
View Full Code Here

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

    byte[] resp = receiveMessage(34000);

    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_DATA)
    {
      if (debug != null)
      {
        debug.println("Got SSH_FXP_DATA...");
        debug.flush();
      }

      int readLen = tr.readUINT32();

      if ((readLen < 0) || (readLen > len))
        throw new IOException("The server sent an invalid length field.");

      tr.readBytes(dst, dstoff, readLen);

      return readLen;
    }

    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)
    {
      if (debug != null)
      {
        debug.println("Got SSH_FX_EOF.");
        debug.flush();
      }

      return -1;
    }

    String errorMessage = tr.readString();

    throw new SFTPException(errorMessage, errorCode);
  }
View Full Code Here

        srcoff += writeRequestLen;
        len -= writeRequestLen;

        byte[] resp = receiveMessage(34000);

        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_STATUS)
          throw new IOException("The SFTP server sent an unexpected packet type (" + t + ")");

        int errorCode = tr.readUINT32();

        if (errorCode == ErrorCodes.SSH_FX_OK)
          continue;

        String errorMessage = tr.readString();

        throw new SFTPException(errorMessage, errorCode);
      }
  }
View Full Code Here

TOP

Related Classes of ch.ethz.ssh2.crypto.digest.MD5

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.