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