Package org.apache.sshd.scp.server
Class ScpShell
- 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 ScpShell extends AbstractFileSystemCommand implements ServerChannelSessionHolder
This command provides SCP support for a ChannelSession.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classScpShell.PathEntry
-
Field Summary
Fields Modifier and Type Field Description private ChannelSessionchannelSessionprotected java.nio.file.PathcurrentDirstatic java.lang.StringENV_HOMEThe "HOME" environment variablestatic java.lang.StringENV_LANGKey for the language - format "en_US.UTF-8"static java.lang.StringENV_PWDThe "PWD" environment variableprotected java.nio.charset.CharsetenvVarsEnodingCharsetprotected java.nio.file.PathhomeDirprotected ScpTransferEventListenerlistenerprivate static intLS_ALLprivate static intLS_DIR_PLAINprivate static intLS_FULL_TIMEprivate static intLS_LONGprotected java.nio.charset.CharsetnameEncodingCharsetprotected ScpFileOpeneropenerprotected intreceiveBufferSizeprivate static intSCP_Dprivate static intSCP_Fprivate static intSCP_Pprivate static intSCP_Rprivate static intSCP_Tprotected intsendBufferSizestatic java.lang.StringSTATUSprotected java.util.Map<java.lang.String,java.lang.Object>variables-
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 ScpShell(ChannelSession channelSession, CloseableExecutorService executorService, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcd(java.lang.String[] argv)protected voiddoLs(java.lang.String cmd, java.lang.String path, int options)protected voiddoScp(java.lang.String command, java.lang.String path, int options)protected voidecho(java.lang.String[] argv)ChannelSessiongetServerChannelSession()protected booleanhandleCommandLine(java.lang.String command)protected voidhandleUnsupportedCommand(java.lang.String command, java.lang.String[] argv)protected voidls(java.lang.String[] argv)protected java.util.List<java.lang.String[]>parse(java.lang.String command)protected voidprepareEnvironment(Environment environ)protected voidprintenv(java.lang.String[] argv)protected voidprintln(java.lang.String cmd, java.lang.Object x, java.io.OutputStream out, java.nio.charset.Charset cs)protected voidpwd(java.lang.String[] argv)protected java.lang.StringreadLine(java.io.Reader reader)protected java.lang.StringresolveEnvironmentVariable(java.lang.String varName, java.util.Map<java.lang.String,java.lang.String> envValues)voidrun()protected voidscp(java.lang.String command, java.lang.String[] argv)voidsetFileSystemFactory(FileSystemFactory factory, SessionContext session)Sets theFileSystemFactoryused to create theFileSystemto be used by the sessionprotected voidsignalError(java.lang.String cmd, java.lang.String errorMsg)protected voidsignalError(java.lang.String cmd, java.lang.String errorMsg, java.nio.charset.Charset cs)private java.lang.StringtoScpPath(java.lang.String winScpPath)protected voidunset(java.lang.String[] argv)protected voidupdatePwdEnvVariable(java.nio.file.Path pwd)-
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, start, toString
-
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.session.SessionHolder
getSessionContext
-
-
-
-
Field Detail
-
STATUS
public static final java.lang.String STATUS
- See Also:
- Constant Field Values
-
ENV_PWD
public static final java.lang.String ENV_PWD
The "PWD" environment variable- See Also:
- Constant Field Values
-
ENV_HOME
public static final java.lang.String ENV_HOME
The "HOME" environment variable- See Also:
- Constant Field Values
-
ENV_LANG
public static final java.lang.String ENV_LANG
Key for the language - format "en_US.UTF-8"- See Also:
- Constant Field Values
-
LS_ALL
private static final int LS_ALL
- See Also:
- Constant Field Values
-
LS_DIR_PLAIN
private static final int LS_DIR_PLAIN
- See Also:
- Constant Field Values
-
LS_LONG
private static final int LS_LONG
- See Also:
- Constant Field Values
-
LS_FULL_TIME
private static final int LS_FULL_TIME
- See Also:
- Constant Field Values
-
SCP_D
private static final int SCP_D
- See Also:
- Constant Field Values
-
SCP_F
private static final int SCP_F
- See Also:
- Constant Field Values
-
SCP_P
private static final int SCP_P
- See Also:
- Constant Field Values
-
SCP_R
private static final int SCP_R
- See Also:
- Constant Field Values
-
SCP_T
private static final int SCP_T
- See Also:
- Constant Field Values
-
variables
protected final java.util.Map<java.lang.String,java.lang.Object> variables
-
nameEncodingCharset
protected final java.nio.charset.Charset nameEncodingCharset
-
envVarsEnodingCharset
protected final java.nio.charset.Charset envVarsEnodingCharset
-
opener
protected final ScpFileOpener opener
-
listener
protected final ScpTransferEventListener listener
-
sendBufferSize
protected final int sendBufferSize
-
receiveBufferSize
protected final int receiveBufferSize
-
currentDir
protected java.nio.file.Path currentDir
-
homeDir
protected java.nio.file.Path homeDir
-
channelSession
private final ChannelSession channelSession
-
-
Constructor Detail
-
ScpShell
public ScpShell(ChannelSession channelSession, CloseableExecutorService executorService, int sendSize, int receiveSize, ScpFileOpener fileOpener, ScpTransferEventListener eventListener)
-
-
Method Detail
-
getServerChannelSession
public ChannelSession getServerChannelSession()
- Specified by:
getServerChannelSessionin interfaceServerChannelSessionHolder
-
setFileSystemFactory
public void setFileSystemFactory(FileSystemFactory factory, SessionContext session) throws java.io.IOException
Description copied from interface:FileSystemAwareSets theFileSystemFactoryused to create theFileSystemto be used by the session- Specified by:
setFileSystemFactoryin interfaceFileSystemAware- Parameters:
factory- The factory instancesession- TheSessionContext- Throws:
java.io.IOException- If failed to resolve/create the file system- See Also:
FileSystemAware.setFileSystem(FileSystem)
-
println
protected void println(java.lang.String cmd, java.lang.Object x, java.io.OutputStream out, java.nio.charset.Charset cs)
-
signalError
protected void signalError(java.lang.String cmd, java.lang.String errorMsg)
-
signalError
protected void signalError(java.lang.String cmd, java.lang.String errorMsg, java.nio.charset.Charset cs)
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
readLine
protected java.lang.String readLine(java.io.Reader reader) throws java.io.IOException- Throws:
java.io.IOException
-
handleCommandLine
protected boolean handleCommandLine(java.lang.String command) throws java.lang.Exception- Throws:
java.lang.Exception
-
prepareEnvironment
protected void prepareEnvironment(Environment environ)
-
handleUnsupportedCommand
protected void handleUnsupportedCommand(java.lang.String command, java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
parse
protected java.util.List<java.lang.String[]> parse(java.lang.String command)
-
printenv
protected void printenv(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
resolveEnvironmentVariable
protected java.lang.String resolveEnvironmentVariable(java.lang.String varName, java.util.Map<java.lang.String,java.lang.String> envValues)
-
unset
protected void unset(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
scp
protected void scp(java.lang.String command, java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
doScp
protected void doScp(java.lang.String command, java.lang.String path, int options) throws java.lang.Exception- Throws:
java.lang.Exception
-
echo
protected void echo(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
pwd
protected void pwd(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
toScpPath
private java.lang.String toScpPath(java.lang.String winScpPath)
-
cd
protected void cd(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
updatePwdEnvVariable
protected void updatePwdEnvVariable(java.nio.file.Path pwd)
-
ls
protected void ls(java.lang.String[] argv) throws java.lang.Exception- Throws:
java.lang.Exception
-
doLs
protected void doLs(java.lang.String cmd, java.lang.String path, int options) throws java.lang.Exception- Throws:
java.lang.Exception
-
-