update OpenPgpSignatureResult to use enums
This commit is contained in:
@@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.pgp;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||
import org.openintents.openpgp.OpenPgpSignatureResult.SenderStatusResult;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
||||
import org.openintents.openpgp.util.OpenPgpUtils.UserId;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@@ -42,7 +43,7 @@ public class OpenPgpSignatureResultBuilder {
|
||||
private ArrayList<String> mUserIds = new ArrayList<>();
|
||||
private ArrayList<String> mConfirmedUserIds;
|
||||
private long mKeyId;
|
||||
private int mSenderStatus;
|
||||
private SenderStatusResult mSenderStatusResult;
|
||||
|
||||
// builder
|
||||
private boolean mSignatureAvailable = false;
|
||||
@@ -125,14 +126,14 @@ public class OpenPgpSignatureResultBuilder {
|
||||
|
||||
if (mSenderAddress != null) {
|
||||
if (userIdListContainsAddress(mSenderAddress, confirmedUserIds)) {
|
||||
setSenderStatus(OpenPgpSignatureResult.SENDER_RESULT_UID_CONFIRMED);
|
||||
mSenderStatusResult = SenderStatusResult.USER_ID_CONFIRMED;
|
||||
} else if (userIdListContainsAddress(mSenderAddress, allUserIds)) {
|
||||
setSenderStatus(OpenPgpSignatureResult.SENDER_RESULT_UID_UNCONFIRMED);
|
||||
mSenderStatusResult = SenderStatusResult.USER_ID_UNCONFIRMED;
|
||||
} else {
|
||||
setSenderStatus(OpenPgpSignatureResult.SENDER_RESULT_UID_MISSING);
|
||||
mSenderStatusResult = SenderStatusResult.USER_ID_MISSING;
|
||||
}
|
||||
} else {
|
||||
setSenderStatus(OpenPgpSignatureResult.SENDER_RESULT_NO_SENDER);
|
||||
mSenderStatusResult = SenderStatusResult.UNKNOWN;
|
||||
}
|
||||
|
||||
} catch (NotFoundException e) {
|
||||
@@ -189,14 +190,11 @@ public class OpenPgpSignatureResultBuilder {
|
||||
}
|
||||
|
||||
return OpenPgpSignatureResult.createWithValidSignature(
|
||||
signatureStatus, mPrimaryUserId, mKeyId, mUserIds, mConfirmedUserIds, mSenderStatus);
|
||||
signatureStatus, mPrimaryUserId, mKeyId, mUserIds, mConfirmedUserIds, mSenderStatusResult);
|
||||
}
|
||||
|
||||
public void setSenderAddress(String senderAddress) {
|
||||
mSenderAddress = senderAddress;
|
||||
}
|
||||
|
||||
public void setSenderStatus(int senderStatus) {
|
||||
mSenderStatus = senderStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,11 +519,11 @@ public class OpenPgpService extends Service {
|
||||
signatureResult.getKeyId()));
|
||||
break;
|
||||
}
|
||||
case OpenPgpSignatureResult.RESULT_VALID_CONFIRMED:
|
||||
case OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED:
|
||||
case OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED:
|
||||
case OpenPgpSignatureResult.RESULT_VALID_KEY_UNCONFIRMED:
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED:
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED:
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_INSECURE: {
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE: {
|
||||
// If signature key is known, return PendingIntent to show key
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT,
|
||||
piFactory.createShowKeyPendingIntent(data, signatureResult.getKeyId()));
|
||||
@@ -546,7 +546,7 @@ public class OpenPgpService extends Service {
|
||||
|
||||
if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 8) {
|
||||
// RESULT_INVALID_INSECURE has been added in version 8, fallback to RESULT_INVALID_SIGNATURE
|
||||
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_INSECURE) {
|
||||
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE) {
|
||||
signatureResult = OpenPgpSignatureResult.createWithInvalidSignature();
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
||||
// revoked/expired subkeys
|
||||
boolean isRevoked = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED;
|
||||
boolean isExpired = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED;
|
||||
boolean isInsecure = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_INSECURE;
|
||||
boolean isInsecure = mSignatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE;
|
||||
boolean isVerified = data.getInt(INDEX_VERIFIED) > 0;
|
||||
boolean isYours = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.RESULT_VALID_CONFIRMED: {
|
||||
case OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED: {
|
||||
sigText = R.string.decrypt_result_signature_certified;
|
||||
sigIcon = R.drawable.status_signature_verified_cutout_24dp;
|
||||
sigColor = R.color.key_flag_green;
|
||||
@@ -516,7 +516,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.RESULT_VALID_UNCONFIRMED: {
|
||||
case OpenPgpSignatureResult.RESULT_VALID_KEY_UNCONFIRMED: {
|
||||
sigText = R.string.decrypt_result_signature_uncertified;
|
||||
sigIcon = R.drawable.status_signature_unverified_cutout_24dp;
|
||||
sigColor = R.color.key_flag_orange;
|
||||
@@ -552,7 +552,7 @@ public class KeyFormattingUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_INSECURE: {
|
||||
case OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE: {
|
||||
sigText = R.string.decrypt_result_insecure_cryptography;
|
||||
sigIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
|
||||
Reference in New Issue
Block a user