aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhsm <hsm@lamia.panaceas.james.local>2016-05-29 04:34:17 +0100
committerhsm <hsm@lamia.panaceas.james.local>2016-05-29 05:26:48 +0100
commit5a4943730fb343cf90df4088d4959121796b7a01 (patch)
treed140006db7edb7eeee328b159722e541865b7e9d
parent2d2d14c83fc21cce366c30775dfc3b9931924b52 (diff)
downloadconnectbot-5a4943730fb343cf90df4088d4959121796b7a01.tar.gz
connectbot-5a4943730fb343cf90df4088d4959121796b7a01.tar.bz2
connectbot-5a4943730fb343cf90df4088d4959121796b7a01.zip
support for open-keychain auth
-rw-r--r--app/src/main/java/org/connectbot/ConsoleActivity.java9
-rw-r--r--app/src/main/java/org/connectbot/PubkeyListActivity.java7
-rw-r--r--app/src/main/java/org/connectbot/service/TerminalBridge.java7
-rw-r--r--app/src/main/java/org/connectbot/service/TerminalManager.java14
4 files changed, 34 insertions, 3 deletions
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java
index 310eba8..9116a20 100644
--- a/app/src/main/java/org/connectbot/ConsoleActivity.java
+++ b/app/src/main/java/org/connectbot/ConsoleActivity.java
@@ -88,6 +88,9 @@ import android.widget.TextView;
import android.widget.Toast;
import de.mud.terminal.vt320;
+import com.trilead.ssh2.signature.TokenRSASHA1Verify;
+
+
public class ConsoleActivity extends AppCompatActivity implements BridgeDisconnectedListener {
public final static String TAG = "CB.ConsoleActivity";
@@ -1056,6 +1059,12 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne
unbindService(connection);
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ TokenRSASHA1Verify.callback(requestCode, resultCode, data);
+ }
+
+
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// Maintain selected host if connected.
diff --git a/app/src/main/java/org/connectbot/PubkeyListActivity.java b/app/src/main/java/org/connectbot/PubkeyListActivity.java
index 85ca570..187fef9 100644
--- a/app/src/main/java/org/connectbot/PubkeyListActivity.java
+++ b/app/src/main/java/org/connectbot/PubkeyListActivity.java
@@ -351,6 +351,13 @@ public class PubkeyListActivity extends AppCompatListActivity implements EventLi
pubkey.setEncrypted(PEMDecoder.isPEMEncrypted(struct));
pubkey.setType(PubkeyDatabase.KEY_TYPE_IMPORTED);
pubkey.setPrivateKey(raw);
+
+ // The locked/unlocked state of keys on the token
+ // depends on the smart card manager not us
+ // mark them unlocked at start
+
+ if (struct.pemType == PEMDecoder.PEM_RSA_TOKEN_PRIVATE_KEY)
+ pubkey.setStartup(true);
}
// write new value into database
diff --git a/app/src/main/java/org/connectbot/service/TerminalBridge.java b/app/src/main/java/org/connectbot/service/TerminalBridge.java
index d15585c..6d305f5 100644
--- a/app/src/main/java/org/connectbot/service/TerminalBridge.java
+++ b/app/src/main/java/org/connectbot/service/TerminalBridge.java
@@ -43,10 +43,14 @@ import android.graphics.Paint.FontMetrics;
import android.graphics.Typeface;
import android.text.ClipboardManager;
import android.util.Log;
+import android.app.Activity;
+
import de.mud.terminal.VDUBuffer;
import de.mud.terminal.VDUDisplay;
import de.mud.terminal.vt320;
+import com.trilead.ssh2.signature.TokenRSASHA1Verify;
+
/**
* Provides a bridge between a MUD terminal buffer and a possible TerminalView.
@@ -603,6 +607,8 @@ public class TerminalBridge implements VDUDisplay {
final int width = parent.getWidth();
final int height = parent.getHeight();
+ TokenRSASHA1Verify.open((Activity) parent.getContext());
+
// Something has gone wrong with our layout; we're 0 width or height!
if (width <= 0 || height <= 0)
return;
@@ -691,6 +697,7 @@ public class TerminalBridge implements VDUDisplay {
*/
public synchronized void parentDestroyed() {
parent = null;
+ TokenRSASHA1Verify.close();
discardBitmap();
}
diff --git a/app/src/main/java/org/connectbot/service/TerminalManager.java b/app/src/main/java/org/connectbot/service/TerminalManager.java
index 73eb4d1..4f7893f 100644
--- a/app/src/main/java/org/connectbot/service/TerminalManager.java
+++ b/app/src/main/java/org/connectbot/service/TerminalManager.java
@@ -60,6 +60,8 @@ import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;
+import com.trilead.ssh2.crypto.PEMDecoder;
+
/**
* Manager for SSH connections that runs as a service. This service holds a list
* of currently connected SSH bridges that are ready for connection up to a GUI
@@ -141,9 +143,15 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
for (PubkeyBean pubkey : pubkeys) {
try {
- PrivateKey privKey = PubkeyUtils.decodePrivate(pubkey.getPrivateKey(), pubkey.getType());
- PublicKey pubKey = PubkeyUtils.decodePublic(pubkey.getPublicKey(), pubkey.getType());
- KeyPair pair = new KeyPair(pubKey, privKey);
+ KeyPair pair;
+
+ if (PubkeyDatabase.KEY_TYPE_IMPORTED.equals(pubkey.getType())) {
+ pair = PEMDecoder.decode(new String(pubkey.getPrivateKey()).toCharArray(), "");
+ } else {
+ PrivateKey privKey = PubkeyUtils.decodePrivate(pubkey.getPrivateKey(), pubkey.getType());
+ PublicKey pubKey = PubkeyUtils.decodePublic(pubkey.getPublicKey(), pubkey.getType());
+ pair = new KeyPair(pubKey, privKey);
+ }
addKey(pubkey, pair);
} catch (Exception e) {