diff options
author | Tim Bray <timbray@gmail.com> | 2014-05-15 17:14:45 -0700 |
---|---|---|
committer | Tim Bray <timbray@gmail.com> | 2014-05-15 17:14:45 -0700 |
commit | 148a52269450e13a2c5db7670706beb86db8a631 (patch) | |
tree | 335fa8615608190d07d00b09af7c43fcf3860bed /OpenKeychain/src/main/java | |
parent | 9b7179167914d19eb00f6cef5b7664e54efcd5e8 (diff) | |
download | open-keychain-148a52269450e13a2c5db7670706beb86db8a631.tar.gz open-keychain-148a52269450e13a2c5db7670706beb86db8a631.tar.bz2 open-keychain-148a52269450e13a2c5db7670706beb86db8a631.zip |
keybase cleanups for revised search output format
Diffstat (limited to 'OpenKeychain/src/main/java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java | 31 |
1 files changed, 7 insertions, 24 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 ba05742fb..5f729a05c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java @@ -35,8 +35,6 @@ import java.util.WeakHashMap; public class KeybaseKeyServer extends KeyServer { - private WeakHashMap<String, String> mKeyCache = new WeakHashMap<String, String>(); - @Override public ArrayList<ImportKeysListEntry> search(String query) throws QueryException, TooManyResponses, InsufficientQuery { @@ -93,29 +91,18 @@ public class KeybaseKeyServer extends KeyServer { 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(); + fingerprint = fingerprint.replace(" ", "").toUpperCase(); // not strictly necessary but doesn't hurt + entry.setFingerprintHex(fingerprint); // 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); - // TODO: Fix; have suggested keybase provide this value to avoid search-time crypto calls final int algorithmId = JWalk.getInt(match, "components", "key_fingerprint", "algo"); entry.setAlgorithm(PgpKeyHelper.getAlgorithmInfo(algorithmId)); final int bitStrength = JWalk.getInt(match, "components", "key_fingerprint", "nbits"); entry.setBitStrength(bitStrength); - //entry.setBitStrength(4096); - //entry.setAlgorithm("RSA"); - - entry.setFingerprintHex(fingerprint); - - // 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")); ArrayList<String> userIds = new ArrayList<String>(); String name = fullName + " <keybase.io/" + keybaseId + ">"; @@ -176,16 +163,12 @@ public class KeybaseKeyServer extends KeyServer { @Override public String get(String id) throws QueryException { - String key = mKeyCache.get(id); - if (key == null) { - try { - JSONObject user = getUser(id); - key = JWalk.getString(user, "them", "public_keys", "primary", "bundle"); - } catch (Exception e) { - throw new QueryException(e.getMessage()); - } + try { + JSONObject user = getUser(id); + return JWalk.getString(user, "them", "public_keys", "primary", "bundle"); + } catch (Exception e) { + throw new QueryException(e.getMessage()); } - return key; } @Override |