mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
minor fixes to make key retrieval more stable
This commit is contained in:
parent
d1fa1895f1
commit
d483feb64c
@ -648,6 +648,9 @@ public class Apg {
|
||||
}
|
||||
|
||||
public static PGPPublicKey getMasterKey(PGPPublicKeyRing keyRing) {
|
||||
if (keyRing == null) {
|
||||
return null;
|
||||
}
|
||||
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(keyRing.getPublicKeys())) {
|
||||
if (key.isMasterKey()) {
|
||||
return key;
|
||||
@ -658,6 +661,9 @@ public class Apg {
|
||||
}
|
||||
|
||||
public static PGPSecretKey getMasterKey(PGPSecretKeyRing keyRing) {
|
||||
if (keyRing == null) {
|
||||
return null;
|
||||
}
|
||||
for (PGPSecretKey key : new IterableIterator<PGPSecretKey>(keyRing.getSecretKeys())) {
|
||||
if (key.isMasterKey()) {
|
||||
return key;
|
||||
|
@ -25,6 +25,7 @@ import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
@ -42,6 +43,7 @@ public class AskForSecretKeyPassPhrase {
|
||||
alert.setTitle(R.string.title_authentification);
|
||||
|
||||
final PGPSecretKey secretKey;
|
||||
final Activity activity = context;
|
||||
|
||||
if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
|
||||
secretKey = null;
|
||||
@ -49,7 +51,16 @@ public class AskForSecretKeyPassPhrase {
|
||||
} else {
|
||||
secretKey = Apg.getMasterKey(Apg.getSecretKeyRing(secretKeyId));
|
||||
if (secretKey == null) {
|
||||
return null;
|
||||
alert.setTitle(R.string.title_keyNotFound);
|
||||
alert.setMessage(context.getString(R.string.keyNotFound, secretKeyId));
|
||||
alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
activity.removeDialog(Id.dialog.pass_phrase);
|
||||
}
|
||||
});
|
||||
alert.setCancelable(false);
|
||||
return alert.create();
|
||||
}
|
||||
String userId = Apg.getMainUserIdSafe(context, secretKey);
|
||||
alert.setMessage(context.getString(R.string.passPhraseFor, userId));
|
||||
@ -65,7 +76,6 @@ public class AskForSecretKeyPassPhrase {
|
||||
alert.setView(view);
|
||||
|
||||
final PassPhraseCallbackInterface cb = callback;
|
||||
final Activity activity = context;
|
||||
alert.setPositiveButton(android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
Loading…
Reference in New Issue
Block a user