From 57afa9bdc5b269a48bd27fc8455cab4cb956d02a Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Mon, 7 Sep 2015 22:15:57 -0700 Subject: Never cache instances of the HostDatabase --- app/src/main/java/org/connectbot/transport/SSH.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'app/src/main/java/org/connectbot/transport') diff --git a/app/src/main/java/org/connectbot/transport/SSH.java b/app/src/main/java/org/connectbot/transport/SSH.java index 4bad2f1..f3b85a6 100644 --- a/app/src/main/java/org/connectbot/transport/SSH.java +++ b/app/src/main/java/org/connectbot/transport/SSH.java @@ -141,7 +141,8 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException { // read in all known hosts from hostdb - KnownHosts hosts = manager.hostdb.getKnownHosts(); + HostDatabase hostDb = HostDatabase.get(manager); + KnownHosts hosts = hostDb.getKnownHosts(); Boolean result; String matchName = String.format(Locale.US, "%s:%d", hostname, port); @@ -172,7 +173,7 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC if (result == null) return false; if (result.booleanValue()) { // save this key in known database - manager.hostdb.saveKnownHost(hostname, port, serverHostKeyAlgorithm, serverHostKey); + hostDb.saveKnownHost(hostname, port, serverHostKeyAlgorithm, serverHostKey); } return result.booleanValue(); @@ -195,7 +196,7 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC result = bridge.promptHelper.requestBooleanPrompt(null, manager.res.getString(R.string.prompt_continue_connecting)); if (result != null && result.booleanValue()) { // save this key in known database - manager.hostdb.saveKnownHost(hostname, port, serverHostKeyAlgorithm, serverHostKey); + hostDb.saveKnownHost(hostname, port, serverHostKeyAlgorithm, serverHostKey); return true; } else { return false; @@ -249,13 +250,16 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC } else { bridge.outputLine(manager.res.getString(R.string.terminal_auth_pubkey_specific)); // use a specific key for this host, as requested - PubkeyBean pubkey = manager.pubkeydb.findPubkeyById(pubkeyId); + PubkeyDatabase pubkeyDb = PubkeyDatabase.get(manager); + PubkeyBean pubkey = pubkeyDb.findPubkeyById(pubkeyId); - if (pubkey == null) + if (pubkey == null) { bridge.outputLine(manager.res.getString(R.string.terminal_auth_pubkey_invalid)); - else - if (tryPublicKey(pubkey)) + } else { + if (tryPublicKey(pubkey)) { finishConnection(); + } + } } pubkeysExhausted = true; @@ -293,7 +297,7 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC /** * Attempt connection with database row pointed to by cursor. - * @param cursor + * @param pubkey * @return true for successful authentication * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException -- cgit v1.2.3