From ff681158aabc2e018220c9b376b8a5aaa12a422a Mon Sep 17 00:00:00 2001 From: kaloyane <kaloyane> Date: Mon, 23 May 2011 10:26:11 +0000 Subject: [PATCH] minor: added the possibility to configure FTP active port. this could help avoiding firewall issues for phosphonetx SVN: 21424 --- .../dss/generic/server/ftp/FtpServer.java | 10 ++++++++ .../generic/server/ftp/FtpServerConfig.java | 25 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java index 053780f7ebc..2fc887d48b8 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.dss.generic.server.ftp; import java.util.Properties; import org.apache.ftpserver.ConnectionConfigFactory; +import org.apache.ftpserver.DataConnectionConfigurationFactory; import org.apache.ftpserver.FtpServerFactory; import org.apache.ftpserver.ftplet.FileSystemFactory; import org.apache.ftpserver.ftplet.FileSystemView; @@ -83,6 +84,15 @@ public class FtpServer implements FileSystemFactory factory.setSslConfiguration(sslConfigFactory.createSslConfiguration()); factory.setImplicitSsl(true); } + + if (config.isActiveModeEnabled()) + { + DataConnectionConfigurationFactory dccFactory = + new DataConnectionConfigurationFactory(); + dccFactory.setActiveEnabled(true); + dccFactory.setActiveLocalPort(config.getActiveLocalPort()); + factory.setDataConnectionConfiguration(dccFactory.createDataConnectionConfiguration()); + } serverFactory.addListener("default", factory.createListener()); ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory(); diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java index d94591cff99..dd6ab4a9ec7 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java @@ -55,8 +55,14 @@ public class FtpServerConfig final static String DATASET_FILELIST_FILTER_KEY = PREFIX + "dataset.filelist.filter."; + final static String ACTIVE_MODE_ENABLE_KEY = PREFIX + "activemode.enable"; + + final static String ACTIVE_PORT_KEY = PREFIX + "activemode.port"; + private static final int DEFAULT_PORT = 2121; + private static final int DEFAULT_ACTIVE_PORT = 2122; + private static final boolean DEFAULT_USE_SSL = true; private static final int DEFAULT_MAX_THREADS = 25; @@ -67,6 +73,10 @@ public class FtpServerConfig private int port; + private boolean activeModeEnabled; + + private int activePort; + private boolean useSSL; private File keyStore; @@ -95,12 +105,14 @@ public class FtpServerConfig private void initializeProperties(Properties props) { - this.port = PropertyUtils.getPosInt(props, PORT_KEY, DEFAULT_PORT); - this.useSSL = PropertyUtils.getBoolean(props, USE_SSL_KEY, DEFAULT_USE_SSL); + port = PropertyUtils.getPosInt(props, PORT_KEY, DEFAULT_PORT); + useSSL = PropertyUtils.getBoolean(props, USE_SSL_KEY, DEFAULT_USE_SSL); if (useSSL) { initializeSSLProperties(props); } + activeModeEnabled = PropertyUtils.getBoolean(props, ACTIVE_MODE_ENABLE_KEY, false); + activePort = PropertyUtils.getPosInt(props, ACTIVE_PORT_KEY, DEFAULT_ACTIVE_PORT); maxThreads = PropertyUtils.getPosInt(props, MAX_THREADS_KEY, DEFAULT_MAX_THREADS); dataSetDisplayTemplate = PropertyUtils.getProperty(props, DATASET_DISPLAY_TEMPLATE_KEY, DEFAULT_DATASET_TEMPLATE); @@ -214,5 +226,14 @@ public class FtpServerConfig } } + public boolean isActiveModeEnabled() + { + return activeModeEnabled; + } + + public int getActiveLocalPort() + { + return activePort; + } } -- GitLab