net.sf.hermesftp.common
Interface FtpSessionContext

All Known Implementing Classes:
FtpSessionContextImpl

public interface FtpSessionContext

This class servers as a means of transportation for data shared by a single FTP session. Instances of the FtpSessionContextImpl class are passed to each of the commands while executing a FTP command sequence. The command objects read connection settings and other options from the context. In turn data that may concern the general state of the FTP session can be stored in the context.

Author:
Lars Behnke

Method Summary
 boolean authenticate()
           
 void closeSockets()
          Closes all sockets involved in current session.
 java.lang.Object getAttribute(java.lang.String name)
          Returns a sesson attribute.
 java.lang.String getCharset()
          Returns the charset to be used for text output.
 java.io.BufferedReader getClientCmdReader()
          Returns the Reader that is used to read client commands.
 java.io.PrintWriter getClientResponseWriter()
          Returns the writer that is used to respond to client requests.
 java.net.Socket getClientSocket()
          Returns the client communication socket.
 java.util.Date getCreationTime()
          Date/time the session context was created.
 SocketProvider getDataSocketProvider()
          Returns the object that provides the socket that is used for file transfer.
 int getDataType()
          Returns the current data type (ASCII, BINARY, EPBCDIC).
 FtpEventListener getEventListener()
          Returns the instance that listens to session events.
 int getMaxDownloadRate()
          Returns the maximum transfer rate (download stream) in KB/s.
 int getMaxUploadRate()
          Returns the maximum transfer rate (upload stream) in KB/s.
 java.lang.Integer getNextPassivePort()
          Returns the next available port from a user defined list of passive ports.
 java.lang.String getOption(java.lang.String key)
          Returns the value of an server option.
 FtpServerOptions getOptions()
           
 java.lang.String getPassword()
          Gets the user's password.
 int getPermission(java.lang.String path)
          Gets the user's permission on the passed path.
 java.lang.String getRemoteDir()
          Gets the current remote directory.
 java.lang.String getRemoteRelDir()
          Gets the relative path, with respect to the FTP root path.
 java.lang.String getRes(java.lang.String id)
          Returns a named resource from a resource bundle.
 java.util.Map<java.lang.String,java.lang.Long> getSessionStatistics()
          Returns the session statistics.
 int getStorageStructure()
          Returns the storage structure (File, Record).
 int getTransmissionMode()
          Returns the transmission mode (Stream, Block, Compressed).
 java.lang.String getUser()
          Returns the login name of the user.
 UserData getUserData()
          Returns data about the current user.
 UserManager getUserManager()
          Returns the user manager.
 boolean isAuthenticated()
          Checks whether user was successfully authenticated.
 void resetCredentials()
          Resets the user's credentials and unflags the authentication.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets a session attribute.
 void setClientSocket(java.net.Socket clientSocket)
          Sets the client communication socket.
 void setCreationTime(java.util.Date time)
          Date/time the session context was created.
 void setDataSocketProvider(SocketProvider provider)
          Sets the provider that provides the socket that is used in file transfer.
 void setDataType(int dataType)
          Sets the current data type.
 void setPassword(java.lang.String password)
          Sets the user's password.
 void setRemoteDir(java.lang.String remoteDir)
          Sets the remote directory of the user's session.
 void setStorageStructure(int struct)
          Sets the storage structure (File, Record).
 void setTransmissionMode(int mode)
          Sets the transmission mode (Stream, Block, Compressed).
 void setUser(java.lang.String user)
          Sets the login name of the user.
 void updateAverageStat(java.lang.String avgKey, int value)
          Updates the upload/download transfer rate taking the passed value into account.
 void updateIncrementalStat(java.lang.String countKey, long value)
          Updates incremental statistics such as number of files downloaded, bytes transferred etc.
 

Method Detail

getAttribute

java.lang.Object getAttribute(java.lang.String name)
Returns a sesson attribute.

Parameters:
name - Name of the attribute.
Returns:
Value of the attribute.

setAttribute

void setAttribute(java.lang.String name,
                  java.lang.Object value)
Sets a session attribute.

Parameters:
name - Name of the attribute.
value - Value of the attribute.

getOptions

FtpServerOptions getOptions()
Returns:
The static server options as read from the configuration file.

getOption

java.lang.String getOption(java.lang.String key)
Returns the value of an server option.

Parameters:
key - The option name.
Returns:
The value.

getPassword

java.lang.String getPassword()
Gets the user's password.

Returns:
The user's password.

setPassword

void setPassword(java.lang.String password)
Sets the user's password.

Parameters:
password - The users password.

getRemoteDir

java.lang.String getRemoteDir()
Gets the current remote directory.

Returns:
The remote directory.

getRemoteRelDir

java.lang.String getRemoteRelDir()
Gets the relative path, with respect to the FTP root path.

Returns:
The path.

setRemoteDir

void setRemoteDir(java.lang.String remoteDir)
Sets the remote directory of the user's session.

Parameters:
remoteDir - The directory to set.

getUser

java.lang.String getUser()
Returns the login name of the user.

Returns:
The name.

setUser

void setUser(java.lang.String user)
Sets the login name of the user.

Parameters:
user - The user name.

getEventListener

FtpEventListener getEventListener()
Returns the instance that listens to session events.

Returns:
The session listener.

getRes

java.lang.String getRes(java.lang.String id)
Returns a named resource from a resource bundle.

Parameters:
id - The name of the resource.
Returns:
The resource.

isAuthenticated

boolean isAuthenticated()
Checks whether user was successfully authenticated.

Returns:
True, user is authenticated.

getDataType

int getDataType()
Returns the current data type (ASCII, BINARY, EPBCDIC).

Returns:
The data type.

setDataType

void setDataType(int dataType)
Sets the current data type.

Parameters:
dataType - The data type.

getTransmissionMode

int getTransmissionMode()
Returns the transmission mode (Stream, Block, Compressed).

Returns:
The transmission mode.

setTransmissionMode

void setTransmissionMode(int mode)
Sets the transmission mode (Stream, Block, Compressed).

Parameters:
mode - The transmission mode.

getStorageStructure

int getStorageStructure()
Returns the storage structure (File, Record).

Returns:
The storage structure.

setStorageStructure

void setStorageStructure(int struct)
Sets the storage structure (File, Record).

Parameters:
struct - The storage structure..

getDataSocketProvider

SocketProvider getDataSocketProvider()
Returns the object that provides the socket that is used for file transfer.

Returns:
The socket provider.

setDataSocketProvider

void setDataSocketProvider(SocketProvider provider)
Sets the provider that provides the socket that is used in file transfer.

Parameters:
provider - The socket provider.

getClientSocket

java.net.Socket getClientSocket()
Returns the client communication socket.

Returns:
The socket.

setClientSocket

void setClientSocket(java.net.Socket clientSocket)
                     throws java.io.IOException
Sets the client communication socket.

Parameters:
clientSocket - The socket.
Throws:
java.io.IOException - Thrown if socket is invalid.

getClientResponseWriter

java.io.PrintWriter getClientResponseWriter()
Returns the writer that is used to respond to client requests.

Returns:
Response writer.

getClientCmdReader

java.io.BufferedReader getClientCmdReader()
Returns the Reader that is used to read client commands.

Returns:
The reader.

getPermission

int getPermission(java.lang.String path)
Gets the user's permission on the passed path.

Parameters:
path - The path to check the permission on.
Returns:
The permission value.

getUserManager

UserManager getUserManager()
Returns the user manager.

Returns:
The user manager.

getCharset

java.lang.String getCharset()
Returns the charset to be used for text output.

Returns:
The name of the charset.

getNextPassivePort

java.lang.Integer getNextPassivePort()
Returns the next available port from a user defined list of passive ports. If no port list was configured, 0 is returned. The port 0 makes a the system decide which port to use.

Returns:
The port for passive data transfer.

authenticate

boolean authenticate()
Returns:
True, if successful.

getUserData

UserData getUserData()
Returns data about the current user.

Returns:
The user data.

resetCredentials

void resetCredentials()
Resets the user's credentials and unflags the authentication.


closeSockets

void closeSockets()
Closes all sockets involved in current session.


setCreationTime

void setCreationTime(java.util.Date time)
Date/time the session context was created.

Parameters:
time - The creation time.

getCreationTime

java.util.Date getCreationTime()
Date/time the session context was created.

Returns:
The creation time.

getSessionStatistics

java.util.Map<java.lang.String,java.lang.Long> getSessionStatistics()
Returns the session statistics.

Returns:
The statistics.

updateIncrementalStat

void updateIncrementalStat(java.lang.String countKey,
                           long value)
                           throws FtpQuotaException
Updates incremental statistics such as number of files downloaded, bytes transferred etc.

Parameters:
countKey - Name of the statistics.
value - Value.
Throws:
FtpQuotaException - Thrown if a limit has been exceeded.

updateAverageStat

void updateAverageStat(java.lang.String avgKey,
                       int value)
Updates the upload/download transfer rate taking the passed value into account.

Parameters:
avgKey - The name of the statistic.
value - The value

getMaxDownloadRate

int getMaxDownloadRate()
Returns the maximum transfer rate (download stream) in KB/s.

Returns:
The rate.

getMaxUploadRate

int getMaxUploadRate()
Returns the maximum transfer rate (upload stream) in KB/s.

Returns:
The rate.


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