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 commands SCP support for a ChannelSession.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ScpShell.PathEntry
-
Field Summary
Fields Modifier and Type Field Description private ChannelSession
channelSession
protected java.nio.file.Path
currentDir
static java.lang.String
ENV_HOME
The "HOME" environment variablestatic java.lang.String
ENV_LANG
Key for the language - format "en_US.UTF-8"static java.lang.String
ENV_PWD
The "PWD" environment variableprotected java.nio.charset.Charset
envVarsEnodingCharset
protected java.nio.file.Path
homeDir
protected ScpTransferEventListener
listener
protected java.nio.charset.Charset
nameEncodingCharset
protected ScpFileOpener
opener
protected int
receiveBufferSize
protected int
sendBufferSize
static java.lang.String
STATUS
protected 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 void
cd(java.lang.String[] argv)
protected void
doLs(java.lang.String cmd, java.lang.String path, boolean optListAll, boolean optLong, boolean optFullTime)
protected void
doScp(java.lang.String command, java.lang.String path, boolean optR, boolean optT, boolean optF, boolean optD, boolean optP)
protected void
echo(java.lang.String[] argv)
ChannelSession
getServerChannelSession()
protected boolean
handleCommandLine(java.lang.String command)
protected void
handleUnsupportedCommand(java.lang.String command, java.lang.String[] argv)
protected void
ls(java.lang.String[] argv)
protected java.util.List<java.lang.String[]>
parse(java.lang.String command)
protected void
prepareEnvironment(Environment environ)
protected void
printenv(java.lang.String[] argv)
protected void
println(java.lang.String cmd, java.lang.Object x, java.io.OutputStream out, java.nio.charset.Charset cs)
protected void
pwd(java.lang.String[] argv)
protected java.lang.String
readLine(java.io.Reader reader)
protected java.lang.String
resolveEnvironmentVariable(java.lang.String varName, java.util.Map<java.lang.String,java.lang.String> envValues)
void
run()
protected void
scp(java.lang.String command, java.lang.String[] argv)
void
setFileSystemFactory(FileSystemFactory factory, SessionContext session)
Sets theFileSystemFactory
used to create theFileSystem
to be used by the sessionprotected void
signalError(java.lang.String cmd, java.lang.String errorMsg)
protected void
signalError(java.lang.String cmd, java.lang.String errorMsg, java.nio.charset.Charset cs)
protected void
unset(java.lang.String[] argv)
protected void
updatePwdEnvVariable(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
-
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:
getServerChannelSession
in interfaceServerChannelSessionHolder
-
setFileSystemFactory
public void setFileSystemFactory(FileSystemFactory factory, SessionContext session) throws java.io.IOException
Description copied from interface:FileSystemAware
Sets theFileSystemFactory
used to create theFileSystem
to be used by the session- Specified by:
setFileSystemFactory
in 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:
run
in 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, boolean optR, boolean optT, boolean optF, boolean optD, boolean optP) 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
-
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, boolean optListAll, boolean optLong, boolean optFullTime) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-