org.apache.ftpserver.ftplet
Interface FtpSession

All Known Implementing Classes:
DefaultFtpSession

public interface FtpSession

Defines an client session with the FTP server. The session is born when the client connects and dies when the client disconnects. Ftplet methods will always get the same session for one user and one connection. So the attributes set by setAttribute() will be always available later unless that attribute is removed or the client disconnects.

Version:
$Rev$, $Date$
Author:
The Apache MINA Project (dev@mina.apache.org)

Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of the named attribute as an Object.
 java.net.InetSocketAddress getClientAddress()
          Returns the IP address of the client that sent the request.
 java.security.cert.Certificate[] getClientCertificates()
          Retrieve the certificates for the client, if running over SSL and with client authentication
 java.util.Date getConnectionTime()
          Get connection time.
 DataConnectionFactory getDataConnection()
          Get FTP data connection factory, used to transfer data to and from the client.
 DataType getDataType()
          Get the data type.
 int getFailedLogins()
          Get the number of failed logins.
 long getFileOffset()
          Get file upload/download offset.
 FileSystemView getFileSystemView()
          Get user file system view.
 java.lang.String getLanguage()
          Get the requested language.
 java.util.Date getLastAccessTime()
          Get last access time.
 java.util.Date getLoginTime()
          Get the login time.
 int getMaxIdleTime()
          Returns maximum idle time.
 FtpFile getRenameFrom()
          Get rename from file object.
 java.net.InetSocketAddress getServerAddress()
          Returns the IP address of the server
 java.util.UUID getSessionId()
          Get the unique ID for this session.
 Structure getStructure()
          Get structure.
 User getUser()
          Get user object.
 java.lang.String getUserArgument()
          Returns user name entered in USER command
 boolean isLoggedIn()
          Is the user logged in?
 boolean isSecure()
          Indicates whether the control socket for this session is secure, that is, running over SSL/TLS
 void removeAttribute(java.lang.String name)
          Removes an attribute from this request.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Stores an attribute in this request.
 void setMaxIdleTime(int maxIdleTimeSec)
          Set maximum idle time in seconds.
 void write(FtpReply reply)
          Write a reply to the client
 

Method Detail

getClientAddress

java.net.InetSocketAddress getClientAddress()
Returns the IP address of the client that sent the request.

Returns:
The client InetAddress

getServerAddress

java.net.InetSocketAddress getServerAddress()
Returns the IP address of the server

Returns:
The server InetAddress

getDataConnection

DataConnectionFactory getDataConnection()
Get FTP data connection factory, used to transfer data to and from the client.

Returns:
The DataConnectionFactory

getClientCertificates

java.security.cert.Certificate[] getClientCertificates()
Retrieve the certificates for the client, if running over SSL and with client authentication

Returns:
The Certificate chain, or null if the certificates are not avialble

getConnectionTime

java.util.Date getConnectionTime()
Get connection time.

Returns:
Time when the client connected to the server

getLoginTime

java.util.Date getLoginTime()
Get the login time.

Returns:
Time when the client logged into the server

getFailedLogins

int getFailedLogins()
Get the number of failed logins.

Returns:
The number of failed logins. When login succeeds, this will return 0.

getLastAccessTime

java.util.Date getLastAccessTime()
Get last access time.

Returns:
The last time the session performed any action

getMaxIdleTime

int getMaxIdleTime()
Returns maximum idle time. This time equals to ConnectionManagerImpl#getDefaultIdleSec() until user login, and User.getMaxIdleTime() after user login.

Returns:
The number of seconds the client is allowed to be idle before disconnected.

setMaxIdleTime

void setMaxIdleTime(int maxIdleTimeSec)
Set maximum idle time in seconds. This time equals to ConnectionManagerImpl#getDefaultIdleSec() until user login, and User.getMaxIdleTime() after user login.

Parameters:
maxIdleTimeSec - The number of seconds the client is allowed to be idle before disconnected.

getUser

User getUser()
Get user object.

Returns:
The current User

getUserArgument

java.lang.String getUserArgument()
Returns user name entered in USER command

Returns:
user name entered in USER command

getLanguage

java.lang.String getLanguage()
Get the requested language.

Returns:
The language requested by the client

isLoggedIn

boolean isLoggedIn()
Is the user logged in?

Returns:
true if the user is logged in

getFileSystemView

FileSystemView getFileSystemView()
Get user file system view.

Returns:
The FileSystemView for this session/user

getFileOffset

long getFileOffset()
Get file upload/download offset.

Returns:
The current file transfer offset, or 0 if non is set

getRenameFrom

FtpFile getRenameFrom()
Get rename from file object.

Returns:
The current rename from, or null if non is set

getDataType

DataType getDataType()
Get the data type.

Returns:
The current DataType for this session

getStructure

Structure getStructure()
Get structure.

Returns:
The current Structure for this session

getAttribute

java.lang.Object getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object.

Parameters:
name - The attribute name
Returns:
The attribute value, or null if no attribute of the given name exists.

setAttribute

void setAttribute(java.lang.String name,
                  java.lang.Object value)
Stores an attribute in this request. It will be available until it was removed or when the connection ends.

Parameters:
name - The attribute name
value - The attribute value

removeAttribute

void removeAttribute(java.lang.String name)
Removes an attribute from this request.

Parameters:
name - The attribute name

write

void write(FtpReply reply)
           throws FtpException
Write a reply to the client

Parameters:
reply - The reply that will be sent to the client
Throws:
FtpException

isSecure

boolean isSecure()
Indicates whether the control socket for this session is secure, that is, running over SSL/TLS

Returns:
true if the control socket is secured

getSessionId

java.util.UUID getSessionId()
Get the unique ID for this session. This ID will be maintained for the entire session and is also available to MDC logging using the "session" identifier.

Returns:
The unique ID for this session


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.