aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorThialfihar <thi@thialfihar.org>2014-05-14 14:17:20 +0200
committerThialfihar <thi@thialfihar.org>2014-05-14 17:21:27 +0200
commit2480844884ecffcd0d407a9d967b062ac8950462 (patch)
tree5406762efa2d2deb7c197b93bd594e6f93278225 /OpenKeychain
parent056a6dd3479fe1e5cc5981ac51a458b015d3e9cb (diff)
downloadopen-keychain-2480844884ecffcd0d407a9d967b062ac8950462.tar.gz
open-keychain-2480844884ecffcd0d407a9d967b062ac8950462.tar.bz2
open-keychain-2480844884ecffcd0d407a9d967b062ac8950462.zip
Cleanup keybase query a bit
Remove ctime and the cached key, making the query for the entire user object unnecessary. This should only be done when the user decides to import the key. Hopefully keybase.io can provide all info necessary in the search results.
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java
index da47c32c6..57355d808 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java
@@ -88,12 +88,14 @@ public class KeybaseKeyServer extends KeyServer {
private ImportKeysListEntry makeEntry(JSONObject match) throws QueryException, JSONException {
- String key_fingerprint = JWalk.getString(match, "components", "key_fingerprint", "val");
- key_fingerprint = key_fingerprint.replace(" ", "").toUpperCase();
- match = getUser(keybaseID);
-
final ImportKeysListEntry entry = new ImportKeysListEntry();
String keybaseId = JWalk.getString(match, "components", "username", "val");
+ String fullName = JWalk.getString(match, "components", "full_name", "val");
+ String fingerprint = JWalk.getString(match, "components", "key_fingerprint", "val");
+ fingerprint = fingerprint.replace(" ", "").toUpperCase();
+
+ // in anticipation of a full fingerprint, only use the last 16 chars as 64-bit key id
+ entry.setKeyIdHex("0x" + fingerprint.substring(Math.max(0, fingerprint.length() - 16)));
// store extra info, so we can query for the keybase id directly
entry.setExtraData(keybaseId);
@@ -101,20 +103,17 @@ public class KeybaseKeyServer extends KeyServer {
//entry.setBitStrength(4096);
//entry.setAlgorithm("RSA");
- // ctime
- final long creationDate = JWalk.getLong(match, "them", "public_keys", "primary", "ctime");
- final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
- tmpGreg.setTimeInMillis(creationDate * 1000);
- entry.setDate(tmpGreg.getTime());
+ entry.setFingerprintHex(fingerprint);
- // key bits
- // we have to fetch the user object to construct the search-result list, so we might as
- // well (weakly) remember the key, in case they try to import it
- mKeyCache.put(keybaseID, JWalk.getString(match,"them", "public_keys", "primary", "bundle"));
+ // key data
+ // currently there's no need to query the user right away, and it should be avoided, so the
+ // user doesn't experience lag and doesn't download many keys unnecessarily, but should we
+ // require to do it at soe point:
+ // (weakly) remember the key, in case the user tries to import it
+ //mKeyCache.put(keybaseId, JWalk.getString(match, "them", "public_keys", "primary", "bundle"));
- // String displayName = JWalk.getString(match, "them", "profile", "full_name");
ArrayList<String> userIds = new ArrayList<String>();
- String name = "keybase.io/" + keybaseID + " <" + keybaseID + "@keybase.io>";
+ String name = fullName + " <keybase.io/" + keybaseId + ">";
userIds.add(name);
entry.setUserIds(userIds);
entry.setPrimaryUserId(name);