Changeset 741


Ignore:
Timestamp:
Aug 13, 2008, 1:17:55 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

References #114. Upgrading to 1.0.0-M2 release of Apache FTP server.

Location:
extensions/net.sf.basedb.ftp/trunk
Files:
8 added
7 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.ftp/trunk/META-INF/MANIFEST.MF

    r714 r741  
    11Manifest-Version: 1.0
    2 Class-Path: lib/ftpserver/ftplet-api.jar lib/ftpserver//ftpserver-core.jar lib/ftpserver//ftpserver-server.jar lib/ftpserver//mina-core-2.jar lib/ftpserver//slf4j-api-1.4.3.jar lib/ftpserver//slf4j-log4j12-1.4.3.jar
     2Class-Path: lib/ftpserver/ftplet-api-1.0.0-M2.jar lib/ftpserver/ftpserver-core-1.0.0-M2.jar lib/ftpserver/mina-core-2.0.0-M2.jar lib/ftpserver/slf4j-api-1.5.2.jar lib/ftpserver/slf4j-log4j12-1.5.2.jar lib/ftpserver/spring-core-2.5.5.jar lib/ftpserver/spring-beans-2.5.5.jar
  • extensions/net.sf.basedb.ftp/trunk/README

    r717 r741  
    77This package is an extension package to BASE that installs a small FTP
    88server as part of the web server. The code in this package currently
    9 uses non-released software from the Apache foundation. Thus, we can't make
     9uses beta software from the Apache foundation. Thus, we can't make
    1010any guarantee about functionality or stability of this extension. We recommend
    1111testing on a development server before using this software in a production
     
    1616   http://baseplugins.thep.lu.se/wiki/net.sf.basedb.ftp
    1717 * The Apache FTP server site:
    18    http://mina.apache.org/ftpserver.html
     18   http://mina.apache.org/ftpserver/index.html
    1919
    2020== Installation ==
     
    2222 1. Download the `base-ftpserver-*.tar.gz` file.
    2323 2. Unpack the downloaded file to a directory of your choice.
    24  3. Copy the `ftp.config` file to `WEB-INF/classes` directory.
    25  4. The default `ftp.config` file creates a regular FTP service with the
    26     control connection on port 2121 accepting connections from the local
    27     host only. To allow extenal connections the three settings listed
    28     below needs to be changed. It should work to change the 127.0.0.1 value
    29     to the ip number (using names doesn't seem to work) of your BASE server.
    30     For more information about configuration options see:
    31     http://mina.apache.org/ftpserver-documentation.html
    32    
    33     * config.listeners.default.address
    34     * config.listeners.default.data-connection.passive.address
    35     * config.listeners.default.data-connection.passive.external-address
    36    
     24 3. Copy the `ftp-config.xml` file to `WEB-INF/classes` directory.
     25 4. The default `ftp-config.xml` file creates a regular FTP service with the
     26    control connection on port 2121. There is also an example of an
     27    SSL-enabled configuration. For more information about configuration
     28    options see: http://mina.apache.org/ftpserver/documentation.html 
    3729 5. Copy the `base-ftpserver.jar` file and the `lib` directory, including sub-
    3830    directories and files, to your BASE extensions directory, `WEB-INF/extensions`.
     
    4840 8. Done.
    4941
    50 == Known issues / limitation ==
     42== Known issues ==
    5143
    52  * It is not possible to specify a `user-manager` or `file-system-manager`
    53    in the `ftp.config` file. Those settings will be replaced by BASE-specific
    54    options.
    55    
    5644 * BASE allows that a directory has the same name as a file. This may confuse
    5745   FTP clients since that is normally not allowed. The result for certain
    5846   operations is undefined for files and directories that has the same name.
     47
     48== Tips and tricks ==
     49
     50 * If you want to try out an SSL enabled FTP server, but doesn't have
     51   a certificate, you may create one with the following command:
     52   
     53   `keytool -genkey -keystore test.jks -storetype JKS -storepass test -keypass test  -alias test`
    5954
    6055== Compiling ==
  • extensions/net.sf.basedb.ftp/trunk/build.xml

    r716 r741  
    8181        prefix="${tar.prefix}"
    8282        preserveLeadingSlashes="true"
    83         includes="${jar.name},README,LICENSE,ftp.config,lib/ftpserver/*"
     83        includes="${jar.name},README,LICENSE,ftp-config.xml,lib/ftpserver/*"
    8484      />
    8585    </tar>
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtpServer.java

    r719 r741  
    2525
    2626import java.util.EnumSet;
    27 import java.util.Iterator;
    28 import java.util.Properties;
    29 
    30 import org.apache.ftpserver.ConfigurableFtpServerContext;
     27
     28//import org.apache.ftpserver.ConfigurableFtpServerContext;
    3129import org.apache.ftpserver.FtpServer;
    32 import org.apache.ftpserver.config.PropertiesConfiguration;
    33 import org.apache.ftpserver.ftplet.Configuration;
    34 import org.apache.ftpserver.ftplet.FtpException;
    35 import org.apache.ftpserver.ftplet.Ftplet;
    36 import org.apache.ftpserver.interfaces.FtpServerContext;
     30//import org.apache.ftpserver.config.PropertiesConfiguration;
     31//import org.apache.ftpserver.ftplet.Configuration;
    3732import org.slf4j.Logger;
    3833import org.slf4j.LoggerFactory;
     34import org.springframework.beans.factory.support.DefaultListableBeanFactory;
     35import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
     36import org.springframework.core.io.ClassPathResource;
     37import org.springframework.core.io.DefaultResourceLoader;
    3938
    4039import net.sf.basedb.core.Application;
     
    138137  }
    139138
    140   private final Configuration config;
     139  private final String configFile;
    141140  private FtpServer server;
    142141 
     
    146145    added. To start the FTP server call {@link #start()}.
    147146   
    148     @param config The configuration settings
     147    @param config The path to configuration file (classpath based)
    149148    @throws Exception If there is any problem
    150149  */
    151   public BaseFtpServer(Properties config)
     150  public BaseFtpServer(String configFile)
    152151    throws Exception
    153152  {
    154     this.config = setPropertiesRequiredByBase(config);
     153    this.configFile = configFile;
    155154  }
    156155
     
    170169    if (isRunning()) return;
    171170    log.info("Starting BASE FTP Server");
    172     if (log.isDebugEnabled())
    173     {
    174       Iterator<String> keys = config.getKeys();
    175       while (keys.hasNext())
    176       {
    177         String key = keys.next();
    178         try
    179         {
    180           log.debug(key + "=" + config.getString(key));
    181         }
    182         catch (FtpException ex)
    183         {} // Should never happen
    184       }
    185     }
     171
    186172    try
    187173    {
    188       FtpServerContext context = new ConfigurableFtpServerContext(config);
    189       Ftplet baseFtplet = new BaseFtplet();
    190       baseFtplet.init(context);
    191       context.getFtpletContainer().addFtplet("base", baseFtplet);
    192       server = new FtpServer(context);
     174      ClassLoader classLoader = FtpServer.class.getClassLoader();
     175     
     176      DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
     177      factory.setBeanClassLoader(classLoader);
     178      XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
     179      reader.setResourceLoader(new DefaultResourceLoader(classLoader));
     180      reader.loadBeanDefinitions(new ClassPathResource(configFile, classLoader));
     181      server = (FtpServer)factory.getBean("server");
     182     
     183      //System.out.println("Start FTP server: " + server);
     184      //System.out.println("port: " + server.getListener("default").getPort());
     185     
    193186      server.start();
    194187    }
     
    221214    }
    222215    log.info("BASE FTP Server has been stopped");
    223   }
    224 
    225   /**
    226     Makes a copy of the properties and set BASE-specific ones. Returned
    227     as a {@link Configuration} object.
    228   */
    229   private Configuration setPropertiesRequiredByBase(Properties config)
    230   {
    231     Properties cfg = (Properties)config.clone();
    232     cfg.setProperty("config.create-default-user", "false");
    233     cfg.setProperty("config.connection-manager.anonymous-login-enabled", "false");
    234     cfg.setProperty("config.user-manager.class", "net.sf.basedb.clients.ftp.BaseUserManager");
    235     cfg.setProperty("config.file-system-manager.class", "net.sf.basedb.clients.ftp.BaseFileSystem");
    236     if (log.isDebugEnabled())
    237     {
    238       log.debug("Creating new FTP Server configuration");
    239       for (Object key : cfg.keySet())
    240       {
    241         log.debug(key + "=" + cfg.getProperty(key.toString()));
    242       }
    243     }
    244     return new PropertiesConfiguration(cfg);
    245   }
    246  
    247  
     216  }
    248217}
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUser.java

    r716 r741  
    177177
    178178  @Override
    179   public Authority[] getAuthorities(Class<Authority> clazz)
     179  public Authority[] getAuthorities(Class<? extends Authority> clazz)
    180180  {
    181181    List<Authority> selected = new ArrayList<Authority>();
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/FtpServiceController.java

    r719 r741  
    2626import java.io.InputStream;
    2727import java.net.URL;
    28 import java.util.Properties;
    2928
    3029import org.slf4j.Logger;
     
    4948  private static final Logger log = LoggerFactory.getLogger(FtpServiceController.class);
    5049
    51   private final String config;
     50  private final String configFile;
    5251  private BaseFtpServer server;
    5352 
     
    5554    Creates a new service controller action for controlling
    5655    a single ftp server service
    57     @param server The server to control with this action
     56    @param configFile The path to configuration file (classpath based),
     57      if null the default (/ftp-config.xml) is used
    5858  */
    59   public FtpServiceController(String config)
     59  public FtpServiceController(String configFile)
    6060  {
    61     this.config = config == null ? "/ftp.config" : config;
     61    this.configFile = configFile == null ? "/ftp-config.xml" : configFile;
    6262  }
    6363 
     
    119119      try
    120120      {
    121         log.debug("config=" + config);
    122         URL configUrl = BaseFtpServer.class.getResource(config);
     121        log.debug("configuration file=" + configFile);
     122        URL configUrl = BaseFtpServer.class.getResource(configFile);
    123123        InputStream is = configUrl == null ? null : configUrl.openStream();
    124124        if (is == null)
    125125        {
    126           throw new ConfigurationException("Can't find the properties file. " +
    127               "Make sure '" + config + "' is in the CLASSPATH.");
     126          throw new ConfigurationException("Can't find the configuration file. " +
     127              "Make sure '" + configFile + "' is in the CLASSPATH.");
    128128        }
    129         Properties config = new Properties();
    130         config.load(is);
    131         is.close();
    132         server = new BaseFtpServer(config);
     129        server = new BaseFtpServer(configFile);
    133130        log.info("BASE FTP Server created successfully");
    134131      }
  • extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/FtpServiceControllerFactory.java

    r717 r741  
    4040  <ul>
    4141  <li>{@link #setConfig(String)}: The path to the configuration file. The
    42     default is: <code>/ftp.config</code>
     42    default is: <code>/ftp-config.xml</code>
    4343  </ul>
    4444 
     
    8383    Set the path to the configuration file to use. The path
    8484    should be a path on the CLASSPATH.
    85     @param config The path, or null to use the default path (/ftp.config)
     85    @param config The path, or null to use the default path (/ftp-config.xml)
    8686  */
    8787  public void setConfig(String config)
Note: See TracChangeset for help on using the changeset viewer.