public abstract class FtpCommand extends Object
| Constructor and Description |
|---|
FtpCommand()
Default Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkLoggedIn(FtpServerChannel channel)
Check with current session is valid.
|
protected void |
denyGuestAccessForWriteableCommands(String cmdKey)
Guest user has read-only privileges.
|
String |
encodeArgument(String arg,
String charset)
Encodes the string that came in through the InputStreamReader
with the given character set.
|
protected abstract void |
execute(FtpServerChannel channel,
String cmdKey,
Argument[] flags,
Argument[] positionals)
Execute the command.
|
protected String |
formatCmdline(String cmdKey,
String cmdline)
For some commands, add quotes around cmdline input.
|
String |
getHomeFolderPath(FdkSession fdksession)
Get the home folder path.
|
protected int[] |
getPotentialArgs()
Gets the argument type a particular flag is expecting.
|
protected String[] |
getPotentialFlags()
Gets the potentials flags that the CommandlineArguments
object might be expecting.
|
protected void |
handleException(FtpServerChannel channel,
Exception exception,
String cmdKey)
Send a generic error message.
|
String |
normalizePath(FtpSession psession,
String path)
Convert to absolute path if not already.
|
void |
run(FtpServerChannel channel,
String cmdKey,
String cmdline)
Run the command.
|
public final void run(FtpServerChannel channel, String cmdKey, String cmdline)
protected String formatCmdline(String cmdKey, String cmdline) throws Exception
Exceptionprotected void denyGuestAccessForWriteableCommands(String cmdKey) throws Exception
Exceptionprotected String[] getPotentialFlags()
protected int[] getPotentialArgs()
protected abstract void execute(FtpServerChannel channel, String cmdKey, Argument[] flags, Argument[] positionals) throws Exception
Exceptionprotected void handleException(FtpServerChannel channel, Exception exception, String cmdKey) throws Exception
channel - the server channelexception - exception objectcmdKey - the command attemptedExceptionprotected void checkLoggedIn(FtpServerChannel channel) throws FtpException
FtpExceptionpublic String getHomeFolderPath(FdkSession fdksession) throws FdkException, Exception
FdkExceptionExceptionpublic String encodeArgument(String arg, String charset) throws Exception
arg - the string to be encodedcharset - the character set to encode the stringExceptionpublic String normalizePath(FtpSession psession, String path) throws FtpException
FtpExceptionCopyright © 2025. All rights reserved.