From b9c05044655358c8eebd822030d68c76f754d6cb Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 25 Oct 2014 22:20:43 +0200 Subject: [PATCH] remove unnecessary (and buggy) BufferedInputStream wrapping --- .../keychain/operations/ImportExportOperation.java | 13 ++++++++++--- .../keychain/pgp/UncachedKeyRing.java | 4 ---- .../keychain/ui/adapter/ImportKeysAdapter.java | 11 ++++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java index e915c1852..6178b92d0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java @@ -62,12 +62,19 @@ import java.util.concurrent.atomic.AtomicBoolean; /** An operation class which implements high level import and export * operations. * - * This class receivs a source and/or destination of keys as input and performs + * This class receives a source and/or destination of keys as input and performs * all steps for this import or export. * * For the import operation, the only valid source is an Iterator of - * ParcelableKeyRing, each of which must contain exactly a single keyring - * encoded as bytes. + * ParcelableKeyRing, each of which must contain either a single + * keyring encoded as bytes, or a unique reference to a keyring + * on keyservers and/or keybase.io. + * It is important to note that public keys should generally be imported before + * secret keys, because some implementations (notably Symantec PGP Desktop) do + * not include self certificates for user ids in the secret keyring. The import + * method here will generally import keyrings in the order given by the + * iterator. so this should be ensured beforehand. + * @see org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter#getSelectedEntries() * * For the export operation, the input consists of a set of key ids and * either the name of a file or an output uri to write to. diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java index a1479b0c6..7bef2e828 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java @@ -165,10 +165,6 @@ public class UncachedKeyRing { // if there are no objects left from the last factory, create a new one if (mObjectFactory == null) { InputStream in = PGPUtil.getDecoderStream(stream); - if (!BufferedInputStream.class.isInstance(in)) { - in = new BufferedInputStream(in); - } - mObjectFactory = new PGPObjectFactory(in, new JcaKeyFingerprintCalculator()); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index a9795cdd1..08a0c524b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -70,6 +70,7 @@ public class ImportKeysAdapter extends ArrayAdapter { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void setData(List data) { + clear(); if (data != null) { this.mData = data; @@ -89,16 +90,24 @@ public class ImportKeysAdapter extends ArrayAdapter { return mData; } + /** This method returns a list of all selected entries, with public keys sorted + * before secret keys, see ImportExportOperation for specifics. + * @see org.sufficientlysecure.keychain.operations.ImportExportOperation + */ public ArrayList getSelectedEntries() { ArrayList result = new ArrayList(); + ArrayList secrets = new ArrayList(); if (mData == null) { return result; } for (ImportKeysListEntry entry : mData) { if (entry.isSelected()) { - result.add(entry); + // add this entry to either the secret or the public list + (entry.isSecretKey() ? secrets : result).add(entry); } } + // add secret keys at the end of the list + result.addAll(secrets); return result; }