mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 11:35:07 -05:00
removed unused code, fixed certification bug when editing existing key
This commit is contained in:
parent
cadb5d3b1f
commit
3466892010
@ -311,10 +311,10 @@ public class PGPMain {
|
||||
|
||||
updateProgress(progress, R.string.progress_buildingKey, 0, 100);
|
||||
|
||||
if (oldPassPhrase == null || oldPassPhrase.equals("")) {
|
||||
if (oldPassPhrase == null) {
|
||||
oldPassPhrase = "";
|
||||
}
|
||||
if (newPassPhrase == null || newPassPhrase.equals("")) {
|
||||
if (newPassPhrase == null) {
|
||||
newPassPhrase = "";
|
||||
}
|
||||
|
||||
@ -329,9 +329,13 @@ public class PGPMain {
|
||||
PGPSecretKey masterKey = keys.get(0);
|
||||
PGPPublicKey masterPublicKey = masterKey.getPublicKey();
|
||||
|
||||
// Somehow, the PGPPublicKey already has an empty certification attached to it, we remove
|
||||
// that now before adding the new ones
|
||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, "");
|
||||
// Somehow, the PGPPublicKey already has an empty certification attached to it when the
|
||||
// keyRing is generated the first time, we remove that when it exists, before adding the new
|
||||
// ones
|
||||
PGPPublicKey masterPublicKeyRmCert = PGPPublicKey.removeCertification(masterPublicKey, "");
|
||||
if (masterPublicKeyRmCert != null) {
|
||||
masterPublicKey = masterPublicKeyRmCert;
|
||||
}
|
||||
|
||||
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
|
||||
BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray());
|
||||
@ -611,13 +615,13 @@ public class PGPMain {
|
||||
updateProgress(progress, i * 100 / keyRingIds.size(), 100);
|
||||
|
||||
// try to get it as a PGPPublicKeyRing, if that fails try to get it as a SecretKeyRing
|
||||
PGPPublicKeyRing publicKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
||||
keyRingIds.get(i));
|
||||
PGPPublicKeyRing publicKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||
context, keyRingIds.get(i));
|
||||
if (publicKeyRing != null) {
|
||||
publicKeyRing.encode(out);
|
||||
} else {
|
||||
PGPSecretKeyRing secretKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context,
|
||||
keyRingIds.get(i));
|
||||
PGPSecretKeyRing secretKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(
|
||||
context, keyRingIds.get(i));
|
||||
if (secretKeyRing != null) {
|
||||
secretKeyRing.encode(out);
|
||||
} else {
|
||||
@ -729,7 +733,8 @@ public class PGPMain {
|
||||
}
|
||||
|
||||
if (signatureKeyId != Id.key.none) {
|
||||
signingKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context, signatureKeyId);
|
||||
signingKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context,
|
||||
signatureKeyId);
|
||||
signingKey = PGPHelper.getSigningKey(context, signatureKeyId);
|
||||
if (signingKey == null) {
|
||||
throw new ApgGeneralException(context.getString(R.string.error_signatureFailed));
|
||||
@ -1098,7 +1103,8 @@ public class PGPMain {
|
||||
if (passphrase == null || passphrase.length() <= 0) {
|
||||
throw new ApgGeneralException("Unable to obtain passphrase");
|
||||
} else {
|
||||
PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context, pubKeyId);
|
||||
PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
||||
pubKeyId);
|
||||
|
||||
PGPSecretKey signingKey = PGPHelper.getSigningKey(context, masterKeyId);
|
||||
if (signingKey == null) {
|
||||
@ -1356,10 +1362,10 @@ public class PGPMain {
|
||||
signatureIndex = i;
|
||||
signatureKeyId = signature.getKeyID();
|
||||
String userId = null;
|
||||
PGPPublicKeyRing sigKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
||||
signatureKeyId);
|
||||
if (sigKeyRing != null) {
|
||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
||||
PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||
context, signatureKeyId);
|
||||
if (signKeyRing != null) {
|
||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(signKeyRing));
|
||||
}
|
||||
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
||||
break;
|
||||
@ -1522,10 +1528,10 @@ public class PGPMain {
|
||||
} else {
|
||||
signatureKeyId = signature.getKeyID();
|
||||
String userId = null;
|
||||
PGPPublicKeyRing sigKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
||||
signatureKeyId);
|
||||
if (sigKeyRing != null) {
|
||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
||||
PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||
context, signatureKeyId);
|
||||
if (signKeyRing != null) {
|
||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(signKeyRing));
|
||||
}
|
||||
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
||||
break;
|
||||
|
@ -28,7 +28,6 @@ import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.spongycastle.openpgp.PGPKeyRing;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
@ -743,7 +742,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
/* Operation */
|
||||
HkpKeyServer server = new HkpKeyServer(keyServer);
|
||||
|
||||
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, keyRingId);
|
||||
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this,
|
||||
keyRingId);
|
||||
if (keyring != null) {
|
||||
boolean uploaded = PGPMain.uploadKeyRingToServer(server,
|
||||
(PGPPublicKeyRing) keyring);
|
||||
|
@ -51,12 +51,6 @@ public class KeyListFragment extends ExpandableListFragment {
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
// TODO: better inflate menu from xml
|
||||
// android.view.MenuInflater inflater = (android.view.MenuInflater) mActivity
|
||||
// .getMenuInflater();
|
||||
// menu.setHeaderTitle(R.string.checkbox_list_context_title);
|
||||
// inflater.inflate(R.menu.checkbox_list_context, menu);
|
||||
|
||||
menu.add(0, Id.menu.export, 0, R.string.menu_exportKey);
|
||||
menu.add(0, Id.menu.delete, 1, R.string.menu_deleteKey);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class KeyListPublicActivity extends KeyListActivity {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case Id.menu.option.key_server: {
|
||||
startActivity(new Intent(this, KeyServerQueryActivity.class));
|
||||
startActivityForResult(new Intent(this, KeyServerQueryActivity.class), 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -73,12 +73,6 @@ public class KeyListPublicFragment extends KeyListFragment implements
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
// TODO: better inflate menu from xml
|
||||
// android.view.MenuInflater inflater = (android.view.MenuInflater) mActivity
|
||||
// .getMenuInflater();
|
||||
// menu.setHeaderTitle(R.string.checkbox_list_context_title);
|
||||
// inflater.inflate(R.menu.checkbox_list_context, menu);
|
||||
|
||||
menu.add(0, Id.menu.update, 1, R.string.menu_updateKey);
|
||||
menu.add(0, Id.menu.exportToServer, 1, R.string.menu_exportKeyToServer);
|
||||
menu.add(0, Id.menu.signKey, 1, R.string.menu_signKey);
|
||||
|
@ -112,32 +112,13 @@ public class KeyListSecretActivity extends KeyListActivity {
|
||||
private void createKey() {
|
||||
PGPMain.setEditPassPhrase("");
|
||||
Intent intent = new Intent(EditKeyActivity.ACTION_CREATE_KEY);
|
||||
startActivityForResult(intent, Id.message.create_key);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
|
||||
private void editKey(long keyId) {
|
||||
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
||||
intent.putExtra(EditKeyActivity.EXTRA_KEY_ID, keyId);
|
||||
startActivityForResult(intent, Id.message.edit_key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case Id.message.create_key: // intentionally no break
|
||||
case Id.message.edit_key: {
|
||||
if (resultCode == RESULT_OK) {
|
||||
// refreshList();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,23 +73,6 @@ public class KeyListSecretFragment extends KeyListFragment implements
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
// TODO: better inflate menu from xml
|
||||
// android.view.MenuInflater inflater = (android.view.MenuInflater) mActivity
|
||||
// .getMenuInflater();
|
||||
// menu.setHeaderTitle(R.string.checkbox_list_context_title);
|
||||
// inflater.inflate(R.menu.checkbox_list_context, menu);
|
||||
|
||||
// ExpandableListView.ExpandableListContextMenuInfo info =
|
||||
// (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
||||
// int type = ExpandableListView.getPackedPositionType(info.packedPosition);
|
||||
//
|
||||
// if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
|
||||
// // TODO: user id? menu.setHeaderTitle("Key");
|
||||
// menu.add(0, Id.menu.edit, 0, R.string.menu_editKey);
|
||||
// menu.add(0, Id.menu.export, 1, R.string.menu_exportKey);
|
||||
// menu.add(0, Id.menu.delete, 2, R.string.menu_deleteKey);
|
||||
// menu.add(0, Id.menu.share_qr_code, 2, R.string.menu_share);
|
||||
// }
|
||||
|
||||
menu.add(0, Id.menu.edit, 0, R.string.menu_editKey);
|
||||
menu.add(0, Id.menu.share_qr_code, 2, R.string.menu_share);
|
||||
|
Loading…
Reference in New Issue
Block a user