Example #1
0
  /**
   * Starts SSL FTP server
   *
   * @throws Exception
   */
  public static void startSSLServer() throws Exception {

    log.info(
        "Starting Hdfs-Over-Ftp SSL server. ssl-port: "
            + sslPort
            + " ssl-data-ports: "
            + sslPassivePorts
            + " hdfs-uri: "
            + hdfsUri);

    HdfsOverFtpSystem.setHDFS_URI(hdfsUri);

    DataConnectionConfigurationFactory Dccf = new DataConnectionConfigurationFactory();
    Dccf.setPassivePorts(sslPassivePorts);
    DataConnectionConfiguration dataCon = Dccf.createDataConnectionConfiguration();

    MySslConfiguration ssl = new MySslConfiguration();
    ssl.setKeystoreFile(new File("ftp.jks"));
    ssl.setKeystoreType("JKS");
    ssl.setKeyPassword("333333");

    ListenerFactory lf = new ListenerFactory();
    lf.setDataConnectionConfiguration(dataCon);
    lf.setPort(sslPort);
    lf.setImplicitSsl(true);
    lf.setSslConfiguration(ssl);

    FtpServerFactory fsf = new FtpServerFactory();
    fsf.addListener("default", lf.createListener());

    // TODO 搞清楚HdfsUserManager的两个null参数应该改成什么。
    HdfsUserManager userManager = new HdfsUserManager(null, null);
    final File file = loadResource("/users.properties");
    // 	userManager.setFile(new File("users.conf"));
    userManager.setFile(file);

    fsf.setUserManager(userManager);
    fsf.setFileSystem(new HdfsFileSystemManager());

    FtpServer server = fsf.createServer();

    server.start();
  }
Example #2
0
  /**
   * Starts FTP server
   *
   * @throws Exception
   */
  public static void startServer() throws Exception {

    log.info(
        "Starting Hdfs-Over-Ftp server. port: "
            + port
            + " data-ports: "
            + passivePorts
            + " hdfs-uri: "
            + hdfsUri);

    HdfsOverFtpSystem.setHDFS_URI(hdfsUri);

    DataConnectionConfigurationFactory dccf = new DataConnectionConfigurationFactory();
    dccf.setPassivePorts(passivePorts);

    ListenerFactory lf = new ListenerFactory();
    lf.setDataConnectionConfiguration(dccf.createDataConnectionConfiguration());
    lf.setPort(port);
    HashMap<String, Listener> lmap = new HashMap<String, Listener>();
    lmap.put("2222", lf.createListener());

    FtpServerFactory fsf = new FtpServerFactory();
    fsf.addListener("2222", lf.createListener());
    // fsf.setListeners(lmap);

    // TODO 搞清楚HdfsUserManager的两个null参数应该改成什么。
    HdfsUserManager userManager = new HdfsUserManager(null, null);
    final File file = loadResource("/users.properties");
    userManager.setFile(file);

    fsf.setUserManager(userManager);
    fsf.setFileSystem(new HdfsFileSystemManager());

    FtpServer server = fsf.createServer();

    server.start();
  }