pass through info that keys are new without relying on new keys orginally being empty

This commit is contained in:
Ashley Hughes 2014-04-01 23:37:13 +01:00
parent abfe416503
commit 2ad616ed3f
5 changed files with 22 additions and 2 deletions

View File

@ -478,7 +478,9 @@ public class PgpKeyOperation {
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
sigList.add(new Pair<String, PGPSignature>(userId, certification)); sigList.add(new Pair<String, PGPSignature>(userId, certification));
} }
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); if (!saveParcel.newIDs[userIDIndex]) {
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
}
userIDIndex++; userIDIndex++;
} }
for (Pair<String, PGPSignature> toAdd : sigList) { for (Pair<String, PGPSignature> toAdd : sigList) {
@ -500,7 +502,9 @@ public class PgpKeyOperation {
sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); sGen.setUnhashedSubpackets(unhashedPacketsGen.generate());
} }
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); 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); masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
} }
userIDIndex++; userIDIndex++;

View File

@ -32,6 +32,7 @@ public class SaveKeyringParcel implements Parcelable {
public ArrayList<String> userIDs; public ArrayList<String> userIDs;
public ArrayList<String> originalIDs; public ArrayList<String> originalIDs;
public ArrayList<String> deletedIDs; public ArrayList<String> deletedIDs;
public boolean[] newIDs;
public boolean primaryIDChanged; public boolean primaryIDChanged;
public boolean[] moddedKeys; public boolean[] moddedKeys;
public ArrayList<PGPSecretKey> deletedKeys; public ArrayList<PGPSecretKey> deletedKeys;
@ -50,6 +51,7 @@ public class SaveKeyringParcel implements Parcelable {
userIDs = (ArrayList<String>)source.readSerializable(); userIDs = (ArrayList<String>)source.readSerializable();
originalIDs = (ArrayList<String>)source.readSerializable(); originalIDs = (ArrayList<String>)source.readSerializable();
deletedIDs = (ArrayList<String>)source.readSerializable(); deletedIDs = (ArrayList<String>)source.readSerializable();
newIDs = source.createBooleanArray();
primaryIDChanged = source.readByte() != 0; primaryIDChanged = source.readByte() != 0;
moddedKeys = source.createBooleanArray(); moddedKeys = source.createBooleanArray();
byte[] tmp = source.createByteArray(); 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(userIDs); //might not be the best method to store.
destination.writeSerializable(originalIDs); destination.writeSerializable(originalIDs);
destination.writeSerializable(deletedIDs); destination.writeSerializable(deletedIDs);
destination.writeBooleanArray(newIDs);
destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeByte((byte) (primaryIDChanged ? 1 : 0));
destination.writeBooleanArray(moddedKeys); destination.writeBooleanArray(moddedKeys);
byte[] tmp = null; byte[] tmp = null;

View File

@ -584,6 +584,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
saveParams.userIDs = getUserIds(mUserIdsView); saveParams.userIDs = getUserIds(mUserIdsView);
saveParams.originalIDs = mUserIdsView.getOriginalIDs(); saveParams.originalIDs = mUserIdsView.getOriginalIDs();
saveParams.deletedIDs = mUserIdsView.getDeletedIDs(); saveParams.deletedIDs = mUserIdsView.getDeletedIDs();
saveParams.newIDs = toPrimitiveArray(mUserIdsView.getNewIDFlags());
saveParams.primaryIDChanged = mUserIdsView.primaryChanged(); saveParams.primaryIDChanged = mUserIdsView.primaryChanged();
saveParams.moddedKeys = toPrimitiveArray(mKeysView.getNeedsSavingArray()); saveParams.moddedKeys = toPrimitiveArray(mKeysView.getNeedsSavingArray());
saveParams.deletedKeys = mKeysView.getDeletedKeys(); saveParams.deletedKeys = mKeysView.getDeletedKeys();

View File

@ -252,6 +252,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return mList; 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() public List<Boolean> getNewKeysArray()
{ {
ArrayList<Boolean> mList = new ArrayList<Boolean>(); ArrayList<Boolean> mList = new ArrayList<Boolean>();

View File

@ -261,4 +261,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
{ {
return mOriginalID; return mOriginalID;
} }
public boolean getIsNewID() { return mIsNewId; }
} }