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) {
|
public static PGPPublicKey getMasterKey(PGPPublicKeyRing keyRing) {
|
||||||
|
if (keyRing == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(keyRing.getPublicKeys())) {
|
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(keyRing.getPublicKeys())) {
|
||||||
if (key.isMasterKey()) {
|
if (key.isMasterKey()) {
|
||||||
return key;
|
return key;
|
||||||
@ -658,6 +661,9 @@ public class Apg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PGPSecretKey getMasterKey(PGPSecretKeyRing keyRing) {
|
public static PGPSecretKey getMasterKey(PGPSecretKeyRing keyRing) {
|
||||||
|
if (keyRing == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (PGPSecretKey key : new IterableIterator<PGPSecretKey>(keyRing.getSecretKeys())) {
|
for (PGPSecretKey key : new IterableIterator<PGPSecretKey>(keyRing.getSecretKeys())) {
|
||||||
if (key.isMasterKey()) {
|
if (key.isMasterKey()) {
|
||||||
return key;
|
return key;
|
||||||
|
@ -25,6 +25,7 @@ import android.app.AlertDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -42,6 +43,7 @@ public class AskForSecretKeyPassPhrase {
|
|||||||
alert.setTitle(R.string.title_authentification);
|
alert.setTitle(R.string.title_authentification);
|
||||||
|
|
||||||
final PGPSecretKey secretKey;
|
final PGPSecretKey secretKey;
|
||||||
|
final Activity activity = context;
|
||||||
|
|
||||||
if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
|
if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
|
||||||
secretKey = null;
|
secretKey = null;
|
||||||
@ -49,7 +51,16 @@ public class AskForSecretKeyPassPhrase {
|
|||||||
} else {
|
} else {
|
||||||
secretKey = Apg.getMasterKey(Apg.getSecretKeyRing(secretKeyId));
|
secretKey = Apg.getMasterKey(Apg.getSecretKeyRing(secretKeyId));
|
||||||
if (secretKey == null) {
|
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);
|
String userId = Apg.getMainUserIdSafe(context, secretKey);
|
||||||
alert.setMessage(context.getString(R.string.passPhraseFor, userId));
|
alert.setMessage(context.getString(R.string.passPhraseFor, userId));
|
||||||
@ -65,7 +76,6 @@ public class AskForSecretKeyPassPhrase {
|
|||||||
alert.setView(view);
|
alert.setView(view);
|
||||||
|
|
||||||
final PassPhraseCallbackInterface cb = callback;
|
final PassPhraseCallbackInterface cb = callback;
|
||||||
final Activity activity = context;
|
|
||||||
alert.setPositiveButton(android.R.string.ok,
|
alert.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user