mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
keybase cleanups for revised search output format
This commit is contained in:
parent
9b71791679
commit
148a522694
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user