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);
|
updateProgress(progress, R.string.progress_buildingKey, 0, 100);
|
||||||
|
|
||||||
if (oldPassPhrase == null || oldPassPhrase.equals("")) {
|
if (oldPassPhrase == null) {
|
||||||
oldPassPhrase = "";
|
oldPassPhrase = "";
|
||||||
}
|
}
|
||||||
if (newPassPhrase == null || newPassPhrase.equals("")) {
|
if (newPassPhrase == null) {
|
||||||
newPassPhrase = "";
|
newPassPhrase = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,9 +329,13 @@ public class PGPMain {
|
|||||||
PGPSecretKey masterKey = keys.get(0);
|
PGPSecretKey masterKey = keys.get(0);
|
||||||
PGPPublicKey masterPublicKey = masterKey.getPublicKey();
|
PGPPublicKey masterPublicKey = masterKey.getPublicKey();
|
||||||
|
|
||||||
// Somehow, the PGPPublicKey already has an empty certification attached to it, we remove
|
// Somehow, the PGPPublicKey already has an empty certification attached to it when the
|
||||||
// that now before adding the new ones
|
// keyRing is generated the first time, we remove that when it exists, before adding the new
|
||||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, "");
|
// ones
|
||||||
|
PGPPublicKey masterPublicKeyRmCert = PGPPublicKey.removeCertification(masterPublicKey, "");
|
||||||
|
if (masterPublicKeyRmCert != null) {
|
||||||
|
masterPublicKey = masterPublicKeyRmCert;
|
||||||
|
}
|
||||||
|
|
||||||
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
|
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
|
||||||
BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray());
|
BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray());
|
||||||
@ -611,13 +615,13 @@ public class PGPMain {
|
|||||||
updateProgress(progress, i * 100 / keyRingIds.size(), 100);
|
updateProgress(progress, i * 100 / keyRingIds.size(), 100);
|
||||||
|
|
||||||
// try to get it as a PGPPublicKeyRing, if that fails try to get it as a SecretKeyRing
|
// try to get it as a PGPPublicKeyRing, if that fails try to get it as a SecretKeyRing
|
||||||
PGPPublicKeyRing publicKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
PGPPublicKeyRing publicKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||||
keyRingIds.get(i));
|
context, keyRingIds.get(i));
|
||||||
if (publicKeyRing != null) {
|
if (publicKeyRing != null) {
|
||||||
publicKeyRing.encode(out);
|
publicKeyRing.encode(out);
|
||||||
} else {
|
} else {
|
||||||
PGPSecretKeyRing secretKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context,
|
PGPSecretKeyRing secretKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(
|
||||||
keyRingIds.get(i));
|
context, keyRingIds.get(i));
|
||||||
if (secretKeyRing != null) {
|
if (secretKeyRing != null) {
|
||||||
secretKeyRing.encode(out);
|
secretKeyRing.encode(out);
|
||||||
} else {
|
} else {
|
||||||
@ -729,7 +733,8 @@ public class PGPMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (signatureKeyId != Id.key.none) {
|
if (signatureKeyId != Id.key.none) {
|
||||||
signingKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context, signatureKeyId);
|
signingKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context,
|
||||||
|
signatureKeyId);
|
||||||
signingKey = PGPHelper.getSigningKey(context, signatureKeyId);
|
signingKey = PGPHelper.getSigningKey(context, signatureKeyId);
|
||||||
if (signingKey == null) {
|
if (signingKey == null) {
|
||||||
throw new ApgGeneralException(context.getString(R.string.error_signatureFailed));
|
throw new ApgGeneralException(context.getString(R.string.error_signatureFailed));
|
||||||
@ -1098,7 +1103,8 @@ public class PGPMain {
|
|||||||
if (passphrase == null || passphrase.length() <= 0) {
|
if (passphrase == null || passphrase.length() <= 0) {
|
||||||
throw new ApgGeneralException("Unable to obtain passphrase");
|
throw new ApgGeneralException("Unable to obtain passphrase");
|
||||||
} else {
|
} else {
|
||||||
PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context, pubKeyId);
|
PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
||||||
|
pubKeyId);
|
||||||
|
|
||||||
PGPSecretKey signingKey = PGPHelper.getSigningKey(context, masterKeyId);
|
PGPSecretKey signingKey = PGPHelper.getSigningKey(context, masterKeyId);
|
||||||
if (signingKey == null) {
|
if (signingKey == null) {
|
||||||
@ -1356,10 +1362,10 @@ public class PGPMain {
|
|||||||
signatureIndex = i;
|
signatureIndex = i;
|
||||||
signatureKeyId = signature.getKeyID();
|
signatureKeyId = signature.getKeyID();
|
||||||
String userId = null;
|
String userId = null;
|
||||||
PGPPublicKeyRing sigKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||||
signatureKeyId);
|
context, signatureKeyId);
|
||||||
if (sigKeyRing != null) {
|
if (signKeyRing != null) {
|
||||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(signKeyRing));
|
||||||
}
|
}
|
||||||
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
||||||
break;
|
break;
|
||||||
@ -1522,10 +1528,10 @@ public class PGPMain {
|
|||||||
} else {
|
} else {
|
||||||
signatureKeyId = signature.getKeyID();
|
signatureKeyId = signature.getKeyID();
|
||||||
String userId = null;
|
String userId = null;
|
||||||
PGPPublicKeyRing sigKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context,
|
PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||||
signatureKeyId);
|
context, signatureKeyId);
|
||||||
if (sigKeyRing != null) {
|
if (signKeyRing != null) {
|
||||||
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(sigKeyRing));
|
userId = PGPHelper.getMainUserId(PGPHelper.getMasterKey(signKeyRing));
|
||||||
}
|
}
|
||||||
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
returnData.putString(ApgService.RESULT_SIGNATURE_USER_ID, userId);
|
||||||
break;
|
break;
|
||||||
|
@ -28,7 +28,6 @@ import java.io.OutputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.spongycastle.openpgp.PGPKeyRing;
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
@ -743,7 +742,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
|||||||
/* Operation */
|
/* Operation */
|
||||||
HkpKeyServer server = new HkpKeyServer(keyServer);
|
HkpKeyServer server = new HkpKeyServer(keyServer);
|
||||||
|
|
||||||
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, keyRingId);
|
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this,
|
||||||
|
keyRingId);
|
||||||
if (keyring != null) {
|
if (keyring != null) {
|
||||||
boolean uploaded = PGPMain.uploadKeyRingToServer(server,
|
boolean uploaded = PGPMain.uploadKeyRingToServer(server,
|
||||||
(PGPPublicKeyRing) keyring);
|
(PGPPublicKeyRing) keyring);
|
||||||
|
@ -51,12 +51,6 @@ public class KeyListFragment extends ExpandableListFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, 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.export, 0, R.string.menu_exportKey);
|
||||||
menu.add(0, Id.menu.delete, 1, R.string.menu_deleteKey);
|
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) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case Id.menu.option.key_server: {
|
case Id.menu.option.key_server: {
|
||||||
startActivity(new Intent(this, KeyServerQueryActivity.class));
|
startActivityForResult(new Intent(this, KeyServerQueryActivity.class), 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,6 @@ public class KeyListPublicFragment extends KeyListFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, 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.update, 1, R.string.menu_updateKey);
|
||||||
menu.add(0, Id.menu.exportToServer, 1, R.string.menu_exportKeyToServer);
|
menu.add(0, Id.menu.exportToServer, 1, R.string.menu_exportKeyToServer);
|
||||||
menu.add(0, Id.menu.signKey, 1, R.string.menu_signKey);
|
menu.add(0, Id.menu.signKey, 1, R.string.menu_signKey);
|
||||||
|
@ -112,32 +112,13 @@ public class KeyListSecretActivity extends KeyListActivity {
|
|||||||
private void createKey() {
|
private void createKey() {
|
||||||
PGPMain.setEditPassPhrase("");
|
PGPMain.setEditPassPhrase("");
|
||||||
Intent intent = new Intent(EditKeyActivity.ACTION_CREATE_KEY);
|
Intent intent = new Intent(EditKeyActivity.ACTION_CREATE_KEY);
|
||||||
startActivityForResult(intent, Id.message.create_key);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editKey(long keyId) {
|
private void editKey(long keyId) {
|
||||||
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
||||||
intent.putExtra(EditKeyActivity.EXTRA_KEY_ID, keyId);
|
intent.putExtra(EditKeyActivity.EXTRA_KEY_ID, keyId);
|
||||||
startActivityForResult(intent, Id.message.edit_key);
|
startActivityForResult(intent, 0);
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,23 +73,6 @@ public class KeyListSecretFragment extends KeyListFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, 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.edit, 0, R.string.menu_editKey);
|
||||||
menu.add(0, Id.menu.share_qr_code, 2, R.string.menu_share);
|
menu.add(0, Id.menu.share_qr_code, 2, R.string.menu_share);
|
||||||
|
Loading…
Reference in New Issue
Block a user