Package org.apache.sshd.common.scp
Class ScpHelper
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.scp.ScpHelper
-
- All Implemented Interfaces:
SessionContextHolder,SessionHolder<Session>
public class ScpHelper extends AbstractLoggingBean implements SessionHolder<Session>
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_COPY_BUFFER_SIZEDefault size (in bytes) of send / receive buffer sizestatic java.lang.StringDEFAULT_DIR_OCTAL_PERMISSIONSstatic java.lang.StringDEFAULT_FILE_OCTAL_PERMISSIONSstatic intDEFAULT_RECEIVE_BUFFER_SIZEstatic intDEFAULT_SEND_BUFFER_SIZEstatic intERRORprotected java.nio.file.FileSystemfileSystemprotected java.io.InputStreaminprotected ScpTransferEventListenerlistenerstatic intMIN_COPY_BUFFER_SIZEThe minimum size for sending / receiving filesstatic intMIN_RECEIVE_BUFFER_SIZEstatic intMIN_SEND_BUFFER_SIZEstatic intOKprotected ScpFileOpeneropenerprotected java.io.OutputStreamoutstatic intS_IRGRPstatic intS_IROTHstatic intS_IRUSRstatic intS_IWGRPstatic intS_IWOTHstatic intS_IWUSRstatic intS_IXGRPstatic intS_IXOTHstatic intS_IXUSRstatic java.lang.StringSCP_COMMAND_PREFIXCommand prefix used to identify SCP commandsprivate SessionsessionInstancestatic intWARNING-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ScpHelper(Session session, java.io.InputStream in, java.io.OutputStream out, java.nio.file.FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidack()static java.lang.StringgetExitStatusName(java.lang.Integer exitStatus)static java.lang.StringgetOctalPermissions(java.util.Collection<java.nio.file.attribute.PosixFilePermission> perms)SessiongetSession()static java.util.Set<java.nio.file.attribute.PosixFilePermission>parseOctalPermissions(java.lang.String str)intreadAck(boolean canEof)java.lang.StringreadLine()java.lang.StringreadLine(boolean canEof)voidreceive(java.nio.file.Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize)protected voidreceive(ScpReceiveLineHandler handler)voidreceiveDir(java.lang.String header, java.nio.file.Path local, ScpTimestamp time, boolean preserve, int bufferSize)voidreceiveFile(java.lang.String header, java.nio.file.Path local, ScpTimestamp time, boolean preserve, int bufferSize)voidreceiveFileStream(java.io.OutputStream local, int bufferSize)voidreceiveStream(java.lang.String header, ScpTargetStreamResolver resolver, ScpTimestamp time, boolean preserve, int bufferSize)java.nio.file.PathresolveLocalPath(java.lang.String commandPath)java.nio.file.PathresolveLocalPath(java.lang.String basedir, java.lang.String subpath)protected voidsend(java.nio.file.Path local, boolean recursive, boolean preserve, int bufferSize, java.nio.file.LinkOption... options)voidsend(java.util.Collection<java.lang.String> paths, boolean recursive, boolean preserve, int bufferSize)voidsendDir(java.nio.file.Path local, boolean preserve, int bufferSize)protected voidsendError(java.lang.String message)static <O extends java.io.OutputStream>
OsendError(O out, java.lang.String message)voidsendFile(java.nio.file.Path local, boolean preserve, int bufferSize)voidsendPaths(java.util.Collection<? extends java.nio.file.Path> paths, boolean recursive, boolean preserve, int bufferSize)protected voidsendResponseMessage(int level, java.lang.String message)static <O extends java.io.OutputStream>
OsendResponseMessage(O out, int level, java.lang.String message)voidsendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize)protected voidsendWarning(java.lang.String message)static <O extends java.io.OutputStream>
OsendWarning(O out, java.lang.String message)java.lang.StringtoString()protected voidvalidateAckReplyCode(java.lang.String command, java.lang.Object location, int replyCode, boolean eofAllowed)protected voidvalidateCommandStatusCode(java.lang.String command, java.lang.Object location, int statusCode, boolean eofAllowed)protected voidvalidateOperationReadyCode(java.lang.String command, java.lang.Object location, int readyCode, boolean eofAllowed)-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
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
-
SCP_COMMAND_PREFIX
public static final java.lang.String SCP_COMMAND_PREFIX
Command prefix used to identify SCP commands- See Also:
- Constant Field Values
-
OK
public static final int OK
- See Also:
- Constant Field Values
-
WARNING
public static final int WARNING
- See Also:
- Constant Field Values
-
ERROR
public static final int ERROR
- See Also:
- Constant Field Values
-
DEFAULT_COPY_BUFFER_SIZE
public static final int DEFAULT_COPY_BUFFER_SIZE
Default size (in bytes) of send / receive buffer size- See Also:
- Constant Field Values
-
DEFAULT_RECEIVE_BUFFER_SIZE
public static final int DEFAULT_RECEIVE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_SEND_BUFFER_SIZE
public static final int DEFAULT_SEND_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MIN_COPY_BUFFER_SIZE
public static final int MIN_COPY_BUFFER_SIZE
The minimum size for sending / receiving files- See Also:
- Constant Field Values
-
MIN_RECEIVE_BUFFER_SIZE
public static final int MIN_RECEIVE_BUFFER_SIZE
- See Also:
- Constant Field Values
-
MIN_SEND_BUFFER_SIZE
public static final int MIN_SEND_BUFFER_SIZE
- See Also:
- Constant Field Values
-
S_IRUSR
public static final int S_IRUSR
- See Also:
- Constant Field Values
-
S_IWUSR
public static final int S_IWUSR
- See Also:
- Constant Field Values
-
S_IXUSR
public static final int S_IXUSR
- See Also:
- Constant Field Values
-
S_IRGRP
public static final int S_IRGRP
- See Also:
- Constant Field Values
-
S_IWGRP
public static final int S_IWGRP
- See Also:
- Constant Field Values
-
S_IXGRP
public static final int S_IXGRP
- See Also:
- Constant Field Values
-
S_IROTH
public static final int S_IROTH
- See Also:
- Constant Field Values
-
S_IWOTH
public static final int S_IWOTH
- See Also:
- Constant Field Values
-
S_IXOTH
public static final int S_IXOTH
- See Also:
- Constant Field Values
-
DEFAULT_DIR_OCTAL_PERMISSIONS
public static final java.lang.String DEFAULT_DIR_OCTAL_PERMISSIONS
- See Also:
- Constant Field Values
-
DEFAULT_FILE_OCTAL_PERMISSIONS
public static final java.lang.String DEFAULT_FILE_OCTAL_PERMISSIONS
- See Also:
- Constant Field Values
-
in
protected final java.io.InputStream in
-
out
protected final java.io.OutputStream out
-
fileSystem
protected final java.nio.file.FileSystem fileSystem
-
opener
protected final ScpFileOpener opener
-
listener
protected final ScpTransferEventListener listener
-
sessionInstance
private final Session sessionInstance
-
-
Constructor Detail
-
ScpHelper
public ScpHelper(Session session, java.io.InputStream in, java.io.OutputStream out, java.nio.file.FileSystem fileSystem, ScpFileOpener opener, ScpTransferEventListener eventListener)
-
-
Method Detail
-
getSession
public Session getSession()
- Specified by:
getSessionin interfaceSessionHolder<Session>
-
receiveFileStream
public void receiveFileStream(java.io.OutputStream local, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
receive
public void receive(java.nio.file.Path local, boolean recursive, boolean shouldBeDir, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
receive
protected void receive(ScpReceiveLineHandler handler) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveDir
public void receiveDir(java.lang.String header, java.nio.file.Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
receiveFile
public void receiveFile(java.lang.String header, java.nio.file.Path local, ScpTimestamp time, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
receiveStream
public void receiveStream(java.lang.String header, ScpTargetStreamResolver resolver, ScpTimestamp time, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOException- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine(boolean canEof) throws java.io.IOException- Throws:
java.io.IOException
-
send
public void send(java.util.Collection<java.lang.String> paths, boolean recursive, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
sendPaths
public void sendPaths(java.util.Collection<? extends java.nio.file.Path> paths, boolean recursive, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
send
protected void send(java.nio.file.Path local, boolean recursive, boolean preserve, int bufferSize, java.nio.file.LinkOption... options) throws java.io.IOException- Throws:
java.io.IOException
-
resolveLocalPath
public java.nio.file.Path resolveLocalPath(java.lang.String basedir, java.lang.String subpath) throws java.io.IOException- Throws:
java.io.IOException
-
resolveLocalPath
public java.nio.file.Path resolveLocalPath(java.lang.String commandPath) throws java.io.IOException, java.nio.file.InvalidPathException- Parameters:
commandPath- The command path using the local file separator- Returns:
- The resolved absolute and normalized local
Path - Throws:
java.io.IOException- If failed to resolve the pathjava.nio.file.InvalidPathException- If invalid local path value
-
sendFile
public void sendFile(java.nio.file.Path local, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
sendStream
public void sendStream(ScpSourceStreamResolver resolver, boolean preserve, int bufferSize) throws java.io.IOException
- Throws:
java.io.IOException
-
validateOperationReadyCode
protected void validateOperationReadyCode(java.lang.String command, java.lang.Object location, int readyCode, boolean eofAllowed) throws java.io.IOException- Throws:
java.io.IOException
-
validateAckReplyCode
protected void validateAckReplyCode(java.lang.String command, java.lang.Object location, int replyCode, boolean eofAllowed) throws java.io.IOException- Throws:
java.io.IOException
-
validateCommandStatusCode
protected void validateCommandStatusCode(java.lang.String command, java.lang.Object location, int statusCode, boolean eofAllowed) throws java.io.IOException- Throws:
java.io.IOException
-
sendDir
public void sendDir(java.nio.file.Path local, boolean preserve, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
getOctalPermissions
public static java.lang.String getOctalPermissions(java.util.Collection<java.nio.file.attribute.PosixFilePermission> perms)
-
parseOctalPermissions
public static java.util.Set<java.nio.file.attribute.PosixFilePermission> parseOctalPermissions(java.lang.String str)
-
sendWarning
protected void sendWarning(java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
sendError
protected void sendError(java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
sendResponseMessage
protected void sendResponseMessage(int level, java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
sendWarning
public static <O extends java.io.OutputStream> O sendWarning(O out, java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
sendError
public static <O extends java.io.OutputStream> O sendError(O out, java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
sendResponseMessage
public static <O extends java.io.OutputStream> O sendResponseMessage(O out, int level, java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
getExitStatusName
public static java.lang.String getExitStatusName(java.lang.Integer exitStatus)
-
ack
public void ack() throws java.io.IOException- Throws:
java.io.IOException
-
readAck
public int readAck(boolean canEof) throws java.io.IOException- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-