Package org.apache.sshd.scp.server
Class ScpCommand
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Runnable,FileSystemAware,SessionContextHolder,SessionHolder<ServerSession>,ExecutorServiceCarrier,ServerChannelSessionHolder,Command,CommandDirectErrorStreamAware,CommandDirectInputStreamAware,CommandDirectOutputStreamAware,CommandDirectStreamsAware,CommandLifecycle,ServerSessionAware,ServerSessionHolder
public class ScpCommand extends AbstractFileSystemCommand implements ServerChannelSessionHolder
This commands provide SCP support on both server and client side. Permissions and preservation of access / modification times on files are not supported.
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelSessionchannelSessionprotected java.io.IOExceptionerrorprotected ScpTransferEventListenerlistenerprotected ScpFileOpeneropenerprotected booleanoptDprotected booleanoptFprotected booleanoptPprotected booleanoptRprotected booleanoptTprotected java.lang.Stringpathprotected intreceiveBufferSizeprotected intsendBufferSize-
Fields inherited from class org.apache.sshd.server.command.AbstractFileSystemCommand
fileSystem
-
Fields inherited from class org.apache.sshd.server.command.AbstractCommandSupport
cbCalled, cmdRunner, executorService
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ScpCommand(ChannelSession channelSession, java.lang.String command, CloseableExecutorService executorService, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelSessiongetServerChannelSession()voidrun()voidstart(ChannelSession channel, Environment env)Starts the command execution.java.lang.StringtoString()protected voidwriteCommandResponseMessage(java.lang.String command, int exitValue, java.lang.String exitMessage)-
Methods inherited from class org.apache.sshd.server.command.AbstractFileSystemCommand
destroy, getFileSystem, setFileSystem
-
Methods inherited from class org.apache.sshd.server.command.AbstractCommandSupport
getCommand, getEnvironment, getErrorStream, getExecutorService, getExitCallback, getInputStream, getOutputStream, getServerSession, getSession, getStartedCommandFuture, onExit, onExit, setErrorStream, setExitCallback, setInputStream, setOutputStream, setSession
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.file.FileSystemAware
setFileSystemFactory
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
-
-
-
Field Detail
-
sendBufferSize
protected final int sendBufferSize
-
receiveBufferSize
protected final int receiveBufferSize
-
opener
protected final ScpFileOpener opener
-
optR
protected boolean optR
-
optT
protected boolean optT
-
optF
protected boolean optF
-
optD
protected boolean optD
-
optP
protected boolean optP
-
path
protected java.lang.String path
-
error
protected java.io.IOException error
-
listener
protected ScpTransferEventListener listener
-
channelSession
private final ChannelSession channelSession
-
-
Constructor Detail
-
ScpCommand
public ScpCommand(ChannelSession channelSession, java.lang.String command, CloseableExecutorService executorService, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
- Parameters:
channelSession- TheChannelSessionthrough which the command was receivedcommand- The command to be executedexecutorService- AnCloseableExecutorServiceto be used whenstart(ChannelSession, Environment)-ing execution. Ifnullan ad-hoc single-threaded service is created and used.sendSize- Size (in bytes) of buffer to use when sending filesreceiveSize- Size (in bytes) of buffer to use when receiving filesfileOpener- TheScpFileOpener- ifnullthenDefaultScpFileOpeneris usedeventListener- AnScpTransferEventListener- may benull- See Also:
ThreadUtils.newSingleThreadExecutor(String),ScpHelper.MIN_SEND_BUFFER_SIZE,ScpHelper.MIN_RECEIVE_BUFFER_SIZE
-
-
Method Detail
-
getServerChannelSession
public ChannelSession getServerChannelSession()
- Specified by:
getServerChannelSessionin interfaceServerChannelSessionHolder
-
start
public void start(ChannelSession channel, Environment env) throws java.io.IOException
Description copied from interface:CommandLifecycleStarts the command execution. All streams must have been set before calling this method. The command should implementRunnable, and this method should spawn a new thread like:Thread(this).start();- Specified by:
startin interfaceCommandLifecycle- Overrides:
startin classAbstractCommandSupport- Parameters:
channel- TheChannelSessionthrough which the command has been receivedenv- TheEnvironment- Throws:
java.io.IOException- If failed to start
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
writeCommandResponseMessage
protected void writeCommandResponseMessage(java.lang.String command, int exitValue, java.lang.String exitMessage) throws java.io.IOException- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractCommandSupport
-
-