pass through which keys are new

This commit is contained in:
Ashley Hughes 2014-02-22 16:08:38 +00:00
parent fab74590eb
commit fa533dda32
5 changed files with 29 additions and 3 deletions

View File

@ -345,7 +345,7 @@ public class PgpKeyOperation {
updateProgress(R.string.progress_done, 100, 100);
}
public void buildSecretKey(ArrayList<String> userIds, ArrayList<String> OriginalIDs, ArrayList<String> deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList<PGPSecretKey> deleted_keys, ArrayList<GregorianCalendar> keysExpiryDates, ArrayList<Integer> keysUsages, String newPassPhrase, String oldPassPhrase, ArrayList<PGPSecretKey> keys) throws PgpGeneralException,
public void buildSecretKey(ArrayList<String> userIds, ArrayList<String> OriginalIDs, ArrayList<String> deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList<PGPSecretKey> deleted_keys, ArrayList<GregorianCalendar> keysExpiryDates, ArrayList<Integer> keysUsages, String newPassPhrase, String oldPassPhrase, boolean[] new_keys, ArrayList<PGPSecretKey> keys) throws PgpGeneralException,
PGPException, SignatureException, IOException {
updateProgress(R.string.progress_building_key, 0, 100);
@ -490,6 +490,11 @@ public class PgpKeyOperation {
masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(),
unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor);
//updating master is slightly different to updating the others
if (modded_keys[0]) {
}
updateProgress(R.string.progress_adding_sub_keys, 40, 100);
for (int i = 1; i < keys.size(); ++i) {
@ -549,7 +554,7 @@ public class PgpKeyOperation {
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
//must copy with new passphrase... new keys will have an empty passphrase... pass in boolean array to mark new key?
updateProgress(R.string.progress_saving_key_ring, 90, 100);
ProviderHelper.saveKeyRing(mContext, secretKeyRing);

View File

@ -138,6 +138,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
public static final String SAVE_KEYRING_DELETED_IDS = "deleted_ids";
public static final String SAVE_KEYRING_MODDED_KEYS = "modified_keys";
public static final String SAVE_KEYRING_DELETED_KEYS = "deleted_keys";
public static final String SAVE_KEYRING_NEW_KEYS = "new_keys";
// generate key
public static final String GENERATE_KEY_ALGORITHM = "algorithm";
@ -548,6 +549,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
ArrayList<String> original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS);
ArrayList<String> deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS);
boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS);
boolean[] new_keys = data.getBooleanArray(SAVE_KEYRING_NEW_KEYS);
ArrayList<PGPSecretKey> deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data
.getByteArray(SAVE_KEYRING_DELETED_KEYS));
boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED);
@ -563,7 +565,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
} else {
keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, primaryChanged,
modded_keys, deletedKeys, keysExpiryDates, keysUsages, newPassPhrase,
oldPassPhrase, keys);
oldPassPhrase, new_keys, keys);
}
PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase);

View File

@ -597,6 +597,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
toPrimitiveArray(mKeysView.getNeedsSavingArray()));
data.putBoolean(KeychainIntentService.SAVE_KEYRING_PRIMARY_ID_CHANGED,
mUserIdsView.primaryChanged());
data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_NEW_KEYS,
toPrimitiveArray(mKeysView.getNewKeysArray()));
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

View File

@ -314,4 +314,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
return retval;
}
public boolean getIsNewKey()
{
return mIsNewKey;
}
}

View File

@ -223,6 +223,18 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return mList;
}
public List<Boolean> getNewKeysArray()
{
ArrayList<Boolean> mList = new ArrayList<Boolean>();
if (mType == Id.type.key) {
for (int i = 0; i < mEditors.getChildCount(); ++i) {
KeyEditor editor = (KeyEditor) mEditors.getChildAt(i);
mList.add(editor.getIsNewKey());
}
}
return mList;
}
/** {@inheritDoc} */
public void onClick(View v) {
if (canEdit) {