aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java16
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java44
5 files changed, 40 insertions, 27 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
index c4c12cd3a..a6f1334ea 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java
@@ -278,7 +278,7 @@ public class HkpKeyserver extends Keyserver {
while (matcher.find()) {
final ImportKeysListEntry entry = new ImportKeysListEntry();
entry.setQuery(query);
- entry.setOrigin(getUrlPrefix() + mHost + ":" + mPort);
+ entry.addOrigin(getUrlPrefix() + mHost + ":" + mPort);
int bitSize = Integer.parseInt(matcher.group(3));
entry.setBitStrength(bitSize);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java
index 00bbca69c..15bcd8576 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysList.java
@@ -67,6 +67,9 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> {
existing.setExpired(true);
modified = true;
}
+ for (String origin : incoming.getOrigins()) {
+ existing.addOrigin(origin);
+ }
ArrayList<String> incomingIDs = incoming.getUserIds();
ArrayList<String> existingIDs = existing.getUserIds();
for (String incomingID : incomingIDs) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
index c10cd2e70..b3df67c0c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
@@ -46,7 +46,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
private String mPrimaryUserId;
private String mExtraData;
private String mQuery;
- private String mOrigin;
+ private ArrayList<String> mOrigins;
private Integer mHashCode = null;
private boolean mSelected;
@@ -70,7 +70,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
dest.writeByte((byte) (mSecretKey ? 1 : 0));
dest.writeByte((byte) (mSelected ? 1 : 0));
dest.writeString(mExtraData);
- dest.writeString(mOrigin);
+ dest.writeStringList(mOrigins);
}
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
@@ -90,7 +90,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
vr.mSecretKey = source.readByte() == 1;
vr.mSelected = source.readByte() == 1;
vr.mExtraData = source.readString();
- vr.mOrigin = source.readString();
+ vr.mOrigins = new ArrayList<String>();
+ source.readStringList(vr.mOrigins);
return vr;
}
@@ -230,12 +231,12 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
mQuery = query;
}
- public String getOrigin() {
- return mOrigin;
+ public ArrayList<String> getOrigins() {
+ return mOrigins;
}
- public void setOrigin(String origin) {
- mOrigin = origin;
+ public void addOrigin(String origin) {
+ mOrigins.add(origin);
}
/**
@@ -247,6 +248,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
// do not select by default
mSelected = false;
mUserIds = new ArrayList<String>();
+ mOrigins = new ArrayList<String>();
}
/**
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 ff582e5ed..0a55fccc8 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java
@@ -63,7 +63,7 @@ public class KeybaseKeyserver extends Keyserver {
private ImportKeysListEntry makeEntry(Match match) throws KeybaseException {
final ImportKeysListEntry entry = new ImportKeysListEntry();
entry.setQuery(mQuery);
- entry.setOrigin(ORIGIN);
+ entry.addOrigin(ORIGIN);
entry.setRevoked(false); // keybase doesn’t say anything about revoked keys
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
index 52638f592..9b7dcaf6a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
@@ -652,27 +652,35 @@ public class KeychainIntentService extends IntentService implements Progressable
for (ImportKeysListEntry entry : entries) {
try {
Keyserver server;
- if (entry.getOrigin() == null) {
- server = new HkpKeyserver(keyServer);
- } else if (KeybaseKeyserver.ORIGIN.equals(entry.getOrigin())) {
- server = new KeybaseKeyserver();
- } else {
- server = new HkpKeyserver(entry.getOrigin());
+ ArrayList<String> origins = entry.getOrigins();
+ if (origins == null) {
+ origins = new ArrayList<String>();
}
-
- // if available use complete fingerprint for get request
- byte[] downloadedKeyBytes;
- if (KeybaseKeyserver.ORIGIN.equals(entry.getOrigin())) {
- downloadedKeyBytes = server.get(entry.getExtraData()).getBytes();
- } else if (entry.getFingerprintHex() != null) {
- downloadedKeyBytes = server.get("0x" + entry.getFingerprintHex()).getBytes();
- } else {
- downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes();
+ if (origins.isEmpty()) {
+ origins.add(keyServer);
}
+ for (String origin : origins) {
+ if (KeybaseKeyserver.ORIGIN.equals(origin)) {
+ server = new KeybaseKeyserver();
+ } else {
+ server = new HkpKeyserver(origin);
+ }
+ Log.d(Constants.TAG, "IMPORTING " + entry.getKeyIdHex() + " FROM: " + server);
+
+ // if available use complete fingerprint for get request
+ byte[] downloadedKeyBytes;
+ if (KeybaseKeyserver.ORIGIN.equals(origin)) {
+ downloadedKeyBytes = server.get(entry.getExtraData()).getBytes();
+ } else if (entry.getFingerprintHex() != null) {
+ downloadedKeyBytes = server.get("0x" + entry.getFingerprintHex()).getBytes();
+ } else {
+ downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes();
+ }
- // save key bytes in entry object for doing the
- // actual import afterwards
- keyRings.add(new ParcelableKeyRing(downloadedKeyBytes, entry.getFingerprintHex()));
+ // save key bytes in entry object for doing the
+ // actual import afterwards
+ keyRings.add(new ParcelableKeyRing(downloadedKeyBytes, entry.getFingerprintHex()));
+ }
} catch (Exception e) {
sendErrorToHandler(e);
}