handle override flag from service, and indicate support for it
This commit is contained in:
parent
8a4fd60165
commit
18b09b3bee
4 changed files with 29 additions and 9 deletions
|
@ -21,6 +21,7 @@ public final class CryptoResultAnnotation {
|
|||
private final OpenPgpError openPgpError;
|
||||
private final PendingIntent openPgpPendingIntent;
|
||||
private final PendingIntent openPgpInsecureWarningPendingIntent;
|
||||
private final boolean overrideCryptoWarning;
|
||||
|
||||
private final CryptoResultAnnotation encapsulatedResult;
|
||||
|
||||
|
@ -29,7 +30,8 @@ public final class CryptoResultAnnotation {
|
|||
OpenPgpSignatureResult openPgpSignatureResult,
|
||||
PendingIntent openPgpPendingIntent,
|
||||
PendingIntent openPgpInsecureWarningPendingIntent,
|
||||
OpenPgpError openPgpError) {
|
||||
OpenPgpError openPgpError,
|
||||
boolean overrideCryptoWarning) {
|
||||
this.errorType = errorType;
|
||||
this.replacementData = replacementData;
|
||||
|
||||
|
@ -38,6 +40,7 @@ public final class CryptoResultAnnotation {
|
|||
this.openPgpPendingIntent = openPgpPendingIntent;
|
||||
this.openPgpError = openPgpError;
|
||||
this.openPgpInsecureWarningPendingIntent = openPgpInsecureWarningPendingIntent;
|
||||
this.overrideCryptoWarning = overrideCryptoWarning;
|
||||
|
||||
this.encapsulatedResult = null;
|
||||
}
|
||||
|
@ -55,6 +58,7 @@ public final class CryptoResultAnnotation {
|
|||
this.openPgpPendingIntent = annotation.openPgpPendingIntent;
|
||||
this.openPgpInsecureWarningPendingIntent = annotation.openPgpInsecureWarningPendingIntent;
|
||||
this.openPgpError = annotation.openPgpError;
|
||||
this.overrideCryptoWarning = annotation.overrideCryptoWarning;
|
||||
|
||||
this.encapsulatedResult = encapsulatedResult;
|
||||
}
|
||||
|
@ -62,30 +66,33 @@ public final class CryptoResultAnnotation {
|
|||
|
||||
public static CryptoResultAnnotation createOpenPgpResultAnnotation(OpenPgpDecryptionResult decryptionResult,
|
||||
OpenPgpSignatureResult signatureResult, PendingIntent pendingIntent,
|
||||
PendingIntent insecureWarningPendingIntent, MimeBodyPart replacementPart) {
|
||||
PendingIntent insecureWarningPendingIntent, MimeBodyPart replacementPart,
|
||||
boolean overrideCryptoWarning) {
|
||||
return new CryptoResultAnnotation(CryptoError.OPENPGP_OK, replacementPart,
|
||||
decryptionResult, signatureResult, pendingIntent, insecureWarningPendingIntent, null);
|
||||
decryptionResult, signatureResult, pendingIntent, insecureWarningPendingIntent, null,
|
||||
overrideCryptoWarning);
|
||||
}
|
||||
|
||||
public static CryptoResultAnnotation createErrorAnnotation(CryptoError error, MimeBodyPart replacementData) {
|
||||
if (error == CryptoError.OPENPGP_OK) {
|
||||
throw new AssertionError("CryptoError must be actual error state!");
|
||||
}
|
||||
return new CryptoResultAnnotation(error, replacementData, null, null, null, null, null);
|
||||
return new CryptoResultAnnotation(error, replacementData, null, null, null, null, null, false);
|
||||
}
|
||||
|
||||
public static CryptoResultAnnotation createOpenPgpCanceledAnnotation() {
|
||||
return new CryptoResultAnnotation(CryptoError.OPENPGP_UI_CANCELED, null, null, null, null, null, null);
|
||||
return new CryptoResultAnnotation(CryptoError.OPENPGP_UI_CANCELED, null, null, null, null, null, null, false);
|
||||
}
|
||||
|
||||
public static CryptoResultAnnotation createOpenPgpSignatureErrorAnnotation(
|
||||
OpenPgpError error, MimeBodyPart replacementData) {
|
||||
return new CryptoResultAnnotation(
|
||||
CryptoError.OPENPGP_SIGNED_API_ERROR, replacementData, null, null, null, null, error);
|
||||
CryptoError.OPENPGP_SIGNED_API_ERROR, replacementData, null, null, null, null, error, false);
|
||||
}
|
||||
|
||||
public static CryptoResultAnnotation createOpenPgpEncryptionErrorAnnotation(OpenPgpError error) {
|
||||
return new CryptoResultAnnotation(CryptoError.OPENPGP_ENCRYPTED_API_ERROR, null, null, null, null, null, error);
|
||||
return new CryptoResultAnnotation(
|
||||
CryptoError.OPENPGP_ENCRYPTED_API_ERROR, null, null, null, null, null, error, false);
|
||||
}
|
||||
|
||||
public boolean isOpenPgpResult() {
|
||||
|
@ -147,6 +154,10 @@ public final class CryptoResultAnnotation {
|
|||
return replacementData;
|
||||
}
|
||||
|
||||
public boolean isOverrideSecurityWarning() {
|
||||
return overrideCryptoWarning;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public CryptoResultAnnotation withEncapsulatedResult(CryptoResultAnnotation resultAnnotation) {
|
||||
return new CryptoResultAnnotation(this, resultAnnotation);
|
||||
|
|
|
@ -251,6 +251,7 @@ public class MessageCryptoHelper {
|
|||
decryptIntent.putExtra(OpenPgpApi.EXTRA_SENDER_ADDRESS, from[0].getAddress());
|
||||
}
|
||||
|
||||
decryptIntent.putExtra(OpenPgpApi.EXTRA_SUPPORT_OVERRIDE_CRYPTO_WARNING, true);
|
||||
decryptIntent.putExtra(OpenPgpApi.EXTRA_DECRYPTION_RESULT, cachedDecryptionResult);
|
||||
|
||||
return decryptIntent;
|
||||
|
@ -515,9 +516,11 @@ public class MessageCryptoHelper {
|
|||
currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
|
||||
PendingIntent pendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
|
||||
PendingIntent insecureWarningPendingIntent = currentCryptoResult.getParcelableExtra(OpenPgpApi.RESULT_INSECURE_DETAIL_INTENT);
|
||||
boolean overrideCryptoWarning = currentCryptoResult.getBooleanExtra(
|
||||
OpenPgpApi.RESULT_OVERRIDE_CRYPTO_WARNING, false);
|
||||
|
||||
CryptoResultAnnotation resultAnnotation = CryptoResultAnnotation.createOpenPgpResultAnnotation(
|
||||
decryptionResult, signatureResult, pendingIntent, insecureWarningPendingIntent, outputPart);
|
||||
CryptoResultAnnotation resultAnnotation = CryptoResultAnnotation.createOpenPgpResultAnnotation(decryptionResult,
|
||||
signatureResult, pendingIntent, insecureWarningPendingIntent, outputPart, overrideCryptoWarning);
|
||||
|
||||
onCryptoOperationSuccess(resultAnnotation);
|
||||
}
|
||||
|
|
|
@ -72,6 +72,10 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (cryptoResultAnnotation.isOverrideSecurityWarning()) {
|
||||
overrideCryptoWarning = true;
|
||||
}
|
||||
|
||||
messageView.getMessageHeaderView().setCryptoStatus(displayStatus);
|
||||
|
||||
switch (displayStatus) {
|
||||
|
|
|
@ -263,10 +263,12 @@ public class OpenPgpApi {
|
|||
public static final String EXTRA_PROGRESS_MESSENGER = "progress_messenger";
|
||||
public static final String EXTRA_DATA_LENGTH = "data_length";
|
||||
public static final String EXTRA_SENDER_ADDRESS = "sender_address";
|
||||
public static final String EXTRA_SUPPORT_OVERRIDE_CRYPTO_WARNING = "support_override_crpto_warning";
|
||||
public static final String RESULT_SIGNATURE = "signature";
|
||||
public static final String RESULT_DECRYPTION = "decryption";
|
||||
public static final String RESULT_METADATA = "metadata";
|
||||
public static final String RESULT_INSECURE_DETAIL_INTENT = "insecure_detail_intent";
|
||||
public static final String RESULT_OVERRIDE_CRYPTO_WARNING = "override_crypto_warning";
|
||||
// This will be the charset which was specified in the headers of ascii armored input, if any
|
||||
public static final String RESULT_CHARSET = "charset";
|
||||
|
||||
|
|
Loading…
Reference in a new issue