Package net.schmizz.sshj.sftp
Class SFTPEngine
- java.lang.Object
-
- net.schmizz.sshj.sftp.SFTPEngine
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TIMEOUT_MS
protected org.slf4j.Logger
log
protected LoggerFactory
loggerFactory
Loggerstatic int
MAX_SUPPORTED_VERSION
protected int
operativeVersion
protected java.io.OutputStream
out
protected PathHelper
pathHelper
protected PacketReader
reader
protected long
reqID
protected java.util.Map<java.lang.String,java.lang.String>
serverExtensions
protected Session.Subsystem
sub
protected int
timeoutMs
-
Constructor Summary
Constructors Constructor Description SFTPEngine(SessionFactory ssh)
SFTPEngine(SessionFactory ssh, java.lang.String pathSep)
-
Method Summary
Modifier and Type Method Description java.lang.String
canonicalize(java.lang.String path)
void
close()
protected LoggerFactory
getLoggerFactory()
int
getOperativeProtocolVersion()
PathHelper
getPathHelper()
java.lang.String
getServerExtensionData(java.lang.String extension, java.lang.String domain)
Session.Subsystem
getSubsystem()
int
getTimeoutMs()
SFTPEngine
init()
protected SFTPEngine
init(int requestedVersion)
Introduced for internal use by testcases.FileAttributes
lstat(java.lang.String path)
void
makeDir(java.lang.String path)
void
makeDir(java.lang.String path, FileAttributes attrs)
Request
newExtendedRequest(java.lang.String reqName)
Request
newRequest(PacketType type)
RemoteFile
open(java.lang.String filename)
RemoteFile
open(java.lang.String filename, java.util.Set<OpenMode> modes)
RemoteFile
open(java.lang.String path, java.util.Set<OpenMode> modes, FileAttributes fa)
RemoteDirectory
openDir(java.lang.String path)
java.lang.String
readLink(java.lang.String path)
protected static java.lang.String
readSingleName(Response res)
Using UTF-8protected static java.lang.String
readSingleName(Response res, java.nio.charset.Charset charset)
Using any character setvoid
remove(java.lang.String filename)
void
removeDir(java.lang.String path)
void
rename(java.lang.String oldPath, java.lang.String newPath, java.util.Set<RenameFlags> flags)
Promise<Response,SFTPException>
request(Request req)
void
setAttributes(java.lang.String path, FileAttributes attrs)
void
setTimeoutMs(int timeoutMs)
FileAttributes
stat(java.lang.String path)
protected FileAttributes
stat(PacketType pt, java.lang.String path)
boolean
supportsServerExtension(java.lang.String extension, java.lang.String domain)
void
symlink(java.lang.String linkpath, java.lang.String targetpath)
protected void
transmit(SFTPPacket<Request> payload)
-
-
-
Field Detail
-
MAX_SUPPORTED_VERSION
public static final int MAX_SUPPORTED_VERSION
- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT_MS
public static final int DEFAULT_TIMEOUT_MS
- See Also:
- Constant Field Values
-
loggerFactory
protected final LoggerFactory loggerFactory
Logger
-
log
protected final org.slf4j.Logger log
-
timeoutMs
protected volatile int timeoutMs
-
pathHelper
protected final PathHelper pathHelper
-
sub
protected final Session.Subsystem sub
-
reader
protected final PacketReader reader
-
out
protected final java.io.OutputStream out
-
reqID
protected long reqID
-
operativeVersion
protected int operativeVersion
-
serverExtensions
protected final java.util.Map<java.lang.String,java.lang.String> serverExtensions
-
-
Constructor Detail
-
SFTPEngine
public SFTPEngine(SessionFactory ssh) throws SSHException
- Throws:
SSHException
-
SFTPEngine
public SFTPEngine(SessionFactory ssh, java.lang.String pathSep) throws SSHException
- Throws:
SSHException
-
-
Method Detail
-
init
public SFTPEngine init() throws java.io.IOException
- Throws:
java.io.IOException
-
init
protected SFTPEngine init(int requestedVersion) throws java.io.IOException
Introduced for internal use by testcases.- Parameters:
requestedVersion
-- Throws:
java.io.IOException
-
getSubsystem
public Session.Subsystem getSubsystem()
-
getOperativeProtocolVersion
public int getOperativeProtocolVersion()
-
supportsServerExtension
public boolean supportsServerExtension(java.lang.String extension, java.lang.String domain)
-
getServerExtensionData
public java.lang.String getServerExtensionData(java.lang.String extension, java.lang.String domain)
-
newExtendedRequest
public Request newExtendedRequest(java.lang.String reqName)
-
getPathHelper
public PathHelper getPathHelper()
- Specified by:
getPathHelper
in interfaceRequester
-
newRequest
public Request newRequest(PacketType type)
- Specified by:
newRequest
in interfaceRequester
-
request
public Promise<Response,SFTPException> request(Request req) throws java.io.IOException
-
open
public RemoteFile open(java.lang.String path, java.util.Set<OpenMode> modes, FileAttributes fa) throws java.io.IOException
- Throws:
java.io.IOException
-
open
public RemoteFile open(java.lang.String filename, java.util.Set<OpenMode> modes) throws java.io.IOException
- Throws:
java.io.IOException
-
open
public RemoteFile open(java.lang.String filename) throws java.io.IOException
- Throws:
java.io.IOException
-
openDir
public RemoteDirectory openDir(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
setAttributes
public void setAttributes(java.lang.String path, FileAttributes attrs) throws java.io.IOException
- Throws:
java.io.IOException
-
readLink
public java.lang.String readLink(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
makeDir
public void makeDir(java.lang.String path, FileAttributes attrs) throws java.io.IOException
- Throws:
java.io.IOException
-
makeDir
public void makeDir(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
symlink
public void symlink(java.lang.String linkpath, java.lang.String targetpath) throws java.io.IOException
- Throws:
java.io.IOException
-
remove
public void remove(java.lang.String filename) throws java.io.IOException
- Throws:
java.io.IOException
-
removeDir
public void removeDir(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
stat
public FileAttributes stat(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
lstat
public FileAttributes lstat(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
rename
public void rename(java.lang.String oldPath, java.lang.String newPath, java.util.Set<RenameFlags> flags) throws java.io.IOException
- Throws:
java.io.IOException
-
canonicalize
public java.lang.String canonicalize(java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
setTimeoutMs
public void setTimeoutMs(int timeoutMs)
-
getTimeoutMs
public int getTimeoutMs()
- Specified by:
getTimeoutMs
in interfaceRequester
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
getLoggerFactory
protected LoggerFactory getLoggerFactory()
-
stat
protected FileAttributes stat(PacketType pt, java.lang.String path) throws java.io.IOException
- Throws:
java.io.IOException
-
readSingleName
protected static java.lang.String readSingleName(Response res) throws java.io.IOException
Using UTF-8- Throws:
java.io.IOException
-
readSingleName
protected static java.lang.String readSingleName(Response res, java.nio.charset.Charset charset) throws java.io.IOException
Using any character set- Throws:
java.io.IOException
-
transmit
protected void transmit(SFTPPacket<Request> payload) throws java.io.IOException
- Throws:
java.io.IOException
-
-