public class FtpServerChannel extends Thread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected InetAddress |
m_ClientHost |
protected BufferedReader |
m_CommandLineInput
The Commandline input.
|
protected InputStream |
m_ControlIn
The control input.
|
protected OutputStream |
m_ControlOut
The control output.
|
protected Socket |
m_ControlSocket
The Control socket for commands.
|
protected int |
m_ControlSocketTimeout
The default timeout for the channel socket.
|
protected PrintWriter |
m_ControlWriter
PrintWriter
|
protected FtpSocketFactory |
m_FtpSocketFactory
My socket factory.
|
protected boolean |
m_ReachedMaximumConnections
Determined in FtpServer whether maximum number of connections
has been reached.
|
protected String |
m_ReplyToken
Token set by a command used in a sendAnswer reply.
|
protected String |
m_Username
Name of user.
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
FtpServerChannel(FtpServer server,
Socket controlSocket,
int key,
String threadName,
boolean reachedMaximumConnections)
The Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeConnection()
Close outputstream, inputStream, and all sockets setting the
member variables to null.
|
protected FtpSocketFactory |
createFtpSocketFactory(InetAddress localhost,
int localControlPort,
InetAddress clientHost,
int clientControlPort)
Creates a socket factory with the InetAddresses as given and the
ports minus 1.
|
void |
disconnect()
Disconnects this Channel.
|
int |
getChannelKey()
Gets the channel key given at instantiation.
|
protected String |
getCommandLine()
Gets the commandline input.
|
Socket |
getControlSocket()
Gets the active socket.
|
int |
getControlSocketTimeout()
Gets control socket timeout.
|
protected FdkSession |
getFdkSession() |
FtpServer |
getFtpServer()
Gets the FtpServer that started this Channel.
|
FtpSession |
getFtpSession()
Gets the FtpSession associated with this Channel.
|
FtpSocketFactory |
getFtpSocketFactory()
Gets the SocketFactory associated with this Channel.
|
String |
getReplyToken()
Gets the reply token.
|
String |
getUsername()
Gets the username for the channel.
|
protected void |
handleCommandThrowable(Throwable e,
String cmdKey)
Handles a Throwable while invoking command.
|
protected void |
handleFtpException(FtpException e,
String cmdKey)
Handles an exception while invoking command.
|
protected void |
handleInterruptedIOException()
Handles an InterruptedIOException in the command loop.
|
protected void |
handleThrowable()
Handles a Throwable in the command loop.
|
boolean |
isSameClientHost(InetAddress addr)
Checks whether the IP address is the same as the FTP client machine.
|
String |
logUser()
Gets the username for the channel for logging.
|
void |
run()
Runs thread.
|
protected boolean |
satisfiesPolicy(String cmd,
String args) |
void |
sendAnswer(String answer)
Convenience method for sending a String answer.
|
void |
setControlSocketTimeout(int timeout)
Sets timeout of control socket.
|
void |
setFtpSession(FtpSession ftpSession)
Sets the FtpSession associated with this Channel.
|
void |
setReplyToken(String msg)
Sets reply token.
|
void |
setShouldContinue(boolean shouldContinue)
Set the boolean whether this thread should continue to receive commands.
|
protected void |
setupIO()
Create the Reader and Writer associated with this Channel.
|
void |
setUsername(String username)
Sets the username for the channel.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected FtpSocketFactory m_FtpSocketFactory
protected Socket m_ControlSocket
protected int m_ControlSocketTimeout
protected InputStream m_ControlIn
protected OutputStream m_ControlOut
protected BufferedReader m_CommandLineInput
protected PrintWriter m_ControlWriter
protected String m_Username
protected String m_ReplyToken
protected boolean m_ReachedMaximumConnections
protected InetAddress m_ClientHost
public void run()
public void setReplyToken(String msg)
public String getReplyToken()
public int getChannelKey()
public FtpServer getFtpServer()
public FtpSession getFtpSession()
public void setFtpSession(FtpSession ftpSession)
public String getUsername()
public String logUser()
public void setUsername(String username)
username
- name of userpublic void setShouldContinue(boolean shouldContinue)
public void sendAnswer(String answer)
answer
- reply stringprotected void handleInterruptedIOException()
protected void handleThrowable()
protected void handleFtpException(FtpException e, String cmdKey)
e
- the exception objectcmdKey
- the command keyprotected void handleCommandThrowable(Throwable e, String cmdKey)
e
- the exception objectcmdKey
- the command keyprotected void setupIO() throws IOException
IOException
public void setControlSocketTimeout(int timeout)
public int getControlSocketTimeout()
public Socket getControlSocket()
public FtpSocketFactory getFtpSocketFactory()
protected FtpSocketFactory createFtpSocketFactory(InetAddress localhost, int localControlPort, InetAddress clientHost, int clientControlPort)
protected String getCommandLine() throws FtpException, Exception
FtpException
Exception
public void disconnect()
protected void closeConnection()
protected FdkSession getFdkSession()
public boolean isSameClientHost(InetAddress addr)
Copyright © 2023. All rights reserved.