Package org.apache.ftpserver.ftplet
Interface FtpSession
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.- Author:
- Apache MINA Project
-
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Returns the value of the named attribute as an Object.Returns the IP address of the client that sent the request.Retrieve the certificates for the client, if running over SSL and with client authenticationGet connection time.Get FTP data connection factory, used to transfer data to and from the client.Get the data type.intGet the number of failed logins.longGet file upload/download offset.Get user file system view.Get the requested language.Get last access time.Get the login time.intReturns maximum idle time.Get rename from file object.Returns the IP address of the serverGet the unique ID for this session.Get structure.getUser()Get user object.Returns user name entered in USER commandbooleanIs the user logged in?booleanisSecure()Indicates whether the control socket for this session is secure, that is, running over SSL/TLSvoidremoveAttribute(String name) Removes an attribute from this request.voidsetAttribute(String name, Object value) Stores an attribute in this request.voidsetMaxIdleTime(int maxIdleTimeSec) Set maximum idle time in seconds.voidWrite a reply to the client
-
Method Details
-
getClientAddress
InetSocketAddress getClientAddress()Returns the IP address of the client that sent the request.- Returns:
- The client
InetAddress
-
getServerAddress
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
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
Date getConnectionTime()Get connection time.- Returns:
- Time when the client connected to the server
-
getLoginTime
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
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 toUser.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 toUser.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
String getUserArgument()Returns user name entered in USER command- Returns:
- user name entered in USER command
-
getLanguage
String getLanguage()Get the requested language.- Returns:
- The language requested by the client
-
isLoggedIn
boolean isLoggedIn()Is the user logged in?- Returns:
trueif the user is logged in
-
getFileSystemView
FileSystemView getFileSystemView()Get user file system view.- Returns:
- The
FileSystemViewfor 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
DataTypefor this session
-
getStructure
Structure getStructure()Get structure.- Returns:
- The current
Structurefor this session
-
getAttribute
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
Stores an attribute in this request. It will be available until it was removed or when the connection ends.- Parameters:
name- The attribute namevalue- The attribute value
-
removeAttribute
Removes an attribute from this request.- Parameters:
name- The attribute name
-
write
Write a reply to the client- Parameters:
reply- The reply that will be sent to the client- Throws:
FtpException- If the write failed
-
isSecure
boolean isSecure()Indicates whether the control socket for this session is secure, that is, running over SSL/TLS- Returns:
trueif the control socket is secured
-
getSessionId
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
-