FTP-Server API

server
Class Survailance

java.lang.Object
  |
  +--server.Survailance
All Implemented Interfaces:
ServerObserver

public final class Survailance
extends Object
implements ServerObserver

Keeps an eye on the clients and kicks/bans them if they are too passive, or uses a known pattern of commands that should be banned!


Field Summary
static int ACTION_ON_FOUND_PATTERN
          Default = BAN_ON_FOUND_PATTERN
static int BAN_ON_FOUND_PATTERN
           
static int KICK_ON_FOUND_PATTERN
           
 
Method Summary
 int addKickPattern(LogFileSession ses)
          Adds a LogFileSession as a pattern, that clients will be kicked if they use!
 void addSurvailanceController(SurvailanceController survailanceController)
          Adds a SurvailanceController.
 void clientConnected(UserSession userSession)
          When a client connects this method is automatically called.
 void clientDisconnected(UserSession userSession)
          When a client disconnects this method is automatically called.
 int containsPattern(LogFileSession logFileSession)
          Sees if the LogFileSession already exists in the banpatterns.
 boolean deleteKickPattern(LogFileSession ses)
          Delets a kickpattern from the survailance
 Vector getKickPatterns()
          Gets all kickpatterns in a new Vector.
 LogFileReader getLogFileReader()
          Gets the logFileReader reading the 'ban-patterns.conf' file.
static Survailance instanceOf()
          Constructor of Singleton class.
 boolean isStarted()
          Is Survailance turned on
 void readloadPatterns()
          Reloads all the patterns from the ban-patterns.conf file
 void removeSurvailanceController(SurvailanceController survailanceController)
          Removes a SurvailanceController
 void serverStarted(boolean startedOk)
          Indicated that the server has been attemped started
 void serverStoped()
          The server has been stoped!
 void setSecondsToTimeout(int seconds)
          Sets the number of seconds a client must live before he is kicked if he is too passive.
 void start()
          Starts the survailance of clients.
 void stop()
          Stops the survailance of clients.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KICK_ON_FOUND_PATTERN

public static final int KICK_ON_FOUND_PATTERN
See Also:
Constant Field Values

BAN_ON_FOUND_PATTERN

public static final int BAN_ON_FOUND_PATTERN
See Also:
Constant Field Values

ACTION_ON_FOUND_PATTERN

public static int ACTION_ON_FOUND_PATTERN
Default = BAN_ON_FOUND_PATTERN

Method Detail

instanceOf

public static Survailance instanceOf()
Constructor of Singleton class.

Returns:
the instance

containsPattern

public int containsPattern(LogFileSession logFileSession)
Sees if the LogFileSession already exists in the banpatterns.

Parameters:
logFileSession - pattern to check if exists
Returns:
if the pattern is already added, the sessionnumber that holds the pattern are returned. -1 otherwise.

getLogFileReader

public LogFileReader getLogFileReader()
Gets the logFileReader reading the 'ban-patterns.conf' file.

Returns:
file containing all ban-patterns

setSecondsToTimeout

public void setSecondsToTimeout(int seconds)
Sets the number of seconds a client must live before he is kicked if he is too passive. One thing should be noticed though! Only ONE timer keeps track of all clients. This means that even if this method is set to 60 seconds, a new client cold be kicked after 10 seconds, because the timer has reached 50 seconds when he connects... NO clients can be kicked within their first 10 seconds online though...

Parameters:
seconds - Seconds before autokick if passive

clientConnected

public final void clientConnected(UserSession userSession)
When a client connects this method is automatically called. A client cannot be added though here twice (uses HashMap for storage)

Specified by:
clientConnected in interface ServerObserver
Parameters:
userSession - the new client

clientDisconnected

public final void clientDisconnected(UserSession userSession)
When a client disconnects this method is automatically called.

Specified by:
clientDisconnected in interface ServerObserver
Parameters:
userSession - the disconnecting client

serverStarted

public void serverStarted(boolean startedOk)
Description copied from interface: ServerObserver
Indicated that the server has been attemped started

Specified by:
serverStarted in interface ServerObserver
Parameters:
startedOk - whether the server has started successfully or not.

serverStoped

public void serverStoped()
Description copied from interface: ServerObserver
The server has been stoped!

Specified by:
serverStoped in interface ServerObserver

addKickPattern

public int addKickPattern(LogFileSession ses)
Adds a LogFileSession as a pattern, that clients will be kicked if they use!

Parameters:
ses - pattern
Returns:
if the pattern is already added, the sessionnumber that holds the pattern are returned. -1 otherwise.

deleteKickPattern

public boolean deleteKickPattern(LogFileSession ses)
Delets a kickpattern from the survailance

Parameters:
ses - pattern
Returns:
true if found

readloadPatterns

public void readloadPatterns()
Reloads all the patterns from the ban-patterns.conf file


getKickPatterns

public Vector getKickPatterns()
Gets all kickpatterns in a new Vector.

Returns:
all petterns in a cloned Vector.

addSurvailanceController

public void addSurvailanceController(SurvailanceController survailanceController)
Adds a SurvailanceController.

Parameters:
survailanceController -

removeSurvailanceController

public void removeSurvailanceController(SurvailanceController survailanceController)
Removes a SurvailanceController

Parameters:
survailanceController -

start

public void start()
Starts the survailance of clients.


stop

public void stop()
Stops the survailance of clients.


isStarted

public boolean isStarted()
Is Survailance turned on

Returns:

FTP-Server API