Package it.sauronsoftware.ftp4j

Examples of it.sauronsoftware.ftp4j.FTPReply


      throws IOException {
    Socket socket = new Socket(proxyHost, proxyPort);
    FTPCommunicationChannel communication = new FTPCommunicationChannel(
        socket, "ASCII");
    // Welcome message.
    FTPReply r;
    try {
      r = communication.readFTPReply();
    } catch (FTPIllegalReplyException e) {
      throw new IOException("Invalid proxy response");
    }
    // Does this reply mean "ok"?
    if (r.getCode() != 220) {
      // Mmmmm... it seems no!
      throw new IOException("Invalid proxy response");
    }
    if (style == STYLE_SITE_COMMAND) {
      // Usefull flags.
      boolean passwordRequired;
      // Send the user and read the reply.
      communication.sendFTPCommand("USER " + proxyUser);
      try {
        r = communication.readFTPReply();
      } catch (FTPIllegalReplyException e) {
        throw new IOException("Invalid proxy response");
      }
      switch (r.getCode()) {
      case 230:
        // Password isn't required.
        passwordRequired = false;
        break;
      case 331:
        // Password is required.
        passwordRequired = true;
        break;
      default:
        // User validation failed.
        throw new IOException("Proxy authentication failed");
      }
      // Password.
      if (passwordRequired) {
        // Send the password.
        communication.sendFTPCommand("PASS " + proxyPass);
        try {
          r = communication.readFTPReply();
        } catch (FTPIllegalReplyException e) {
          throw new IOException("Invalid proxy response");
        }
        if (r.getCode() != 230) {
          // Authentication failed.
          throw new IOException("Proxy authentication failed");
        }
      }
      communication.sendFTPCommand("SITE " + host + ":" + port);
View Full Code Here


      throws IOException {
    Socket socket = new Socket(proxyHost, proxyPort);
    FTPCommunicationChannel communication = new FTPCommunicationChannel(
        socket, "ASCII");
    // Welcome message.
    FTPReply r;
    try {
      r = communication.readFTPReply();
    } catch (FTPIllegalReplyException e) {
      throw new IOException("Invalid proxy response");
    }
    // Does this reply mean "ok"?
    if (r.getCode() != 220) {
      // Mmmmm... it seems no!
      throw new IOException("Invalid proxy response");
    }
    if (style == STYLE_SITE_COMMAND) {
      // Usefull flags.
      boolean passwordRequired;
      // Send the user and read the reply.
      communication.sendFTPCommand("USER " + proxyUser);
      try {
        r = communication.readFTPReply();
      } catch (FTPIllegalReplyException e) {
        throw new IOException("Invalid proxy response");
      }
      switch (r.getCode()) {
      case 230:
        // Password isn't required.
        passwordRequired = false;
        break;
      case 331:
        // Password is required.
        passwordRequired = true;
        break;
      default:
        // User validation failed.
        throw new IOException("Proxy authentication failed");
      }
      // Password.
      if (passwordRequired) {
        // Send the password.
        communication.sendFTPCommand("PASS " + proxyPass);
        try {
          r = communication.readFTPReply();
        } catch (FTPIllegalReplyException e) {
          throw new IOException("Invalid proxy response");
        }
        if (r.getCode() != 230) {
          // Authentication failed.
          throw new IOException("Proxy authentication failed");
        }
      }
      communication.sendFTPCommand("SITE " + host + ":" + port);
View Full Code Here

TOP

Related Classes of it.sauronsoftware.ftp4j.FTPReply

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.