Changeset 741
- Timestamp:
- Aug 13, 2008, 1:17:55 PM (15 years ago)
- 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 1 1 Manifest-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.jar2 Class-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 7 7 This package is an extension package to BASE that installs a small FTP 8 8 server as part of the web server. The code in this package currently 9 uses non-releasedsoftware from the Apache foundation. Thus, we can't make9 uses beta software from the Apache foundation. Thus, we can't make 10 10 any guarantee about functionality or stability of this extension. We recommend 11 11 testing on a development server before using this software in a production … … 16 16 http://baseplugins.thep.lu.se/wiki/net.sf.basedb.ftp 17 17 * The Apache FTP server site: 18 http://mina.apache.org/ftpserver .html18 http://mina.apache.org/ftpserver/index.html 19 19 20 20 == Installation == … … 22 22 1. Download the `base-ftpserver-*.tar.gz` file. 23 23 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 37 29 5. Copy the `base-ftpserver.jar` file and the `lib` directory, including sub- 38 30 directories and files, to your BASE extensions directory, `WEB-INF/extensions`. … … 48 40 8. Done. 49 41 50 == Known issues / limitation==42 == Known issues == 51 43 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-specific54 options.55 56 44 * BASE allows that a directory has the same name as a file. This may confuse 57 45 FTP clients since that is normally not allowed. The result for certain 58 46 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` 59 54 60 55 == Compiling == -
extensions/net.sf.basedb.ftp/trunk/build.xml
r716 r741 81 81 prefix="${tar.prefix}" 82 82 preserveLeadingSlashes="true" 83 includes="${jar.name},README,LICENSE,ftp .config,lib/ftpserver/*"83 includes="${jar.name},README,LICENSE,ftp-config.xml,lib/ftpserver/*" 84 84 /> 85 85 </tar> -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseFtpServer.java
r719 r741 25 25 26 26 import 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; 31 29 import 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; 37 32 import org.slf4j.Logger; 38 33 import org.slf4j.LoggerFactory; 34 import org.springframework.beans.factory.support.DefaultListableBeanFactory; 35 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; 36 import org.springframework.core.io.ClassPathResource; 37 import org.springframework.core.io.DefaultResourceLoader; 39 38 40 39 import net.sf.basedb.core.Application; … … 138 137 } 139 138 140 private final Configuration config;139 private final String configFile; 141 140 private FtpServer server; 142 141 … … 146 145 added. To start the FTP server call {@link #start()}. 147 146 148 @param config The configuration settings147 @param config The path to configuration file (classpath based) 149 148 @throws Exception If there is any problem 150 149 */ 151 public BaseFtpServer( Properties config)150 public BaseFtpServer(String configFile) 152 151 throws Exception 153 152 { 154 this.config = setPropertiesRequiredByBase(config);153 this.configFile = configFile; 155 154 } 156 155 … … 170 169 if (isRunning()) return; 171 170 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 186 172 try 187 173 { 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 193 186 server.start(); 194 187 } … … 221 214 } 222 215 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 } 248 217 } -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUser.java
r716 r741 177 177 178 178 @Override 179 public Authority[] getAuthorities(Class< Authority> clazz)179 public Authority[] getAuthorities(Class<? extends Authority> clazz) 180 180 { 181 181 List<Authority> selected = new ArrayList<Authority>(); -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/FtpServiceController.java
r719 r741 26 26 import java.io.InputStream; 27 27 import java.net.URL; 28 import java.util.Properties;29 28 30 29 import org.slf4j.Logger; … … 49 48 private static final Logger log = LoggerFactory.getLogger(FtpServiceController.class); 50 49 51 private final String config ;50 private final String configFile; 52 51 private BaseFtpServer server; 53 52 … … 55 54 Creates a new service controller action for controlling 56 55 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 58 58 */ 59 public FtpServiceController(String config )59 public FtpServiceController(String configFile) 60 60 { 61 this.config = config == null ? "/ftp.config" : config;61 this.configFile = configFile == null ? "/ftp-config.xml" : configFile; 62 62 } 63 63 … … 119 119 try 120 120 { 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); 123 123 InputStream is = configUrl == null ? null : configUrl.openStream(); 124 124 if (is == null) 125 125 { 126 throw new ConfigurationException("Can't find the propertiesfile. " +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."); 128 128 } 129 Properties config = new Properties(); 130 config.load(is); 131 is.close(); 132 server = new BaseFtpServer(config); 129 server = new BaseFtpServer(configFile); 133 130 log.info("BASE FTP Server created successfully"); 134 131 } -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/FtpServiceControllerFactory.java
r717 r741 40 40 <ul> 41 41 <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> 43 43 </ul> 44 44 … … 83 83 Set the path to the configuration file to use. The path 84 84 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) 86 86 */ 87 87 public void setConfig(String config)
Note: See TracChangeset
for help on using the changeset viewer.