FtpServer

Small FTP Server. Intended for ad-hoc networks in a secure environment. Remote connections are possible. See also http://cr.yp.to/ftp.html http://www.ftpguide.com/

Methods
static ServerSocket createDataSocket()
Create a socket to listen for incoming data connections.
static ServerSocket createDataSocket()
Create a socket to listen for incoming data connections.
Returns:
the server socket
static Server createFtpServer(String... args)
Create a new FTP server, but does not start it yet.
static Server createFtpServer(String... args) throws SQLException
Create a new FTP server, but does not start it yet. Example:
 Server server = FtpServer.createFtpServer(null).start();
Parameters:
args - the argument list
Returns:
the server
static void main(String... args)
When running without options, -tcp, -web, -browser, and -pg are started.
Options are case sensitive.
static void main(String... args) throws SQLException
When running without options, -tcp, -web, -browser, and -pg are started.
Options are case sensitive. Supported options are:
[-help] or [-?] Print the list of options
[-web] Start the web server with the H2 Console
[-webAllowOthers] Allow other computers to connect
[-webPort <port>] The port (default: 8082)
[-webSSL] Use encrypted (HTTPS) connections
[-browser] Start a browser and open a page to login to the web server
[-tcp] Start the TCP server
[-tcpAllowOthers] Allow other computers to connect
[-tcpPort <port>] The port (default: 9092)
[-tcpSSL] Use encrypted (SSL) connections
[-tcpPassword <pwd>] The password for shutting down a TCP server
[-tcpShutdown "<url>"] Stop the TCP server; example: tcp://localhost:9094
[-tcpShutdownForce] Do not wait until all connections are closed
[-pg] Start the PG server
[-pgAllowOthers] Allow other computers to connect
[-pgPort <port>] The port (default: 5435)
[-ftp] Start the FTP server
[-ftpPort <port>] The port (default: 8021)
[-ftpDir <dir>] The base directory (default: ftp)
[-ftpRead <user>] The user name for reading (default: guest)
[-ftpWrite <user>] The user name for writing (default: sa)
[-ftpWritePassword <p>] The write password (default: sa)
[-baseDir <dir>] The base directory for H2 databases; for all servers
[-ifExists] Only existing databases may be opened; for all servers
[-trace] Print additional trace information; for all servers
Parameters:
args - the command line arguments
boolean checkUserPasswordReadOnly(String userName)
Check if this user name is allowed to read.
boolean checkUserPasswordReadOnly(String userName)
Check if this user name is allowed to read.
Parameters:
userName - the user name
Returns:
true if this user may read
boolean checkUserPasswordWrite(String userName, String password)
Check if this user name is allowed to write.
boolean checkUserPasswordWrite(String userName, String password)
Check if this user name is allowed to write.
Parameters:
userName - the user name
password - the password
Returns:
true if this user may write
void closeConnection()
Close a connection.
void closeConnection()
Close a connection. The open connection count will be decremented.
String formatLastModified(String fileName)
Get the last modified date of a date and format it as required by the FTP protocol.
String formatLastModified(String fileName)
Get the last modified date of a date and format it as required by the FTP protocol.
Parameters:
fileName - the file name
Returns:
the last modified date of this file
boolean getAllowOthers()
boolean getAllowOthers()
boolean getAllowTask()
boolean getAllowTask()
String getDirectoryListing(String directory, boolean listDirectories)
Get the directory listing for this directory.
String getDirectoryListing(String directory, boolean listDirectories)
Get the directory listing for this directory.
Parameters:
directory - the directory to list
listDirectories - if sub-directories should be listed
Returns:
the list
FtpEventListener getEventListener()
Get the registered event listener.
FtpEventListener getEventListener()
Get the registered event listener.
Returns:
the event listener, or null if non is registered
String getFileName(String path)
Get the full file name of this relative path.
String getFileName(String path)
Get the full file name of this relative path.
Parameters:
path - the relative path
Returns:
the file name
String getName()
String getName()
int getPort()
int getPort()
String getType()
String getType()
String getURL()
String getURL()
void init(String... args)
void init(String... args)
boolean isDaemon()
boolean isDaemon()
boolean isRunning(boolean traceError)
boolean isRunning(boolean traceError)
void listen()
void listen()
void runTool(String... args)
void runTool(String... args) throws SQLException
void setEventListener(FtpEventListener eventListener)
Set the event listener.
void setEventListener(FtpEventListener eventListener)
Set the event listener. Only one listener can be registered.
Parameters:
eventListener - the new listener, or null to de-register
void start()
void start()
void startTask(String path)
Start a task.
void startTask(String path) throws IOException
Start a task.
Parameters:
path - the name of the task file
void stop()
void stop()
void stopTask(String processName)
Stop a running task.
void stopTask(String processName)
Stop a running task.
Parameters:
processName - the task name
void trace(String s)
Write trace information if trace is enabled.
void trace(String s)
Write trace information if trace is enabled.
Parameters:
s - the message to write
void traceError(Throwable e)
Write the stack trace if trace is enabled.
void traceError(Throwable e)
Write the stack trace if trace is enabled.
Parameters:
e - the exception