|
Secure iNet Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.scp.Scp
public final class Scp
Implements the basic functionality of an SCP (Secure Copy) client over SSH2 protocol.
Example Usage:
// create new SshParamters instance SshParameters params = new SshParameters(hostname,username,password);// create new Scp instance Scp scp = new Scp(params);
// register event listener scp.addListener(this);
// establish connection scp.connect();
// upload file to remote directory scp.upload(new File("c:/tmp/file.txt"),"/home/jsmith/");
// disconnect scp.disconnect();
Constructor Summary | |
---|---|
Scp(SshParameters parameters)
Creates a new client instance. |
|
Scp(SshParameters parameters,
SshConfiguration configuration)
Creates a new client instance. |
Method Summary | |
---|---|
void |
addListener(ScpEventListener listener)
Adds an event listener. |
void |
connect()
Connects to the server. |
void |
disconnect()
Disconnects from the server. |
void |
download(java.io.OutputStream out,
java.lang.String remoteDir,
java.lang.String remoteFile)
Downloads file from SSH server and writes to specified output stream. |
java.io.File |
download(java.lang.String remoteDir,
java.lang.String remoteFile)
Downloads the file from SSH server. |
void |
downloadDir(java.lang.String remoteDir,
java.lang.String name)
Downloads remote directory and contents recursively from SSH server. |
SshConfiguration |
getConfiguration()
Returns current SSH configuraton. |
boolean |
getDebug()
Returns current debug status. |
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debugging statements. |
int |
getDownloadBlockSize()
Returns download block size in bytes. |
java.lang.String |
getHost()
Returns server host name/IP. |
SshHostKeys |
getHostKeys()
Returns SSH host keys for further use. |
java.io.File |
getLocalDir()
Returns current local directory. |
SshParameters |
getParameters()
Returns current SSH parameters. |
int |
getPort()
Returns server port. |
boolean |
getPreserveTime()
Checks if preserve time flag is set. |
int |
getUploadBlockSize()
Returns upload block size in bytes. |
void |
interrupt()
Interrupts current transfer process. |
boolean |
isConnected()
Checks if client is connected. |
void |
mdownload(java.lang.String remoteDir,
java.util.Enumeration fileNames)
Downloads specified files in current working remote directory from SSH server to local directory. |
void |
mdownload(java.lang.String remoteDir,
java.util.Iterator fileNames)
Downloads specified files in current working remote directory from SSH server to local directory. |
void |
mdownload(java.lang.String remoteDir,
java.lang.String filter)
Downloads multiple files matching filter from SSH server's directory. |
void |
mdownload(java.lang.String remoteDir,
java.lang.String[] fileNames)
Downloads specified files in current working remote directory from SSH server to local directory. |
void |
mupload(java.lang.String remoteDir,
java.util.Enumeration fileNames)
Uploads multiple files to SSH server. |
void |
mupload(java.lang.String remoteDir,
java.util.Iterator fileNames)
Uploads multiple files to SSH server. |
void |
mupload(java.lang.String remoteDir,
java.lang.String filter)
Uploads multiple files matching regular expression to SSH server's current directory. |
void |
mupload(java.lang.String remoteDir,
java.lang.String[] fileNames)
Uploads multiple files to SSH server. |
void |
removeListener(ScpEventListener listener)
Removes listener. |
void |
setDebug(boolean value)
Sets debug status. |
void |
setDebugStream(java.io.PrintStream value)
Sets PrintStream used in reporting debugging statements. |
void |
setDownloadBlockSize(int value)
Sets download block size. |
void |
setLocalDir(java.io.File value)
Sets current local directory. |
void |
setPreserveTime(boolean value)
Sets preserver time flag. |
void |
setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size option of the scp connection. |
void |
setSendBufferSize(int sendBufferSize)
Sets the send buffer size option of the scp connection. |
void |
setUploadBlockSize(int value)
Sets upload block size. |
void |
upload(byte[] data,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server where contents of file is not on disk but in memory. |
void |
upload(java.io.File file,
java.lang.String remoteDir)
Uploads file to SSH server. |
void |
upload(java.io.File file,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server. |
void |
upload(java.io.InputStream in,
long fileLength,
java.lang.String remoteDir,
java.lang.String remoteFile)
Upload file to SSH server. |
void |
upload(java.io.InputStream in,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server. |
void |
upload(java.lang.String remoteDir,
java.lang.String filename)
Uploads file to SSH server. |
void |
upload(java.lang.String localFile,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server. |
void |
uploadDir(java.io.File dir,
java.lang.String remoteDir)
Uploads the specified directory. |
void |
uploadDir(java.io.File dir,
java.lang.String remoteDir,
java.lang.String remoteName)
Uploads the specified directory. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Scp(SshParameters parameters, SshConfiguration configuration)
parameters
- ssh connection parametersconfiguration
- ssh configuration parameterspublic Scp(SshParameters parameters)
parameters
- ssh connection parametersMethod Detail |
---|
public SshParameters getParameters()
public SshConfiguration getConfiguration()
public java.lang.String getHost()
public int getPort()
public java.io.File getLocalDir()
public void setLocalDir(java.io.File value)
value
- local directorypublic int getUploadBlockSize()
public void setUploadBlockSize(int value)
value
- upload block size in bytespublic int getDownloadBlockSize()
public void setDownloadBlockSize(int value)
value
- download block size in bytespublic boolean getPreserveTime()
public void setPreserveTime(boolean value)
value
- preserve timepublic void setSendBufferSize(int sendBufferSize)
sendBufferSize
- Send buffer size.public void setReceiveBufferSize(int receiveBufferSize)
receiveBufferSize
- Receive buffer size.public boolean getDebug()
true
if debug is on;
false
otherwisepublic void setDebug(boolean value)
value
- if true
debug output will bw turned onpublic void setDebugStream(java.io.PrintStream value)
value
- the PrintStream to send debug statements toPrintStream
public java.io.PrintStream getDebugStream()
PrintStream
public void addListener(ScpEventListener listener)
listener
- event listenerpublic void removeListener(ScpEventListener listener)
listener
- target listenerpublic SshHostKeys getHostKeys()
null
if keys are not availablepublic void connect() throws ScpException
ScpException
- if an I/O error occurspublic void disconnect()
public boolean isConnected()
true
if client is connected; false
otherwisepublic void interrupt()
public void download(java.io.OutputStream out, java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
out
- the OutputStream to writing file toremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile
- the remote file to download
java.io.IOException
- if an I/O, SSH or Scp error occurs.public java.io.File download(java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile
- the remote file to download
java.io.IOException
- if an I/O or SSH error occurs.public void mdownload(java.lang.String remoteDir, java.util.Enumeration fileNames) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames
- filenames of files to download
java.io.IOException
- if an I/O or SSH error occurs.downloadDir(String, String)
public void mdownload(java.lang.String remoteDir, java.util.Iterator fileNames) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames
- filenames of files to download
java.io.IOException
- if an I/O or SSH error occurs.downloadDir(String, String)
public void mdownload(java.lang.String remoteDir, java.lang.String[] fileNames) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames
- filenames of files to download
java.io.IOException
- if an I/O or SSH error occurs.downloadDir(String, String)
public void mdownload(java.lang.String remoteDir, java.lang.String filter) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfilter
- the filter to use
java.io.IOException
- if an I/O or SSH error occurs.downloadDir(java.lang.String, java.lang.String)
public void downloadDir(java.lang.String remoteDir, java.lang.String name) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryname
- the directory to download
java.io.IOException
- if an I/O or SSH error occurs.public void upload(byte[] data, java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
data
- the raw contents of the file to uploadremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile
- the filename to store file as on SSH server
java.io.IOException
- if an I/O or SSH error occurs.public void upload(java.io.InputStream in, java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
in
- the input stream to read fromremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile
- the remote file name relative to current remote directory
java.io.IOException
- if an I/O or SSH error occurspublic void upload(java.io.InputStream in, long fileLength, java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
in
- the input stream to read fromfileLength
- total amount of data to sendremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile
- the remote file name relative to current remote directory
java.io.IOException
- if an error occurspublic void upload(java.io.File file, java.lang.String remoteDir) throws java.io.IOException
file
- file to uploadremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directory
java.io.IOException
- if an I/O or SSH error occurspublic void upload(java.io.File file, java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
file
- file to uploadremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile
- the remote file name relative to current remote directory
java.io.IOException
- if an I/O or SSH error occurspublic void upload(java.lang.String remoteDir, java.lang.String filename) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfilename
- file name to upload
java.io.IOException
- if an I/O or SSH error occurspublic void upload(java.lang.String localFile, java.lang.String remoteDir, java.lang.String remoteFile) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directorylocalFile
- local file name relative to local directoryremoteFile
- the remote file name relative to current remote directory
java.io.IOException
- if an I/O or SSH error occurssetLocalDir(java.io.File)
public void mupload(java.lang.String remoteDir, java.util.Enumeration fileNames) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames
- filenames of files to upload
java.io.IOException
- if an I/O or SSH error occurs.public void mupload(java.lang.String remoteDir, java.util.Iterator fileNames) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames
- filenames of files to upload
java.io.IOException
- if an I/O or SSH error occurs.public void mupload(java.lang.String remoteDir, java.lang.String[] fileNames) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/") or empty line for current directoryfileNames
- filenames of files to upload
java.io.IOException
- if an I/O or SSH error occurs.public void mupload(java.lang.String remoteDir, java.lang.String filter) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfilter
- the filter to use
java.io.IOException
- if an I/O or SSH error occurs.public void uploadDir(java.io.File dir, java.lang.String remoteDir, java.lang.String remoteName) throws java.io.IOException
dir
- directory to uploadremoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteName
- the remote directory name relative to current remote directory
java.io.IOException
- if an I/O or SSH error occurspublic void uploadDir(java.io.File dir, java.lang.String remoteDir) throws java.io.IOException
remoteDir
- remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directorydir
- directory to upload
java.io.IOException
- if an I/O or SSH error occurs
|
Secure iNet Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |