All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class kmy.net.ftpd.FTPDaemon

kmy.net.ftpd.FTPDaemon

public class FTPDaemon
Class FTPDaemon implemens FTP server. It can be customized as a Java Bean. Note that most of the functionality is actually implemented in the class FTPDConnection that runs single FTP connection. If you feel that you need to subclass this class you also probably will want to subclass FTPDConnection. In this case make sure you override method createConnection. For the description of FTP see RFC959.


Constructor Index

 o FTPDaemon()
Create new FTP server on the default FTP port 21.
 o FTPDaemon(int)
Create new FTP server on the specified port and initialize it.

Method Index

 o addFTPDListener(FTPDListener)
Registers new FTPDListener that will receive notifications for every new connection and every new command on every connection.
 o addUser(FTPDUser)
Add a user into default user directory.
 o addUser(String, String, String)
Add a user into default user directory.
 o createConnection(Socket)
Creates connection processing thread for the new incoming connection.
 o getAllowAnonymous()
Find out if this server allowes anonymous access.
 o getFTPThreadGroup()
Returns the ThreadGroup for the connections to this server.
 o getPort()
Returns port where this server accepts connections
 o getServerName()
Returns the name of the server which is used in the initial FTP reply.
 o getUserByName(String)
Return FTP user by its name in the default user directory.
 o getUserStrings()
For the simplified access to the default user directory (via JavaBean-style property).
 o homeSubstitution(String, String)
Performes csh-slyle "home substitution": a leading string in form ~user is substituted by the home directory of user 'user'.
 o init()
Initialize this server if it was not already initialized.
 o main(String[])
main that can be used to start and test the server.
 o makeURLStub(String)
Return an URL stub for this server, for the username specified, for example "ftp://user
 o nextRandom()
 o notifyListeners(FTPDConnection, String)
Notifies all listeners that command is issued on a connection
 o produceObject(String, String)
Produce an object that is represented by the path 'path' for user 'user'.
 o removeFTPDListener(FTPDListener)
Removes FTPDListener.
 o removeUser(String)
Removes a user from the default user directory.
 o run()
Runs the server.
 o setAllowAnonymous(boolean)
Allow or disallow anonymous access to this server.
 o setPort(int)
Sets the port where this server shuold accept connections.
 o setUserStrings(String[])
Setter for the userStrings property.
 o start()
Start FTP server, initializing it if needed.
 o userHome(String, String, String)
Authenticate user.

Constructors

 o FTPDaemon
 public FTPDaemon()
Create new FTP server on the default FTP port 21. Do not initialize it.

 o FTPDaemon
 public FTPDaemon(int _port) throws IOException
Create new FTP server on the specified port and initialize it.

Methods

 o nextRandom
 public long nextRandom()
 o start
 public void start()
Start FTP server, initializing it if needed.

 o init
 public synchronized void init() throws IOException
Initialize this server if it was not already initialized.

 o makeURLStub
 public String makeURLStub(String user)
Return an URL stub for this server, for the username specified, for example "ftp://user@127.0.0.1:8881".

 o getUserByName
 protected FTPDUser getUserByName(String name)
Return FTP user by its name in the default user directory. Override this method if you want to hook up your own user directory.

 o addUser
 public void addUser(FTPDUser user)
Add a user into default user directory.

 o addUser
 public void addUser(String name,
                     String pass,
                     String home)
Add a user into default user directory.

 o removeUser
 public void removeUser(String name)
Removes a user from the default user directory.

 o getServerName
 public String getServerName()
Returns the name of the server which is used in the initial FTP reply. Override if you want customize this name. (hostname or hostname:port is used by default).

 o getPort
 public synchronized int getPort()
Returns port where this server accepts connections

 o setPort
 public synchronized void setPort(int p)
Sets the port where this server shuold accept connections. Server should be reinitialized for this setting to take effect.

 o getFTPThreadGroup
 public ThreadGroup getFTPThreadGroup()
Returns the ThreadGroup for the connections to this server. (Every connection is processed in a separate thread.)

 o createConnection
 protected FTPDConnection createConnection(Socket incoming) throws IOException
Creates connection processing thread for the new incoming connection. Default implementation returns new instance of FTPDConnection. You need to override this method if you have written your own extension of FTPDConnection and want to hook it up to the server.

 o run
 public void run()
Runs the server. Normally you do not call this directly, call start() instead.

 o notifyListeners
 public void notifyListeners(FTPDConnection conn,
                             String command)
Notifies all listeners that command is issued on a connection

 o produceObject
 public VirtualObject produceObject(String path,
                                    String user) throws FTPDException
Produce an object that is represented by the path 'path' for user 'user'. Default method does the following:
    return getUserByName( user ).produceObject( path, this );
  
You can override it to implement your own behaviour (or you can override getUserByName and FTPDUser.produceObject).

Throws: FTPDException
if object cannot be produced for the path given
 o getAllowAnonymous
 public boolean getAllowAnonymous()
Find out if this server allowes anonymous access.

 o setAllowAnonymous
 public synchronized void setAllowAnonymous(boolean allow)
Allow or disallow anonymous access to this server.

 o userHome
 public synchronized String userHome(String user,
                                     String password,
                                     String challenge)
Authenticate user. Return null if authentication failed or user's home path if it succeeded. User and password are received from the client, and challenge is generated before client is asked for the password. Challenge is sent to the client in the request for password and thus can be (potentially) used to encript user's password. It is unused by the default FTPDUser implementation.

 o getUserStrings
 public synchronized String[] getUserStrings()
For the simplified access to the default user directory (via JavaBean-style property). Every user is represented as a String in the following format: "name;password;homeOnly;home;prefix". homeOnly should be true or false and it determines if this user should be grated access only to subdirectories of its own home directory. prefix is an "invisible" part of the path, prepended silently to every path this user wants to access.

 o setUserStrings
 public synchronized void setUserStrings(String userList[])
Setter for the userStrings property. See getUserStrings for the description.

 o addFTPDListener
 public synchronized void addFTPDListener(FTPDListener log)
Registers new FTPDListener that will receive notifications for every new connection and every new command on every connection.

 o removeFTPDListener
 public synchronized void removeFTPDListener(FTPDListener log)
Removes FTPDListener.

 o homeSubstitution
 public String homeSubstitution(String patt,
                                String cuser)
Performes csh-slyle "home substitution": a leading string in form ~user is substituted by the home directory of user 'user'. ~ alone is substituted by the home path of the current user.

 o main
 public static void main(String args[])
main that can be used to start and test the server.


All Packages  Class Hierarchy  This Package  Previous  Next  Index