pass through deleted keys

This commit is contained in:
Ashley Hughes 2014-02-15 14:45:57 +00:00
parent ba62d30563
commit c9d9c800b6
4 changed files with 21 additions and 4 deletions

View File

@ -198,7 +198,7 @@ public class PgpKeyOperation {
}
public void buildSecretKey(ArrayList<String> userIds, ArrayList<String> OriginalIDs, ArrayList<String> deletedIDs, ArrayList<PGPSecretKey> keys, boolean[] modded_keys, String newPassPhrase, ArrayList<GregorianCalendar> keysExpiryDates, String oldPassPhrase, ArrayList<Integer> keysUsages) throws PgpGeneralException,
public void buildSecretKey(ArrayList<String> userIds, ArrayList<String> OriginalIDs, ArrayList<String> deletedIDs, ArrayList<PGPSecretKey> keys, boolean[] modded_keys, ArrayList<PGPSecretKey> deleted_keys, ArrayList<GregorianCalendar> keysExpiryDates, ArrayList<Integer> keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException,
PGPException, SignatureException, IOException {
Log.d(Constants.TAG, "userIds: " + userIds.toString());

View File

@ -137,6 +137,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
public static final String SAVE_KEYRING_ORIGINAL_IDS = "original_ids";
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";
// generate key
public static final String GENERATE_KEY_ALGORITHM = "algorithm";
@ -537,6 +538,8 @@ 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);
ArrayList<PGPSecretKey> deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data
.getByteArray(SAVE_KEYRING_DELETED_KEYS));
long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
@ -548,7 +551,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
oldPassPhrase, newPassPhrase);
} else {
keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, keys, modded_keys,
newPassPhrase, keysExpiryDates, oldPassPhrase, keysUsages);
deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase);
}
PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase);

View File

@ -580,6 +580,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
ArrayList<PGPSecretKey> keys = getKeys(mKeysView);
data.putByteArray(KeychainIntentService.SAVE_KEYRING_KEYS,
PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys));
ArrayList<PGPSecretKey> dKeys = mKeysView.getDeletedKeys();
data.putByteArray(KeychainIntentService.SAVE_KEYRING_DELETED_KEYS,
PgpConversionHelper.PGPSecretKeyArrayListToBytes(dKeys));
data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES,
getKeysUsages(mKeysView));
data.putSerializable(KeychainIntentService.SAVE_KEYRING_KEYS_EXPIRY_DATES,

View File

@ -66,6 +66,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
private boolean canEdit = true;
private boolean oldItemDeleted = false;
private ArrayList<String> mDeletedIDs = new ArrayList<String>();
private ArrayList<PGPSecretKey> mDeletedKeys = new ArrayList<PGPSecretKey>();
private ActionBarActivity mActivity;
@ -136,8 +137,13 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
/** {@inheritDoc} */
public void onDeleted(Editor editor, boolean wasNewItem) {
oldItemDeleted |= !wasNewItem;
if (oldItemDeleted && mType == Id.type.user_id)
mDeletedIDs.add(((UserIdEditor)editor).getOriginalID());
if (oldItemDeleted) {
if (mType == Id.type.user_id)
mDeletedIDs.add(((UserIdEditor)editor).getOriginalID());
else if (mType == Id.type.key)
mDeletedKeys.add(((KeyEditor)editor).getValue());
}
this.updateEditorsVisible();
if (mEditorListener != null) {
mEditorListener.onEdited();
@ -186,6 +192,11 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return mDeletedIDs;
}
public ArrayList<PGPSecretKey> getDeletedKeys()
{
return mDeletedKeys;
}
public List<Boolean> getNeedsSavingArray()
{
ArrayList<Boolean> mList = new ArrayList<Boolean>();