Class SftpAdapter
java.lang.Object
net.jalbum.remotefs.sftp.SftpAdapter
- All Implemented Interfaces:
RemoteFS
SFTP implementation of RemoteFS interface.
Adapter class to adapt external component JSCH to RemoteFS interface.
See http://www.jcraft.com/jsch/index.html
Only SFTP capabilities of JSCH are used by this adapter.
During an SFTP connection, UTF-8 is always used for data transfer. Furthermore JSCH uses JZLib to compress the data send to the server.
PassiveMode does not apply to SFTP since it only uses 1 port: default port 22.
Adapter class to adapt external component JSCH to RemoteFS interface.
See http://www.jcraft.com/jsch/index.html
Only SFTP capabilities of JSCH are used by this adapter.
During an SFTP connection, UTF-8 is always used for data transfer. Furthermore JSCH uses JZLib to compress the data send to the server.
PassiveMode does not apply to SFTP since it only uses 1 port: default port 22.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classCustom UserInfo class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAbort a connection attemptvoidConnect to remote server using user and passwordvoidcreateDirectory(String name) Create directory on remote filesystemvoidDisconnect from remote serverbooleanCheck the existence of a filebooleanexistsDirectory(String path) Check the existence of a directory (the ftp protocol can't determine existence of both files and directories in one call)voidget(String path, OutputStream out) Get current remote directorygetFiles()Get files and convert result to array of RemoteFiles.Return all files in spefified remote directory.intgetPort()Return port numbervoidgetUnmonitored(String path, OutputStream out) Allows us to get :filetree on CrushFTP (avoids stat call)booleanCheck if connected to remote systembooleanReturn whether UTF8 is forcedbooleanReturn if passive mode is usedvoidnoop()voidput(InputStream in, String path) voidPut file to remote systemvoidvoidremoveDirectory(String name) Remove directory from remote filesystemvoidremoveFile(String filename) Remove file from remote systemvoidrenamevoidsetDirectory(String directory) Set remote directoryvoidsetForceUTF8(boolean force) Force using UTF8 to remote filesystemvoidsetPassiveMode(boolean mode) Set access mode to passivevoidsetPort(int port) Set port to use to access remote filesystemvoidsetProgressMonitorvoidGo to parent directory of current remote directory
-
Constructor Details
-
SftpAdapter
public SftpAdapter()
-
-
Method Details
-
setPort
Description copied from interface:RemoteFSSet port to use to access remote filesystem- Specified by:
setPortin interfaceRemoteFS- Parameters:
port- port number to access remote filesystem- Throws:
RemoteFSException- See Also:
-
getPort
Description copied from interface:RemoteFSReturn port number- Specified by:
getPortin interfaceRemoteFS- Returns:
- port number
- Throws:
RemoteFSException- See Also:
-
setForceUTF8
Description copied from interface:RemoteFSForce using UTF8 to remote filesystem- Specified by:
setForceUTF8in interfaceRemoteFS- Parameters:
force- Use UTF8 if true- Throws:
RemoteFSException- See Also:
-
isForceUTF8
Description copied from interface:RemoteFSReturn whether UTF8 is forced- Specified by:
isForceUTF8in interfaceRemoteFS- Returns:
- true if UTF8 forced
- Throws:
RemoteFSException- See Also:
-
setPassiveMode
Description copied from interface:RemoteFSSet access mode to passive- Specified by:
setPassiveModein interfaceRemoteFS- Parameters:
mode- Use passive mode if true- Throws:
RemoteFSException- See Also:
-
isPassiveMode
Description copied from interface:RemoteFSReturn if passive mode is used- Specified by:
isPassiveModein interfaceRemoteFS- Returns:
- true if passive mode
- Throws:
RemoteFSException- See Also:
-
getDirectory
Description copied from interface:RemoteFSGet current remote directory- Specified by:
getDirectoryin interfaceRemoteFS- Returns:
- Current remote directory
- Throws:
RemoteFSExceptionIOException- See Also:
-
setDirectory
Description copied from interface:RemoteFSSet remote directory- Specified by:
setDirectoryin interfaceRemoteFS- Parameters:
directory- Change remote directory to this directory- Throws:
RemoteFSExceptionIOException- See Also:
-
toParentDirectory
Description copied from interface:RemoteFSGo to parent directory of current remote directory- Specified by:
toParentDirectoryin interfaceRemoteFS- Throws:
RemoteFSExceptionIOException- See Also:
-
createDirectory
Description copied from interface:RemoteFSCreate directory on remote filesystem- Specified by:
createDirectoryin interfaceRemoteFS- Parameters:
name- Create directory with this name- Throws:
IOExceptionRemoteFSException- See Also:
-
removeDirectory
Description copied from interface:RemoteFSRemove directory from remote filesystem- Specified by:
removeDirectoryin interfaceRemoteFS- Parameters:
name- Remove directory with this name- Throws:
IOExceptionRemoteFSException- See Also:
-
connect
public void connect(String server, String user, String password) throws IOException, RemoteFSException Description copied from interface:RemoteFSConnect to remote server using user and password- Specified by:
connectin interfaceRemoteFS- Parameters:
server- server to connect touser- user to use for authenticationpassword- password for authenticating user- Throws:
IOExceptionRemoteFSException- See Also:
-
abortConnect
public void abortConnect()Description copied from interface:RemoteFSAbort a connection attempt- Specified by:
abortConnectin interfaceRemoteFS
-
disconnect
Description copied from interface:RemoteFSDisconnect from remote server- Specified by:
disconnectin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException- See Also:
-
isConnected
Description copied from interface:RemoteFSCheck if connected to remote system- Specified by:
isConnectedin interfaceRemoteFS- Returns:
- true if connected to remote system
- Throws:
RemoteFSException- See Also:
-
getFiles
Get files and convert result to array of RemoteFiles.- Specified by:
getFilesin interfaceRemoteFS- Returns:
- Array of RemoteFiles
- Throws:
IOExceptionRemoteFSException- See Also:
-
getFiles
Description copied from interface:RemoteFSReturn all files in spefified remote directory.- Specified by:
getFilesin interfaceRemoteFS- Returns:
- Array of RemoteFiles
- Throws:
IOExceptionRemoteFSException- deprecated unsafe with spaces in directories on ftp servers
-
putFile
Description copied from interface:RemoteFSPut file to remote system- Specified by:
putFilein interfaceRemoteFS- Parameters:
file- File to copy to remote system- Throws:
IOExceptionRemoteFSException- See Also:
-
putFile
- Specified by:
putFilein interfaceRemoteFS- Throws:
IOExceptionRemoteFSException- See Also:
-
put
- Specified by:
putin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException
-
getUnmonitored
Description copied from interface:RemoteFSAllows us to get :filetree on CrushFTP (avoids stat call)- Specified by:
getUnmonitoredin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException
-
get
- Specified by:
getin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException
-
removeFile
Description copied from interface:RemoteFSRemove file from remote system- Specified by:
removeFilein interfaceRemoteFS- Parameters:
filename- File te remove from remote system- Throws:
IOExceptionRemoteFSException- See Also:
-
setProgressMonitor
setProgressMonitor- Specified by:
setProgressMonitorin interfaceRemoteFS- Parameters:
monitor- RemoteFSProgressMonitor
-
rename
rename- Specified by:
renamein interfaceRemoteFS- Parameters:
from- Stringto- String- Throws:
RemoteFSExceptionIOException- See Also:
-
noop
- Specified by:
noopin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException
-
exists
Description copied from interface:RemoteFSCheck the existence of a file- Specified by:
existsin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException
-
existsDirectory
Description copied from interface:RemoteFSCheck the existence of a directory (the ftp protocol can't determine existence of both files and directories in one call)- Specified by:
existsDirectoryin interfaceRemoteFS- Throws:
IOExceptionRemoteFSException
-