diff options
author | Ashley Hughes <spirit.returned@gmail.com> | 2014-04-01 23:37:13 +0100 |
---|---|---|
committer | Ashley Hughes <spirit.returned@gmail.com> | 2014-04-01 23:37:13 +0100 |
commit | 2ad616ed3f8a801c34da8b10f38103afc0cfe436 (patch) | |
tree | 7d01044f07c2e3d43aed84e2dda25f96d1ddae5b /OpenPGP-Keychain/src/main/java/org/sufficientlysecure | |
parent | abfe416503517ca6eaa1569818154fb498ec1741 (diff) | |
download | open-keychain-2ad616ed3f8a801c34da8b10f38103afc0cfe436.tar.gz open-keychain-2ad616ed3f8a801c34da8b10f38103afc0cfe436.tar.bz2 open-keychain-2ad616ed3f8a801c34da8b10f38103afc0cfe436.zip |
pass through info that keys are new without relying on new keys orginally being empty
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure')
5 files changed, 22 insertions, 2 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 0aa8b7410..66f1f3f01 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -478,7 +478,9 @@ public class PgpKeyOperation { PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); sigList.add(new Pair<String, PGPSignature>(userId, certification)); } - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + if (!saveParcel.newIDs[userIDIndex]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + } userIDIndex++; } for (Pair<String, PGPSignature> toAdd : sigList) { @@ -500,7 +502,9 @@ public class PgpKeyOperation { sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + if (!saveParcel.newIDs[userIDIndex]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + } masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } userIDIndex++; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index c99284847..b7ae4e1f1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -32,6 +32,7 @@ public class SaveKeyringParcel implements Parcelable { public ArrayList<String> userIDs; public ArrayList<String> originalIDs; public ArrayList<String> deletedIDs; + public boolean[] newIDs; public boolean primaryIDChanged; public boolean[] moddedKeys; public ArrayList<PGPSecretKey> deletedKeys; @@ -50,6 +51,7 @@ public class SaveKeyringParcel implements Parcelable { userIDs = (ArrayList<String>)source.readSerializable(); originalIDs = (ArrayList<String>)source.readSerializable(); deletedIDs = (ArrayList<String>)source.readSerializable(); + newIDs = source.createBooleanArray(); primaryIDChanged = source.readByte() != 0; moddedKeys = source.createBooleanArray(); byte[] tmp = source.createByteArray(); @@ -72,6 +74,7 @@ public class SaveKeyringParcel implements Parcelable { destination.writeSerializable(userIDs); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); + destination.writeBooleanArray(newIDs); destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); byte[] tmp = null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 2cdd64f4a..a9ab49c76 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -584,6 +584,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener saveParams.userIDs = getUserIds(mUserIdsView); saveParams.originalIDs = mUserIdsView.getOriginalIDs(); saveParams.deletedIDs = mUserIdsView.getDeletedIDs(); + saveParams.newIDs = toPrimitiveArray(mUserIdsView.getNewIDFlags()); saveParams.primaryIDChanged = mUserIdsView.primaryChanged(); saveParams.moddedKeys = toPrimitiveArray(mKeysView.getNeedsSavingArray()); saveParams.deletedKeys = mKeysView.getDeletedKeys(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 6c7737e6d..e99a4ef04 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -252,6 +252,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } + public List<Boolean> getNewIDFlags() + { + ArrayList<Boolean> mList = new ArrayList<Boolean>(); + for (int i = 0; i < mEditors.getChildCount(); ++i) { + Editor editor = (Editor) mEditors.getChildAt(i); + mList.add(((UserIdEditor)editor).getIsNewID()); + } + return mList; + } + public List<Boolean> getNewKeysArray() { ArrayList<Boolean> mList = new ArrayList<Boolean>(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index d4b15613a..cf0cb6d44 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -261,4 +261,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene { return mOriginalID; } + + public boolean getIsNewID() { return mIsNewId; } } |