Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-05-22 22:17:59 +0000
committerslewis2014-05-22 22:17:59 +0000
commitcab79447ffd20f4a6673a0c58e98bc1856c3afdb (patch)
tree9fcdd9f298151b3117d71443292dd210a60e27d7 /providers
parent5e235cd42d7ee5c0915b88070ac99627a56d6ac1 (diff)
downloadorg.eclipse.ecf-cab79447ffd20f4a6673a0c58e98bc1856c3afdb.tar.gz
org.eclipse.ecf-cab79447ffd20f4a6673a0c58e98bc1856c3afdb.tar.xz
org.eclipse.ecf-cab79447ffd20f4a6673a0c58e98bc1856c3afdb.zip
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=435159
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpOutgoingFileTransfer.java72
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpRetrieveFileTransfer.java137
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpUtil.java109
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java4
6 files changed, 238 insertions, 88 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/META-INF/MANIFEST.MF
index a94bbeaea..d1f06ee60 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer.scp;singleton:=true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.0.100.qualifier
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.scp.Activator
Bundle-Vendor: %plugin.provider
Import-Package: com.jcraft.jsch,
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpOutgoingFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpOutgoingFileTransfer.java
index 8449f005d..6f5f5d84c 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpOutgoingFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpOutgoingFileTransfer.java
@@ -27,10 +27,14 @@ import org.eclipse.osgi.util.NLS;
/**
*
*/
-public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer implements IScpFileTransfer {
+public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer
+ implements IScpFileTransfer {
- private static final String SCP_COMMAND = "scp -p -t "; //$NON-NLS-1$
- private static final String SCP_EXEC = "exec"; //$NON-NLS-1$
+ private static final String SCP_COMMAND = System
+ .getProperty(
+ "org.eclipse.ecf.filetransfer.scp.outgoing.scpcommand", "scp -p -t "); //$NON-NLS-1$; //$NON-NLS-1$
+ private static final String SCP_EXEC = System.getProperty(
+ "org.eclipse.ecf.filetransfer.scp.outgoing.scpcommand", "exec"); //$NON-NLS-1$
String username;
@@ -39,14 +43,19 @@ public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer implem
private InputStream responseStream;
private ScpUtil scpUtil;
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer#openStreams()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer
+ * #openStreams()
*/
protected void openStreams() throws SendFileTransferException {
try {
final File localFile = getFileTransferInfo().getFile();
// Set input stream from local file
- setInputStream(new BufferedInputStream(new FileInputStream(localFile)));
+ setInputStream(new BufferedInputStream(new FileInputStream(
+ localFile)));
final URL url = getRemoteFileURL();
this.username = url.getUserInfo();
scpUtil = new ScpUtil(this);
@@ -63,7 +72,9 @@ public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer implem
sendFileNameAndSize(localFile, targetFileName, outs, responseStream);
setOutputStream(outs);
} catch (final Exception e) {
- throw new SendFileTransferException(NLS.bind(Messages.ScpOutgoingFileTransfer_EXCEPTION_CONNECTING, getRemoteFileURL().toString()), e);
+ throw new SendFileTransferException(NLS.bind(
+ Messages.ScpOutgoingFileTransfer_EXCEPTION_CONNECTING,
+ getRemoteFileURL().toString()), e);
}
}
@@ -80,19 +91,25 @@ public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer implem
return this.proxy;
}
- private void sendFileNameAndSize(File localFile, String fileName, OutputStream outs, InputStream ins) throws IOException {
+ private void sendFileNameAndSize(File localFile, String fileName,
+ OutputStream outs, InputStream ins) throws IOException {
// send "C0644 filesize filename", where filename should not include '/'
final long filesize = localFile.length();
String[] targetFile = StringUtils.split(fileName, '/');
final StringBuffer command = new StringBuffer("C0644 "); //$NON-NLS-1$
- command.append(filesize).append(" ").append(targetFile[targetFile.length - 1]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ command.append(filesize)
+ .append(" ").append(targetFile[targetFile.length - 1]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
outs.write(command.toString().getBytes());
outs.flush();
scpUtil.checkAck(ins);
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer#hardClose()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer
+ * #hardClose()
*/
protected void hardClose() {
try {
@@ -100,10 +117,6 @@ public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer implem
scpUtil.sendZeroToStream(remoteFileContents);
scpUtil.checkAck(responseStream);
}
- if (remoteFileContents != null) {
- remoteFileContents.close();
- remoteFileContents = null;
- }
if (channel != null) {
channel.disconnect();
channel = null;
@@ -119,29 +132,42 @@ public class ScpOutgoingFileTransfer extends AbstractOutgoingFileTransfer implem
super.hardClose();
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer#setupProxy(org.eclipse.ecf.core.util.Proxy)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer
+ * #setupProxy(org.eclipse.ecf.core.util.Proxy)
*/
protected void setupProxy(Proxy proxy) {
this.proxy = proxy;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#getUsername()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#getUsername()
*/
public String getUsername() {
return username;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.internal.provider.filetransfer.scp.IScpFileTransfer#getConnectContext()
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.internal.provider.filetransfer.scp.IScpFileTransfer#
+ * getConnectContext()
*/
public IConnectContext getConnectContext() {
return connectContext;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.internal.provider.filetransfer.scp.IScpFileTransfer#setUsername(java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.internal.provider.filetransfer.scp.IScpFileTransfer#
+ * setUsername(java.lang.String)
*/
public void setUsername(String username) {
this.username = username;
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpRetrieveFileTransfer.java
index 81d0e0e86..a40cec28b 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpRetrieveFileTransfer.java
@@ -26,10 +26,13 @@ import org.eclipse.osgi.util.NLS;
/**
*
*/
-public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implements IScpFileTransfer {
+public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer
+ implements IScpFileTransfer {
- private static final String SCP_COMMAND = "scp -f "; //$NON-NLS-1$
- private static final String SCP_EXEC = "exec"; //$NON-NLS-1$
+ private static final String SCP_COMMAND = System.getProperty(
+ "org.eclipse.ecf.filetransfer.scp.retrieve.scpcommand", "scp -f "); //$NON-NLS-1$
+ private static final String SCP_EXEC = System.getProperty(
+ "org.eclipse.ecf.filetransfer.scp.retrieve.scpcommand", "exec"); //$NON-NLS-1$
String username;
@@ -39,15 +42,23 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
private ScpUtil scpUtil;
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#doPause()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
+ * #doPause()
*/
protected boolean doPause() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#doResume()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
+ * #doResume()
*/
protected boolean doResume() {
return false;
@@ -61,8 +72,12 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
return options;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer#openStreams()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer
+ * #openStreams()
*/
protected void openStreams() throws IncomingFileTransferException {
try {
@@ -74,7 +89,8 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
final Session s = scpUtil.getSession();
s.connect();
- final String command = SCP_COMMAND + scpUtil.trimTargetFile(url.getPath());
+ final String command = SCP_COMMAND
+ + scpUtil.trimTargetFile(url.getPath());
channel = s.openChannel(SCP_EXEC);
((ChannelExec) channel).setCommand(command);
channel.connect();
@@ -82,10 +98,11 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
final InputStream ins = channel.getInputStream();
responseStream = channel.getOutputStream();
scpUtil.sendZeroToStream(responseStream);
- // read and set filesize
- final int c = ins.read();
+
+ final int c = checkAck(ins);
if (c != 'C')
- throw new IOException(Messages.ScpRetrieveFileTransfer_EXCEPTION_SCP_PROTOCOL);
+ throw new IOException(
+ Messages.ScpRetrieveFileTransfer_EXCEPTION_SCP_PROTOCOL);
// read '0644 '
final byte[] buf = new byte[1024];
ins.read(buf, 0, 5);
@@ -93,22 +110,58 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
setFileLength(readFileSize(ins, buf));
readFileName(ins, buf);
// set input stream for reading rest of file
- setInputStream(ins);
+ remoteFileContents = ins;
+
scpUtil.sendZeroToStream(responseStream);
fireReceiveStartEvent();
} catch (final Exception e) {
channel = null;
username = null;
- throw new IncomingFileTransferException(NLS.bind(Messages.ScpRetrieveFileTransfer_EXCEPTION_CONNECTING, getRemoteFileURL().toString()), e);
+ throw new IncomingFileTransferException(NLS.bind(
+ Messages.ScpRetrieveFileTransfer_EXCEPTION_CONNECTING,
+ getRemoteFileURL().toString()), e);
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#handleReceivedData(byte[], int, double, org.eclipse.core.runtime.IProgressMonitor)
+ static int checkAck(InputStream in) throws IOException {
+ int b = in.read();
+ // b may be 0 for success,
+ // 1 for error,
+ // 2 for fatal error,
+ // -1
+ if (b == 0)
+ return b;
+ if (b == -1)
+ return b;
+
+ if (b == 1 || b == 2) {
+ StringBuffer sb = new StringBuffer();
+ int c;
+ do {
+ c = in.read();
+ sb.append((char) c);
+ } while (c != '\n');
+ if (b == 1 || b == 2) { // error
+ throw new IOException(
+ Messages.ScpRetrieveFileTransfer_EXCEPTION_SCP_PROTOCOL
+ + ": " + sb.toString());
+ }
+ }
+ return b;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
+ * #handleReceivedData(byte[], int, double,
+ * org.eclipse.core.runtime.IProgressMonitor)
*/
- protected void handleReceivedData(byte[] buf, int bytes, double factor, IProgressMonitor monitor) throws IOException {
+ protected void handleReceivedData(byte[] buf, int bytes, double factor,
+ IProgressMonitor monitor) throws IOException {
if (bytes == -1) {
done = true;
} else {
@@ -131,7 +184,8 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
long filesize = 0L;
while (true) {
if (ins.read(buf, 0, 1) < 0) {
- throw new IOException(Messages.ScpRetrieveFileTransfer_EXCEPTION_ERROR_READING_FILE);
+ throw new IOException(
+ Messages.ScpRetrieveFileTransfer_EXCEPTION_ERROR_READING_FILE);
}
if (buf[0] == ' ')
break;
@@ -152,8 +206,12 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
return file;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer#hardClose()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer
+ * #hardClose()
*/
protected void hardClose() {
try {
@@ -177,7 +235,9 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
/*
* (non-Javadoc)
*
- * @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#getAdapter(java.lang.Class)
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
+ * #getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
if (adapter == null)
@@ -187,22 +247,33 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
return super.getAdapter(adapter);
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#setupProxy(org.eclipse.ecf.core.util.Proxy)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
+ * #setupProxy(org.eclipse.ecf.core.util.Proxy)
*/
protected void setupProxy(Proxy proxy) {
this.proxy = proxy;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#getConnectContext()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#getConnectContext
+ * ()
*/
public IConnectContext getConnectContext() {
return connectContext;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#getUsername()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#getUsername()
*/
public String getUsername() {
return username;
@@ -212,12 +283,16 @@ public class ScpRetrieveFileTransfer extends AbstractRetrieveFileTransfer implem
this.username = username;
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#promptPassphrase()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.provider.filetransfer.scp.IScpFileTransfer#promptPassphrase
+ * ()
*/
public boolean promptPassphrase() {
// XXX TODO
- //return (keyFile != null);
+ // return (keyFile != null);
return false;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpUtil.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpUtil.java
index 54620e137..d7c9ee90d 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpUtil.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.scp/src/org/eclipse/ecf/internal/provider/filetransfer/scp/ScpUtil.java
@@ -26,11 +26,18 @@ import org.eclipse.osgi.util.NLS;
*/
public class ScpUtil implements UserInfo, UIKeyboardInteractive {
- public static final String SCP_SSHHOMEDIRECTORY = "sshHomeDirectory"; //$NON-NLS-1$
- public static final String SCP_PUBLICKEYFILE = "keyFile"; //$NON-NLS-1$
- public static final String SCP_KNOWNHOSTSFILE = "knownHostsFile"; //$NON-NLS-1$
+ public static final String SCP_SSHHOMEDIRECTORY = System
+ .getProperty(
+ "org.eclipse.ecf.filetransfer.scp.util.sshHomeDirectory", "sshHomeDirectory"); //$NON-NLS-1$
+ public static final String SCP_PUBLICKEYFILE = System.getProperty(
+ "org.eclipse.ecf.filetransfer.scp.util.keyFile", "keyFile"); //$NON-NLS-1$
+ public static final String SCP_KNOWNHOSTSFILE = System
+ .getProperty(
+ "org.eclipse.ecf.filetransfer.scp.util.knownHostsFile", "knownHostsFile"); //$NON-NLS-1$
- public static final int DEFAULT_SCP_PORT = 22;
+ public static final int DEFAULT_SCP_PORT = Integer
+ .parseInt(System.getProperty(
+ "org.eclipse.ecf.filetransfer.scp.util.scpPort", "22"));
private IScpFileTransfer handler;
private String password;
@@ -41,7 +48,8 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
private String keyFile = null;
private String knownHostsFile = null;
- public ScpUtil(IScpFileTransfer handler) throws JSchException, IOException, UnsupportedCallbackException {
+ public ScpUtil(IScpFileTransfer handler) throws JSchException, IOException,
+ UnsupportedCallbackException {
this.handler = handler;
final JSch jsch = new JSch();
final URL url = handler.getTargetURL();
@@ -65,15 +73,18 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
void promptUsername() throws IOException, UnsupportedCallbackException {
final IConnectContext connectContext = handler.getConnectContext();
if (connectContext != null) {
- final CallbackHandler callbackHandler = connectContext.getCallbackHandler();
+ final CallbackHandler callbackHandler = connectContext
+ .getCallbackHandler();
if (handler != null) {
final Callback[] callbacks = new Callback[2];
- final NameCallback nc = new NameCallback(Messages.ScpOutgoingFileTransfer_USERNAME_PROMPT);
+ final NameCallback nc = new NameCallback(
+ Messages.ScpOutgoingFileTransfer_USERNAME_PROMPT);
String user = handler.getUsername();
if (user != null)
nc.setName(user);
callbacks[0] = nc;
- callbacks[1] = new PasswordCallback(Messages.ScpOutgoingFileTransfer_PASSWORD_PROMPT);
+ callbacks[1] = new PasswordCallback(
+ Messages.ScpOutgoingFileTransfer_PASSWORD_PROMPT);
callbackHandler.handle(callbacks);
handler.setUsername(nc.getName());
}
@@ -84,24 +95,30 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
try {
final IConnectContext connectContext = handler.getConnectContext();
if (connectContext != null) {
- final CallbackHandler callbackHandler = connectContext.getCallbackHandler();
+ final CallbackHandler callbackHandler = connectContext
+ .getCallbackHandler();
if (handler != null) {
final Callback[] callbacks = new Callback[2];
- final NameCallback nc = new NameCallback(Messages.ScpOutgoingFileTransfer_USERNAME_PROMPT);
+ final NameCallback nc = new NameCallback(
+ Messages.ScpOutgoingFileTransfer_USERNAME_PROMPT);
String user = handler.getUsername();
if (user != null)
nc.setName(user);
callbacks[0] = nc;
if (usePassphrase) {
- callbacks[1] = new PassphraseCallback(Messages.ScpOutgoingFileTransfer_PASSPHRASE_PROMPT);
+ callbacks[1] = new PassphraseCallback(
+ Messages.ScpOutgoingFileTransfer_PASSPHRASE_PROMPT);
} else
- callbacks[1] = new PasswordCallback(Messages.ScpOutgoingFileTransfer_PASSWORD_PROMPT);
+ callbacks[1] = new PasswordCallback(
+ Messages.ScpOutgoingFileTransfer_PASSWORD_PROMPT);
callbackHandler.handle(callbacks);
handler.setUsername(nc.getName());
if (usePassphrase) {
- passphrase = ((PassphraseCallback) callbacks[1]).getPassphrase();
+ passphrase = ((PassphraseCallback) callbacks[1])
+ .getPassphrase();
} else
- password = ((PasswordCallback) callbacks[1]).getPassword();
+ password = ((PasswordCallback) callbacks[1])
+ .getPassword();
}
}
return (usePassphrase) ? this.passphrase : this.password;
@@ -110,54 +127,72 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.jcraft.jsch.UserInfo#getPassphrase()
*/
public String getPassphrase() {
return promptCredentials(true);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.jcraft.jsch.UserInfo#getPassword()
*/
public String getPassword() {
return promptCredentials(false);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.jcraft.jsch.UserInfo#promptPassphrase(java.lang.String)
*/
public boolean promptPassphrase(String message) {
return (keyFile != null);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.jcraft.jsch.UserInfo#promptPassword(java.lang.String)
*/
public boolean promptPassword(String message) {
return true;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.jcraft.jsch.UserInfo#promptYesNo(java.lang.String)
*/
public boolean promptYesNo(String message) {
return true;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see com.jcraft.jsch.UserInfo#showMessage(java.lang.String)
*/
public void showMessage(String message) {
// do nothing
}
- /* (non-Javadoc)
- * @see com.jcraft.jsch.UIKeyboardInteractive#promptKeyboardInteractive(java.lang.String, java.lang.String, java.lang.String, java.lang.String[], boolean[])
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.jcraft.jsch.UIKeyboardInteractive#promptKeyboardInteractive(java.
+ * lang.String, java.lang.String, java.lang.String, java.lang.String[],
+ * boolean[])
*/
- public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
+ public String[] promptKeyboardInteractive(String destination, String name,
+ String instruction, String[] prompt, boolean[] echo) {
promptCredentials(false);
- return new String[] {password};
+ return new String[] { password };
}
/**
@@ -217,7 +252,14 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
try {
jsch.addIdentity(keyFile);
} catch (final JSchException e) {
- Activator.getDefault().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.ScpOutgoingFileTransfer_EXCEPTION_SETTING_SSH_IDENTITY, e));
+ Activator
+ .getDefault()
+ .log(new Status(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ IStatus.ERROR,
+ Messages.ScpOutgoingFileTransfer_EXCEPTION_SETTING_SSH_IDENTITY,
+ e));
}
}
knownHostsFile = getProperty(SCP_KNOWNHOSTSFILE);
@@ -236,7 +278,14 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
try {
jsch.setKnownHosts(knownHostsFile);
} catch (final JSchException e) {
- Activator.getDefault().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.ScpOutgoingFileTransfer_EXCEPTION_SETTING_KNOWN_HOSTS, e));
+ Activator
+ .getDefault()
+ .log(new Status(
+ IStatus.ERROR,
+ Activator.PLUGIN_ID,
+ IStatus.ERROR,
+ Messages.ScpOutgoingFileTransfer_EXCEPTION_SETTING_KNOWN_HOSTS,
+ e));
}
}
}
@@ -256,8 +305,6 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
}
String trimTargetFile(String string) {
- if (string.charAt(0) == '/')
- return string.substring(1);
return string;
}
@@ -279,10 +326,12 @@ public class ScpUtil implements UserInfo, UIKeyboardInteractive {
sb.append((char) c);
} while (c != '\n');
if (b == 1) { // error
- throw new IOException(NLS.bind(Messages.ScpUtil_SCP_ERROR, sb.toString()));
+ throw new IOException(NLS.bind(Messages.ScpUtil_SCP_ERROR,
+ sb.toString()));
}
if (b == 2) { // fatal error
- throw new IOException(NLS.bind(Messages.ScpUtil_SCP_ERROR, sb.toString()));
+ throw new IOException(NLS.bind(Messages.ScpUtil_SCP_ERROR,
+ sb.toString()));
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF
index 674f8f6d3..4c3787243 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer;singleton:=true
-Bundle-Version: 3.2.100.qualifier
+Bundle-Version: 3.2.200.qualifier
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.Activator
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java
index 3b3edb2bb..66e2d6519 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java
@@ -77,8 +77,8 @@ public class FileTransferID extends BaseID implements IFileID {
}
protected String getFileNameOnly() {
- final String path = this.fileURL.getPath();
- return path.substring(path.lastIndexOf("/") + 1); //$NON-NLS-1$;
+ String path = (fileURI != null) ? fileURI.getPath() : fileURL.getPath();
+ return (path == null) ? null : path.substring(path.lastIndexOf("/") + 1); //$NON-NLS-1$;
}
public String toString() {

Back to the top