Hello
ich want to embed ftpserver in my jboss application, but i cannot store any 
files
also i do not see any files i put (manually) into the ftp root:
 
this is my mbean, which starts the server
 
package de.akdb.ok.test.mbean.ftp;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.Authority;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.ftplet.UserManager;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
import org.apache.ftpserver.usermanager.impl.BaseUser;
import org.apache.ftpserver.usermanager.impl.WritePermission;
import org.jboss.annotation.ejb.Management;
import org.jboss.annotation.ejb.Service;
 
@Service(objectName = "test:service=ftpserver")
@Management(FtpServerMBean.class)
public class FtpServerService implements FtpServerMBean {
 
 FtpServerFactory serverFactory;
 FtpServer server;
 private String jbossDataDir = System.getProperty("jboss.server.data.dir")
   + File.separator;
 
 public FtpServerService() {
  super();
  serverFactory = new FtpServerFactory();
 
  ListenerFactory factory = new ListenerFactory();
  factory.setPort(1121);
  serverFactory.addListener("default", factory.createListener());
 
  PropertiesUserManagerFactory userManagerFactory = new 
PropertiesUserManagerFactory();
  final String pathname = jbossDataDir + "myusers.properties";
  final File propFile = new File(pathname);
  if (!propFile.exists())
   try {
    propFile.createNewFile();
   } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   }
  userManagerFactory.setFile(propFile);
  final UserManager userManager = userManagerFactory.createUserManager();
  serverFactory.setUserManager(userManager);
 
  server = serverFactory.createServer();
  try {
   server.start();
  } catch (FtpException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
 
 public void create() throws Exception {
  // called by the server when the service is created and all the services
  // it depends upon have been created too. At this point the service (and
  // all the services it depends on) is installed in the JMX server, but
  // is not yet fully functional.
 }
 
 public void destroy() {
  // called by the server when the service is destroyed and removed from
  // the MBean server. At this point the service (and all the services
  // that depend on it) are destroyed.
 }
 
 public void start() throws Exception {
  // called by the server when the service is started and all the services
  // it depends upon have been started too. At this point the service (and
  // all the services it depends on) is fully functional..
 }
 
 public void stop() {
  // called by the server when the service is stopped. At this point the
  // service (and all the services that depend on it) is no longer fully
  // operational.
 }
 
 public boolean isStopped() {
  if (server == null) {
   return true;
  }
  final boolean stopped = server.isStopped();
  return stopped;
 }
 
 public boolean isSuspended() {
  if (server == null) {
   return false;
  }
  final boolean suspended = server.isSuspended();
  return suspended;
 }
 
 public void resumeServer() {
  if (server != null) {
   server.resume();
  }
 }
 
 public void suspendServer() {
  if (server != null) {
   server.suspend();
  }
 }
 
 public boolean createBaseUser() {
  if (serverFactory != null) {
   final UserManager userManager = serverFactory.getUserManager();
   if (userManager != null) {
    BaseUser u = new BaseUser();
    u.setName("user");
    u.setPassword("password");
    u.setHomeDirectory(jbossDataDir + "ftp");
    Authority a = new WritePermission(jbossDataDir + "ftp");
    List<Authority> authList = new ArrayList<Authority>();
    authList.add(a);
    u.setAuthorities(authList);
 
    try {
     userManager.save(u);
    } catch (FtpException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return false;
    }
   }
  }
  return true;
 
 }
}

the line above     Authority a = new WritePermission(jbossDataDir + "ftp");
is wrong i guess, as it generates the following myusers.properties:
ftpserver.user.user.idletime=0
ftpserver.user.user.userpassword=5F4DCC3B5AA765D61D8327DEB882CF99
ftpserver.user.user.homedirectory=D\:\\SEU\\Programme\\jboss-4.2.3.GA\\server\\akdb\\data\\ftp
ftpserver.user.user.writepermission=false
ftpserver.user.user.enableflag=true
 
if i did Authority a = new WritePermission();
th e line about writepermissions is
ftpserver.user.user.writepermission=true

what am i missing to access my files ?
 
Mit freundlichen Grüßen,
Maximilian Hötzl
 
Anstalt für kommunale Datenverarbeitung in Bayern (AKDB)
Bereich 151
 
Hauptverwaltung
Zimmer H-337 
Herzogspitalstraße 24 
80331 München 
  • Embedding FtpServ... Hötzl Maximilian, A15 Entwicklung Qualitätsmana gement

Reply via email to