Skip to content

Commit 2fc102a

Browse files
authored
Merge pull request #16956 from iterate-ch/bugfix/GH-16953
Update dependency.
2 parents 32b9483 + e3b1002 commit 2fc102a

File tree

6 files changed

+22
-31
lines changed

6 files changed

+22
-31
lines changed

ssh/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<packaging>jar</packaging>
2525
<properties>
2626
<sshj-version>0.38.0</sshj-version>
27-
<jsch-agentproxy-version>0.0.10</jsch-agentproxy-version>
27+
<jsch-agentproxy-version>0.0.11</jsch-agentproxy-version>
2828
</properties>
2929
<dependencies>
3030
<dependency>

ssh/src/main/java/ch/cyberduck/core/sftp/SFTPSession.java

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
import java.util.List;
7272
import java.util.stream.Collectors;
7373

74-
import com.jcraft.jsch.agentproxy.AgentProxyException;
7574
import net.schmizz.concurrent.Promise;
7675
import net.schmizz.keepalive.KeepAlive;
7776
import net.schmizz.keepalive.KeepAliveProvider;
@@ -283,27 +282,19 @@ private void authenticate(final SSHClient client, final Host host, final LoginCa
283282
// Ordered list of preferred authentication methods
284283
final List<AuthenticationProvider<Boolean>> defaultMethods = new ArrayList<>();
285284
if(preferences.getBoolean("ssh.authentication.agent.enable")) {
286-
final String identityAgent = new OpenSSHIdentityAgentConfigurator().getIdentityAgent(host.getHostname());
287-
log.debug("Determined identity agent {} for {}", identityAgent, host.getHostname());
288-
switch(Platform.getDefault()) {
289-
case windows:
290-
defaultMethods.add(new SFTPAgentAuthentication(client, new PageantAuthenticator()));
291-
try {
292-
defaultMethods.add(new SFTPAgentAuthentication(client,
293-
new WindowsOpenSSHAgentAuthenticator(identityAgent)));
294-
}
295-
catch(AgentProxyException e) {
296-
log.warn("Agent proxy failed with {}", e.getMessage());
297-
}
298-
break;
299-
default:
300-
try {
285+
final String configuration = new OpenSSHIdentityAgentConfigurator().getIdentityAgent(host.getHostname());
286+
if(configuration != null) {
287+
final String identityAgent = LocalFactory.get(configuration).getAbsolute();
288+
log.debug("Determined identity agent {} for {}", identityAgent, host.getHostname());
289+
switch(Platform.getDefault()) {
290+
case windows:
291+
defaultMethods.add(new SFTPAgentAuthentication(client, new PageantAuthenticator()));
292+
defaultMethods.add(new SFTPAgentAuthentication(client, new WindowsOpenSSHAgentAuthenticator(identityAgent)));
293+
break;
294+
default:
301295
defaultMethods.add(new SFTPAgentAuthentication(client, new OpenSSHAgentAuthenticator(identityAgent)));
302-
}
303-
catch(AgentProxyException e) {
304-
log.warn("Agent proxy failed with {}", e.getMessage());
305-
}
306-
break;
296+
break;
297+
}
307298
}
308299
}
309300
defaultMethods.add(new SFTPPublicKeyAuthentication(client));

ssh/src/main/java/ch/cyberduck/core/sftp/auth/SFTPPublicKeyAuthentication.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import ch.cyberduck.core.LoginCallback;
2525
import ch.cyberduck.core.LoginOptions;
2626
import ch.cyberduck.core.exception.BackgroundException;
27-
import ch.cyberduck.core.exception.InteroperabilityException;
2827
import ch.cyberduck.core.exception.LoginCanceledException;
28+
import ch.cyberduck.core.exception.LoginFailureException;
2929
import ch.cyberduck.core.sftp.SFTPExceptionMappingService;
3030
import ch.cyberduck.core.threading.CancelCallback;
3131

@@ -106,7 +106,8 @@ public Boolean authenticate(final Host bookmark, final LoginCallback prompt, fin
106106
pubKey = null;
107107
break;
108108
default:
109-
throw new InteroperabilityException(String.format("Unknown key format for file %s", privKey.getName()));
109+
log.warn("Unknown key format for file {}", privKey.getName());
110+
throw new LoginFailureException(String.format("Unknown key format for file %s", privKey.getName()));
110111
}
111112
provider.init(new InputStreamReader(privKey.getInputStream(), StandardCharsets.UTF_8),
112113
pubKey != null ? new InputStreamReader(pubKey.getInputStream(), StandardCharsets.UTF_8) : null,

ssh/src/main/java/ch/cyberduck/core/sftp/openssh/OpenSSHAgentAuthenticator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.List;
3030

3131
import com.jcraft.jsch.agentproxy.AgentProxy;
32-
import com.jcraft.jsch.agentproxy.AgentProxyException;
3332
import com.jcraft.jsch.agentproxy.Identity;
3433
import com.jcraft.jsch.agentproxy.connector.SSHAgentConnector;
3534
import com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory;
@@ -39,7 +38,7 @@ public class OpenSSHAgentAuthenticator extends AgentAuthenticator {
3938

4039
private final AgentProxy proxy;
4140

42-
public OpenSSHAgentAuthenticator(final String socket) throws AgentProxyException {
41+
public OpenSSHAgentAuthenticator(final String socket) {
4342
this(new AgentProxy(new SSHAgentConnector(new JNAUSocketFactory(), socket)));
4443
}
4544

ssh/src/main/java/ch/cyberduck/core/sftp/openssh/WindowsOpenSSHAgentAuthenticator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
import java.io.RandomAccessFile;
2121

2222
import com.jcraft.jsch.agentproxy.AgentProxy;
23-
import com.jcraft.jsch.agentproxy.AgentProxyException;
2423
import com.jcraft.jsch.agentproxy.USocketFactory;
2524
import com.jcraft.jsch.agentproxy.connector.SSHAgentConnector;
2625

2726
public class WindowsOpenSSHAgentAuthenticator extends OpenSSHAgentAuthenticator {
2827
private final static String SSH_AGENT_PIPE = "\\\\.\\pipe\\openssh-ssh-agent";
2928

30-
public WindowsOpenSSHAgentAuthenticator(final String socketPath) throws AgentProxyException {
29+
public WindowsOpenSSHAgentAuthenticator(final String socketPath) {
3130
super(new AgentProxy(new SSHAgentConnector(new RandomAccessFileSocketFactory(), fixupSocketPath(socketPath))));
3231
}
3332

ssh/src/test/java/ch/cyberduck/core/sftp/openssh/OpenSSHAgentAuthenticatorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,19 @@
2828
import com.jcraft.jsch.agentproxy.AgentProxyException;
2929
import com.jcraft.jsch.agentproxy.Identity;
3030

31+
import static junit.framework.Assert.assertTrue;
3132
import static org.junit.Assert.assertFalse;
3233
import static org.junit.Assert.assertNotNull;
3334
import static org.junit.Assume.assumeTrue;
3435

3536
public class OpenSSHAgentAuthenticatorTest {
3637

37-
@Test(expected = AgentProxyException.class)
38+
@Test
3839
public void testGetIdentities() throws Exception {
3940
assumeTrue(Factory.Platform.getDefault().equals(Factory.Platform.Name.mac));
4041
final OpenSSHAgentAuthenticator authenticator = new OpenSSHAgentAuthenticator(StringUtils.EMPTY);
41-
final Collection<Identity> identities = authenticator.getIdentities();
4242
assertNotNull(authenticator.getProxy());
43-
assertFalse(identities.isEmpty());
43+
final Collection<Identity> identities = authenticator.getIdentities();
44+
assertTrue(identities.isEmpty());
4445
}
4546
}

0 commit comments

Comments
 (0)