Package org.apache.sshd.scp.common
Class ScpHelper
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.scp.common.ScpHelper
- All Implemented Interfaces:
SessionContextHolder
,SessionHolder<Session>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Charset
protected final Charset
static final int
Default size (in bytes) of send / receive buffer sizestatic final int
static final int
protected final FileSystem
protected final InputStream
protected final ScpTransferEventListener
static final int
The minimum size for sending / receiving filesstatic final int
static final int
protected final ScpFileOpener
protected final OutputStream
static final String
Command prefix used to identify SCP commandsprivate final Session
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
ConstructorsConstructorDescriptionScpHelper
(Session session, InputStream in, OutputStream out, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener) ScpHelper
(Session session, InputStream in, Charset csIn, OutputStream out, Charset csOut, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener) -
Method Summary
Modifier and TypeMethodDescriptionreadAck
(boolean canEof) readLine()
readLine
(boolean canEof) void
receive
(String cmd, Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) protected void
receive
(String cmd, ScpReceiveLineHandler handler) Reads command line(s) and invokes the handler until EOF or and "E" command is receivedvoid
receiveDir
(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) void
receiveFile
(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) void
receiveFileStream
(String command, OutputStream local, int bufferSize) protected ScpAckInfo
void
receiveStream
(String header, ScpTargetStreamResolver resolver, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) resolveLocalPath
(String commandPath) resolveLocalPath
(String basedir, String subpath) protected void
send
(Path local, boolean recursive, boolean preserve, int bufferSize, LinkOption... options) void
send
(Collection<String> paths, boolean recursive, boolean preserve, int bufferSize) protected ScpAckInfo
void
protected void
void
void
sendOk()
void
sendPaths
(Collection<? extends Path> paths, boolean recursive, boolean preserve, int bufferSize) protected void
sendResponseMessage
(int level, String message) void
sendStream
(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) protected void
sendWarning
(String message) toString()
protected void
validateAckReplyCode
(String command, Object location, ScpAckInfo ackInfo) protected void
validateCommandStatusCode
(String command, Object location, ScpAckInfo ackInfo, boolean eofAllowed) protected void
validateFileOperationAckReplyCode
(String command, Session session, ScpTransferEventListener.FileOperation op, Path file, long fileSize, Set<PosixFilePermission> perms, ScpAckInfo ackInfo) protected void
validateOperationReadyCode
(String command, Object location, ScpAckInfo ackInfo) 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 Details
-
SCP_COMMAND_PREFIX
Command prefix used to identify SCP commands- See Also:
-
DEFAULT_COPY_BUFFER_SIZE
public static final int DEFAULT_COPY_BUFFER_SIZEDefault size (in bytes) of send / receive buffer size- See Also:
-
DEFAULT_RECEIVE_BUFFER_SIZE
public static final int DEFAULT_RECEIVE_BUFFER_SIZE- See Also:
-
DEFAULT_SEND_BUFFER_SIZE
public static final int DEFAULT_SEND_BUFFER_SIZE- See Also:
-
MIN_COPY_BUFFER_SIZE
public static final int MIN_COPY_BUFFER_SIZEThe minimum size for sending / receiving files- See Also:
-
MIN_RECEIVE_BUFFER_SIZE
public static final int MIN_RECEIVE_BUFFER_SIZE- See Also:
-
MIN_SEND_BUFFER_SIZE
public static final int MIN_SEND_BUFFER_SIZE- See Also:
-
in
-
csIn
-
out
-
csOut
-
fileSystem
-
opener
-
listener
-
sessionInstance
-
-
Constructor Details
-
ScpHelper
public ScpHelper(Session session, InputStream in, OutputStream out, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener) -
ScpHelper
public ScpHelper(Session session, InputStream in, Charset csIn, OutputStream out, Charset csOut, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
-
-
Method Details
-
getSession
- Specified by:
getSession
in interfaceSessionHolder<Session>
-
receiveFileStream
public void receiveFileStream(String command, OutputStream local, int bufferSize) throws IOException - Throws:
IOException
-
receive
public void receive(String cmd, Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
receive
Reads command line(s) and invokes the handler until EOF or and "E" command is received- Parameters:
cmd
- The receive command being attemptedhandler
- TheScpReceiveLineHandler
to invoke when a command has been read- Throws:
IOException
- If failed to read/write
-
receiveNextCmd
- Throws:
IOException
-
receiveDir
public void receiveDir(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
receiveFile
public void receiveFile(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
receiveStream
public void receiveStream(String header, ScpTargetStreamResolver resolver, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
readLine
- Throws:
IOException
-
readLine
- Throws:
IOException
-
send
public void send(Collection<String> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
sendPaths
public void sendPaths(Collection<? extends Path> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
send
protected void send(Path local, boolean recursive, boolean preserve, int bufferSize, LinkOption... options) throws IOException - Throws:
IOException
-
resolveLocalPath
- Throws:
IOException
-
resolveLocalPath
- Parameters:
commandPath
- The command path using the local file separator- Returns:
- The resolved absolute and normalized local
Path
- Throws:
IOException
- If failed to resolve the pathInvalidPathException
- If invalid local path value
-
sendFile
- Throws:
IOException
-
sendStream
public void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws IOException - Throws:
IOException
-
validateOperationReadyCode
protected void validateOperationReadyCode(String command, Object location, ScpAckInfo ackInfo) throws IOException - Throws:
IOException
-
validateFileOperationAckReplyCode
protected void validateFileOperationAckReplyCode(String command, Session session, ScpTransferEventListener.FileOperation op, Path file, long fileSize, Set<PosixFilePermission> perms, ScpAckInfo ackInfo) throws IOException - Throws:
IOException
-
validateAckReplyCode
protected void validateAckReplyCode(String command, Object location, ScpAckInfo ackInfo) throws IOException - Throws:
IOException
-
validateCommandStatusCode
protected void validateCommandStatusCode(String command, Object location, ScpAckInfo ackInfo, boolean eofAllowed) throws IOException - Throws:
IOException
-
sendDir
- Throws:
IOException
-
sendAcknowledgedCommand
- Throws:
IOException
-
sendOk
- Throws:
IOException
-
sendWarning
- Throws:
IOException
-
sendError
- Throws:
IOException
-
sendResponseMessage
- Throws:
IOException
-
readAck
- Throws:
IOException
-
toString
-