Top Fields Constructors Methods
org.apache.sshd.scp.common

public Class ScpHelper

extends AbstractLoggingBean
implements SessionHolder<Session>
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.session.SessionHolder, org.apache.sshd.common.session.SessionContextHolder
Imports
java.io.EOFException, .File, .IOException, .InputStream, .OutputStream, .StreamCorruptedException, java.nio.charset.Charset, java.nio.file.DirectoryStream, .FileSystem, .InvalidPathException, .LinkOption, .OpenOption, .Path, java.nio.file.attribute.BasicFileAttributes, .FileTime, .PosixFilePermission, java.util.Collection, .EnumSet, .Objects, .Set, org.apache.sshd.common.file.util.MockPath, org.apache.sshd.common.session.Session, .SessionHolder, org.apache.sshd.common.util.GenericUtils, org.apache.sshd.common.util.io.IoUtils, org.apache.sshd.common.util.io.input.LimitInputStream, org.apache.sshd.common.util.logging.AbstractLoggingBean, org.apache.sshd.scp.ScpModuleProperties, org.apache.sshd.scp.common.ScpTransferEventListener.FileOperation, org.apache.sshd.scp.common.helpers.DefaultScpFileOpener, .ScpAckInfo, .ScpDirEndCommandDetails, .ScpIoUtils, .ScpPathCommandDetailsSupport, .ScpReceiveDirCommandDetails, .ScpReceiveFileCommandDetails, .ScpTimestampCommandDetails

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
protected final Charset
protected final Charset
public static final int
DEFAULT_COPY_BUFFER_SIZE

Default size (in bytes) of send / receive buffer size

public static final int
public static final int
protected final FileSystem
protected final InputStream
protected final ScpTransferEventListener
public static final int
MIN_COPY_BUFFER_SIZE

The minimum size for sending / receiving files

public static final int
public static final int
protected final ScpFileOpener
protected final OutputStream
public static final String
SCP_COMMAND_PREFIX

Command prefix used to identify SCP commands

private final Session
Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
log

Constructor Summary

AccessConstructor and Description
public
ScpHelper(Session session, InputStream in, OutputStream out, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)

public
ScpHelper(Session session, InputStream in, Charset csIn, OutputStream out, Charset csOut, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)

Method Summary

Modifier and TypeMethod and Description
public Session
public ScpAckInfo
readAck(boolean canEof)

public void
public String
public String
readLine(boolean canEof)

public void
receive(String cmd, Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize)

protected void
receive(String
The receive command being attempted
cmd
,
ScpReceiveLineHandler
The ScpReceiveLineHandler to invoke when a command has been read
handler
)

Reads command line(s) and invokes the handler until EOF or and "E" command is received

public void
receiveDir(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize)

public void
receiveFile(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize)

public void
receiveFileStream(String command, OutputStream local, int bufferSize)

protected ScpAckInfo
public void
receiveStream(String header, ScpTargetStreamResolver resolver, ScpTimestampCommandDetails time, boolean preserve, int bufferSize)

public Path
resolveLocalPath(String basedir, String subpath)

public Path

Returns:

The resolved absolute and normalized local Path
resolveLocalPath
(String
The command path using the local file separator
commandPath
)

public void
send(Collection<String> paths, boolean recursive, boolean preserve, int bufferSize)

protected void
send(Path local, boolean recursive, boolean preserve, int bufferSize, LinkOption... options)

protected ScpAckInfo
public void
sendDir(Path local, boolean preserve, int bufferSize)

protected void
sendError(String message)

public void
sendFile(Path local, boolean preserve, int bufferSize)

public void
public void
sendPaths(Collection<? extends Path> paths, boolean recursive, boolean preserve, int bufferSize)

protected void
sendResponseMessage(int level, String message)

public void
sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize)

protected void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected void
validateAckReplyCode(String command, Object location, ScpAckInfo ackInfo)

protected void
validateCommandStatusCode(String command, Object location, ScpAckInfo ackInfo, boolean eofAllowed)

protected void
protected void
validateOperationReadyCode(String command, Object location, ScpAckInfo ackInfo)

Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
debugdebugdebugdebugdebugerrorerrorerrorerrorerrorgetSimplifiedLoggerinfoinfowarnwarnwarnwarnwarnwarnwarnwarn

Field Detail

csInback to summary
protected final Charset csIn
csOutback to summary
protected final Charset csOut
DEFAULT_COPY_BUFFER_SIZEback to summary
public static final int DEFAULT_COPY_BUFFER_SIZE

Default size (in bytes) of send / receive buffer size

DEFAULT_RECEIVE_BUFFER_SIZEback to summary
public static final int DEFAULT_RECEIVE_BUFFER_SIZE
DEFAULT_SEND_BUFFER_SIZEback to summary
public static final int DEFAULT_SEND_BUFFER_SIZE
fileSystemback to summary
protected final FileSystem fileSystem
inback to summary
protected final InputStream in
listenerback to summary
protected final ScpTransferEventListener listener
MIN_COPY_BUFFER_SIZEback to summary
public static final int MIN_COPY_BUFFER_SIZE

The minimum size for sending / receiving files

MIN_RECEIVE_BUFFER_SIZEback to summary
public static final int MIN_RECEIVE_BUFFER_SIZE
MIN_SEND_BUFFER_SIZEback to summary
public static final int MIN_SEND_BUFFER_SIZE
openerback to summary
protected final ScpFileOpener opener
outback to summary
protected final OutputStream out
SCP_COMMAND_PREFIXback to summary
public static final String SCP_COMMAND_PREFIX

Command prefix used to identify SCP commands

sessionInstanceback to summary
private final Session sessionInstance

Constructor Detail

ScpHelperback to summary
public ScpHelper(Session session, InputStream in, OutputStream out, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
ScpHelperback to summary
public ScpHelper(Session session, InputStream in, Charset csIn, OutputStream out, Charset csOut, FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)

Method Detail

getSessionback to summary
public Session getSession()

Implements org.apache.sshd.common.session.SessionHolder.getSession.

Annotations
@Override
readAckback to summary
public ScpAckInfo readAck(boolean canEof) throws IOException
readAndValidateOperationAckback to summary
public void readAndValidateOperationAck(String cmd, Object location) throws IOException
readLineback to summary
public String readLine() throws IOException
readLineback to summary
public String readLine(boolean canEof) throws IOException
receiveback to summary
public void receive(String cmd, Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) throws IOException
receiveback to summary
protected void receive(String cmd, ScpReceiveLineHandler handler) throws IOException

Reads command line(s) and invokes the handler until EOF or and "E" command is received

Parameters
cmd:String

The receive command being attempted

handler:ScpReceiveLineHandler

The ScpReceiveLineHandler to invoke when a command has been read

Exceptions
IOException:
If failed to read/write
receiveDirback to summary
public void receiveDir(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) throws IOException
receiveFileback to summary
public void receiveFile(String header, Path local, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) throws IOException
receiveFileStreamback to summary
public void receiveFileStream(String command, OutputStream local, int bufferSize) throws IOException
receiveNextCmdback to summary
protected ScpAckInfo receiveNextCmd() throws IOException
receiveStreamback to summary
public void receiveStream(String header, ScpTargetStreamResolver resolver, ScpTimestampCommandDetails time, boolean preserve, int bufferSize) throws IOException
resolveLocalPathback to summary
public Path resolveLocalPath(String basedir, String subpath) throws IOException
resolveLocalPathback to summary
public Path resolveLocalPath(String commandPath) throws IOException, InvalidPathException
Parameters
commandPath:String

The command path using the local file separator

Returns:Path

The resolved absolute and normalized local Path

Exceptions
IOException:
If failed to resolve the path
InvalidPathException:
If invalid local path value
sendback to summary
public void send(Collection<String> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException
sendback to summary
protected void send(Path local, boolean recursive, boolean preserve, int bufferSize, LinkOption... options) throws IOException
sendAcknowledgedCommandback to summary
protected ScpAckInfo sendAcknowledgedCommand(String cmd) throws IOException
sendDirback to summary
public void sendDir(Path local, boolean preserve, int bufferSize) throws IOException
sendErrorback to summary
protected void sendError(String message) throws IOException
sendFileback to summary
public void sendFile(Path local, boolean preserve, int bufferSize) throws IOException
sendOkback to summary
public void sendOk() throws IOException
sendPathsback to summary
public void sendPaths(Collection<? extends Path> paths, boolean recursive, boolean preserve, int bufferSize) throws IOException
sendResponseMessageback to summary
protected void sendResponseMessage(int level, String message) throws IOException
sendStreamback to summary
public void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws IOException
sendWarningback to summary
protected void sendWarning(String message) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
validateAckReplyCodeback to summary
protected void validateAckReplyCode(String command, Object location, ScpAckInfo ackInfo) throws IOException
validateCommandStatusCodeback to summary
protected void validateCommandStatusCode(String command, Object location, ScpAckInfo ackInfo, boolean eofAllowed) throws IOException
validateFileOperationAckReplyCodeback to summary
protected void validateFileOperationAckReplyCode(String command, Session session, ScpTransferEventListener.FileOperation op, Path file, long fileSize, Set<PosixFilePermission> perms, ScpAckInfo ackInfo) throws IOException
validateOperationReadyCodeback to summary
protected void validateOperationReadyCode(String command, Object location, ScpAckInfo ackInfo) throws IOException