net.sf.hermesftp.server
Class AbstractFtpServer

java.lang.Object
  extended by net.sf.hermesftp.utils.AbstractAppAwareBean
      extended by net.sf.hermesftp.server.AbstractFtpServer
All Implemented Interfaces:
java.lang.Runnable, BeanConstants, FtpConstants, FtpEventListener, FtpServer, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
DefaultFtpServer, SecureFtpServer

public abstract class AbstractFtpServer
extends AbstractAppAwareBean
implements FtpServer, FtpConstants, FtpEventListener

Ancestor class for FTP server implementations.

Author:
Lars Behnke

Field Summary
 
Fields inherited from interface net.sf.hermesftp.common.FtpConstants
ATTR_CLIENT_NAME, ATTR_DATA_PROT, ATTR_FILE_OFFSET, ATTR_FORCE_UTF8, ATTR_GROUP_DATA, ATTR_LOGIN_TIME, ATTR_RENAME_FILE, ATTR_RESTART_MARKERS, ATTR_SSL, ATTR_USER_DATA, BYTE_LENGTH, BYTE_MASK, DEFAULT_BEAN_RES, DEFAULT_KEYSTORE, DEFAULT_KEYSTORE_PASS, DT_ASCII, DT_BINARY, DT_EBCDIC, HERMES_HOME, MILLI, MODE_BLOCK, MODE_COMPRESS, MODE_STREAM, MODE_ZIP, MSG_GOODBYE, MSG150, MSG200, MSG200_NOTED, MSG200_PBSZ, MSG200_SIZE, MSG200_TYPE, MSG202, MSG211_FEAT_ENTRY, MSG211_FEAT_FOOTER, MSG211_FEAT_HEADER, MSG211_STAT, MSG213_SIZE, MSG213_TIME, MSG214, MSG220, MSG220_WEL, MSG226, MSG227, MSG229, MSG230, MSG234, MSG250, MSG257, MSG331, MSG350, MSG350_REST, MSG421, MSG425, MSG426, MSG431, MSG450, MSG451, MSG500, MSG500_CMD, MSG501, MSG501_PATH, MSG501_SIZE, MSG503, MSG503_USR, MSG504, MSG522, MSG530, MSG530_AUTH, MSG534, MSG536, MSG550, MSG550_COMM, MSG550_EXISTS, MSG550_MSG, MSG550_NOTEMPTY, MSG550_PERM, MSG553, OPT_ALLOWED_PASSIVE_PORTS, OPT_BUFFER_SIZE, OPT_CHARSET_ASCII, OPT_CHARSET_EBCDIC, OPT_EMULATE_UNIX, OPT_FTP_PORT, OPT_IPV4_BLACK_LIST, OPT_IPV6_BLACK_LIST, OPT_MAX_CONNECTIONS, OPT_MAX_DOWNLOAD_RATE, OPT_MAX_IDLE_SECONDS, OPT_MAX_UPLOAD_RATE, OPT_MSG_GOODBYE, OPT_MSG_WELCOME, OPT_REMOTE_DIR, OPT_SSL_ALLOW_EXPLICIT, OPT_SSL_ALLOW_IMPLICIT, OPT_SSL_CIPHER_SUITES, OPT_SSL_FORCE, OPT_SSL_KEYSTORE_FILE, OPT_SSL_KEYSTORE_PASS, OPT_SSL_PORT_IMPLICIT, PRIV_NONE, PRIV_READ, PRIV_READ_WRITE, PRIV_WRITE, PWD, SEPARATOR, SERVER_STATUS_HALTED, SERVER_STATUS_INIT, SERVER_STATUS_READY, SERVER_STATUS_UNDEF, SPACE, STAT_BYTES_DOWNLOADED, STAT_BYTES_UPLOADED, STAT_DOWNLOAD_RATE, STAT_FILES_DOWNLOADED, STAT_FILES_UPLOADED, STAT_UPLOAD_RATE, STRUCT_FILE, STRUCT_RECORD, TYPE_NAMES, WILDCARD
 
Fields inherited from interface net.sf.hermesftp.common.BeanConstants
BEAN_CONSOLE, BEAN_SERVER, BEAN_SESSION, BEAN_SSL_SERVER
 
Constructor Summary
AbstractFtpServer()
           
 
Method Summary
 void abort()
          Halts the server.
 void addFtpEventListener(FtpEventListener lstnr)
          Adds an external listerner that wants to get informed about FTP events.
 void cleanUpSessions()
          Removes closed sessions from memory.
protected abstract  FtpSessionContext createFtpContext()
          Creates the context object passed to the user session.
protected abstract  java.net.ServerSocket createServerSocket()
          Creates a server socket.
 void downloadPerformed(java.lang.String clientId, java.io.File file)
          The event is called after a file has been downloaded by a client.
 int getConnectionCount()
          Getter method for the java bean connectionCount.
 int getConnectionCountHWMark()
          Maximum number of connections since server started.
 java.util.Date getConnectionCountHWMarkDate()
          Date when number of connections reached its maximum.
 java.lang.String getName()
          Returns the name of the FTP server.
 java.lang.String getOption(java.lang.String name)
          Convenience method for accessing the application properties.
 FtpServerOptions getOptions()
          Getter method for the java bean options.
 java.lang.String getResources()
          Getter method for the java bean resources.
 java.util.List<FtpSession> getSessions()
          Returns the list of active sessions.
 int getStatus()
          Getter method for the java bean status.
 UserManager getUserManager()
          Getter method for the java bean userManager.
 boolean isTerminated()
          Getter method for the java bean terminated.
 void loginPerformed(java.lang.String clientId, boolean successful)
          Number of failed long attempts.
 void run()
          
 void sessionClosed(java.lang.Object sessionObj)
          Method is called after a client session has been closed.
 void sessionOpened(java.lang.Object sessionObj)
          Method is called after a client session has been opened.
 void setConnectionCountHWMark(int connectionCountHWMark)
          Setter methode for property connectionCountHWMark.
 void setConnectionCountHWMarkDate(java.util.Date connectionCountHWMarkDate)
          Setter methode for property connectionCountHWMarkDate.
 void setName(java.lang.String name)
           
 void setOptions(FtpServerOptions options)
          Setter method for the java bean options.
 void setResources(java.lang.String resources)
          Setter method for the java bean resources.
 void setStatus(int status)
          Setter method for the java bean status.
 void setUserManager(UserManager userManager)
          Setter method for the java bean userManager.
 void uploadPerformed(java.lang.String clientId, java.io.File file)
          The event is called after a file has been uploaded by a client.
 
Methods inherited from class net.sf.hermesftp.utils.AbstractAppAwareBean
getApplicationContext, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFtpServer

public AbstractFtpServer()
Method Detail

createServerSocket

protected abstract java.net.ServerSocket createServerSocket()
                                                     throws java.io.IOException
Creates a server socket. Depending on the server implementation this can be a SSL or a regular server socket.

Returns:
The server socket.
Throws:
java.io.IOException - Error on creating server socket.

createFtpContext

protected abstract FtpSessionContext createFtpContext()
Creates the context object passed to the user session.

Returns:
The session context.

abort

public void abort()
Halts the server.

Specified by:
abort in interface FtpServer

getOptions

public FtpServerOptions getOptions()
Getter method for the java bean options.

Specified by:
getOptions in interface FtpServer
Returns:
Returns the value of the java bean options.

setOptions

public void setOptions(FtpServerOptions options)
Setter method for the java bean options.

Parameters:
options - The value of options to set.

run

public void run()

Specified by:
run in interface java.lang.Runnable

getConnectionCount

public int getConnectionCount()
Getter method for the java bean connectionCount.

Specified by:
getConnectionCount in interface FtpServer
Returns:
Returns the value of the java bean connectionCount.

cleanUpSessions

public void cleanUpSessions()
Removes closed sessions from memory.

Specified by:
cleanUpSessions in interface FtpServer

getOption

public java.lang.String getOption(java.lang.String name)
Convenience method for accessing the application properties.

Parameters:
name - The name of the requested property.
Returns:
The property.

getResources

public java.lang.String getResources()
Getter method for the java bean resources.

Returns:
Returns the value of the java bean resources.

setResources

public void setResources(java.lang.String resources)
Setter method for the java bean resources.

Parameters:
resources - The value of resources to set.

isTerminated

public boolean isTerminated()
Getter method for the java bean terminated.

Returns:
Returns the value of the java bean terminated.

getStatus

public int getStatus()
Getter method for the java bean status.

Specified by:
getStatus in interface FtpServer
Returns:
Returns the value of the java bean status.

setStatus

public void setStatus(int status)
Setter method for the java bean status.

Parameters:
status - The value of status to set.

getUserManager

public UserManager getUserManager()
Getter method for the java bean userManager.

Specified by:
getUserManager in interface FtpServer
Returns:
Returns the value of the java bean userManager.

setUserManager

public void setUserManager(UserManager userManager)
Setter method for the java bean userManager.

Parameters:
userManager - The value of userManager to set.

addFtpEventListener

public void addFtpEventListener(FtpEventListener lstnr)
Adds an external listerner that wants to get informed about FTP events.

Specified by:
addFtpEventListener in interface FtpServer
Parameters:
lstnr - The listener.

downloadPerformed

public void downloadPerformed(java.lang.String clientId,
                              java.io.File file)
The event is called after a file has been downloaded by a client.

Specified by:
downloadPerformed in interface FtpEventListener
Parameters:
clientId - The unique ID of a client.
file - The downloaded file.

loginPerformed

public void loginPerformed(java.lang.String clientId,
                           boolean successful)
Number of failed long attempts.

Specified by:
loginPerformed in interface FtpEventListener
Parameters:
clientId - The unique ID of a client.
successful - True, if the authentication was successful.

uploadPerformed

public void uploadPerformed(java.lang.String clientId,
                            java.io.File file)
The event is called after a file has been uploaded by a client.

Specified by:
uploadPerformed in interface FtpEventListener
Parameters:
clientId - The unique ID of a client.
file - The uploaded file.

sessionOpened

public void sessionOpened(java.lang.Object sessionObj)
Method is called after a client session has been opened.

Specified by:
sessionOpened in interface FtpEventListener
Parameters:
sessionObj - The closed session object.

sessionClosed

public void sessionClosed(java.lang.Object sessionObj)
Method is called after a client session has been closed.

Specified by:
sessionClosed in interface FtpEventListener
Parameters:
sessionObj - The closed session object.

getSessions

public java.util.List<FtpSession> getSessions()
Returns the list of active sessions.

Specified by:
getSessions in interface FtpServer
Returns:
The list.

getConnectionCountHWMark

public int getConnectionCountHWMark()
Maximum number of connections since server started.

Specified by:
getConnectionCountHWMark in interface FtpServer
Returns:
The high water mark.

getConnectionCountHWMarkDate

public java.util.Date getConnectionCountHWMarkDate()
Date when number of connections reached its maximum.

Specified by:
getConnectionCountHWMarkDate in interface FtpServer
Returns:
The high water mark date.

setConnectionCountHWMark

public void setConnectionCountHWMark(int connectionCountHWMark)
Setter methode for property connectionCountHWMark.

Parameters:
connectionCountHWMark - Value for connectionCountHWMark.

setConnectionCountHWMarkDate

public void setConnectionCountHWMarkDate(java.util.Date connectionCountHWMarkDate)
Setter methode for property connectionCountHWMarkDate.

Parameters:
connectionCountHWMarkDate - Value for connectionCountHWMarkDate.

getName

public java.lang.String getName()
Description copied from interface: FtpServer
Returns the name of the FTP server.

Specified by:
getName in interface FtpServer
Returns:
The name.

setName

public void setName(java.lang.String name)


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.