Package org.apache.sshd.scp.server
Class ScpShell
-
- All Implemented Interfaces:
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.- Author:
- Apache MINA SSHD Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ScpShell.PathEntry
-
Field Summary
Fields Modifier and Type Field Description protected Path
currentDir
static String
ENV_HOME
The "HOME" environment variablestatic String
ENV_LANG
Key for the language - format "en_US.UTF-8"static String
ENV_PWD
The "PWD" environment variableprotected Charset
envVarsEnodingCharset
protected Path
homeDir
protected ScpTransferEventListener
listener
protected Charset
nameEncodingCharset
protected ScpFileOpener
opener
protected int
receiveBufferSize
protected int
sendBufferSize
static String
STATUS
protected Map<String,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(String[] argv)
protected void
doLs(String cmd, String path, boolean optListAll, boolean optLong, boolean optFullTime)
protected void
doScp(String path, boolean optR, boolean optT, boolean optF, boolean optD, boolean optP)
protected void
echo(String[] argv)
ChannelSession
getServerChannelSession()
protected boolean
handleCommandLine(String command)
protected void
handleUnsupportedCommand(String command, String[] argv)
protected void
ls(String[] argv)
protected List<String[]>
parse(String command)
protected void
prepareEnvironment(Environment environ)
protected void
printenv(String[] argv)
protected void
println(String cmd, Object x, OutputStream out, Charset cs)
protected void
pwd(String[] argv)
protected String
readLine(Reader reader)
protected String
resolveEnvironmentVariable(String varName, Map<String,String> envValues)
void
run()
protected void
scp(String[] argv)
void
setFileSystemFactory(FileSystemFactory factory, SessionContext session)
Sets theFileSystemFactory
used to create theFileSystem
to be used by the sessionprotected void
signalError(String cmd, String errorMsg)
protected void
signalError(String cmd, String errorMsg, Charset cs)
protected void
unset(String[] argv)
protected void
updatePwdEnvVariable(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 String STATUS
- See Also:
- Constant Field Values
-
ENV_PWD
public static final String ENV_PWD
The "PWD" environment variable- See Also:
- Constant Field Values
-
ENV_HOME
public static final String ENV_HOME
The "HOME" environment variable- See Also:
- Constant Field Values
-
ENV_LANG
public static final String ENV_LANG
Key for the language - format "en_US.UTF-8"- See Also:
- Constant Field Values
-
nameEncodingCharset
protected final Charset nameEncodingCharset
-
envVarsEnodingCharset
protected final Charset envVarsEnodingCharset
-
opener
protected final ScpFileOpener opener
-
listener
protected final ScpTransferEventListener listener
-
sendBufferSize
protected final int sendBufferSize
-
receiveBufferSize
protected final int receiveBufferSize
-
currentDir
protected Path currentDir
-
homeDir
protected Path homeDir
-
-
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 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:
IOException
- If failed to resolve/create the file system- See Also:
FileSystemAware.setFileSystem(FileSystem)
-
println
protected void println(String cmd, Object x, OutputStream out, Charset cs)
-
readLine
protected String readLine(Reader reader) throws IOException
- Throws:
IOException
-
handleCommandLine
protected boolean handleCommandLine(String command) throws Exception
- Throws:
Exception
-
prepareEnvironment
protected void prepareEnvironment(Environment environ)
-
handleUnsupportedCommand
protected void handleUnsupportedCommand(String command, String[] argv) throws Exception
- Throws:
Exception
-
resolveEnvironmentVariable
protected String resolveEnvironmentVariable(String varName, Map<String,String> envValues)
-
doScp
protected void doScp(String path, boolean optR, boolean optT, boolean optF, boolean optD, boolean optP) throws Exception
- Throws:
Exception
-
updatePwdEnvVariable
protected void updatePwdEnvVariable(Path pwd)
-
-