From faaa4db88b03f6c1d74f83600b51411025056362 Mon Sep 17 00:00:00 2001 From: anonTree1417 Date: Wed, 1 Apr 2020 18:39:39 +0200 Subject: [PATCH] Removing option "ONCE" --- .../mian/gitnex/clients/PicassoService.java | 2 +- .../mian/gitnex/helpers/ssl/MTMDecision.java | 1 - .../helpers/ssl/MemorizingActivity.java | 3 +-- .../helpers/ssl/MemorizingTrustManager.java | 22 +++++++------------ 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/clients/PicassoService.java b/app/src/main/java/org/mian/gitnex/clients/PicassoService.java index aceceb3f..f13e4d2f 100644 --- a/app/src/main/java/org/mian/gitnex/clients/PicassoService.java +++ b/app/src/main/java/org/mian/gitnex/clients/PicassoService.java @@ -39,7 +39,7 @@ public class PicassoService { builder.downloader(new OkHttp3Downloader(okHttpClient.build())); builder.listener((picasso, uri, exception) -> { - Log.e("PicassoService", Objects.requireNonNull(uri.toString())); // important!! + //Log.e("PicassoService", Objects.requireNonNull(uri.toString())); Log.e("PicassoService", exception.toString()); }); diff --git a/app/src/main/java/org/mian/gitnex/helpers/ssl/MTMDecision.java b/app/src/main/java/org/mian/gitnex/helpers/ssl/MTMDecision.java index 5fc77e06..aab9ce96 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/ssl/MTMDecision.java +++ b/app/src/main/java/org/mian/gitnex/helpers/ssl/MTMDecision.java @@ -8,7 +8,6 @@ class MTMDecision { final static int DECISION_INVALID = 0; final static int DECISION_ABORT = 1; - final static int DECISION_ONCE = 2; final static int DECISION_ALWAYS = 3; int state = DECISION_INVALID; diff --git a/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingActivity.java b/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingActivity.java index 0003e7fc..472a9954 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingActivity.java +++ b/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingActivity.java @@ -27,8 +27,7 @@ public class MemorizingActivity extends Activity { builder.setMessage(cert); builder.setPositiveButton(R.string.mtm_decision_always, (dialog, which) -> onSendResult(decisionId, MTMDecision.DECISION_ALWAYS)); - builder.setNeutralButton(R.string.mtm_decision_once, (dialog, which) -> onSendResult(decisionId, MTMDecision.DECISION_ONCE)); - builder.setNegativeButton(R.string.mtm_decision_abort, (dialog, which) -> onSendResult(decisionId, MTMDecision.DECISION_ABORT)); + builder.setNeutralButton(R.string.mtm_decision_abort, (dialog, which) -> onSendResult(decisionId, MTMDecision.DECISION_ABORT)); builder.setOnCancelListener(dialog -> onSendResult(decisionId, MTMDecision.DECISION_ABORT)); builder.create().show(); diff --git a/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingTrustManager.java b/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingTrustManager.java index 292b5379..49ea6f6e 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingTrustManager.java +++ b/app/src/main/java/org/mian/gitnex/helpers/ssl/MemorizingTrustManager.java @@ -596,26 +596,20 @@ public class MemorizingTrustManager implements X509TrustManager { private void interactCert(final X509Certificate[] chain, String authType, CertificateException cause) throws CertificateException { - switch(interact(certChainMessage(chain, cause), R.string.mtm_accept_cert)) { - case MTMDecision.DECISION_ALWAYS: - storeCert(chain[0]); // only store the server cert, not the whole chain - case MTMDecision.DECISION_ONCE: - break; - default: - throw (cause); + if(interact(certChainMessage(chain, cause), R.string.mtm_accept_cert) == MTMDecision.DECISION_ALWAYS) { + storeCert(chain[0]); // only store the server cert, not the whole chain } + + throw (cause); } private boolean interactHostname(X509Certificate cert, String hostname) { - switch(interact(hostNameMessage(cert, hostname), R.string.mtm_accept_servername)) { - case MTMDecision.DECISION_ALWAYS: - storeCert(hostname, cert); - case MTMDecision.DECISION_ONCE: - return true; - default: - return false; + if(interact(hostNameMessage(cert, hostname), R.string.mtm_accept_servername) == MTMDecision.DECISION_ALWAYS) { + storeCert(hostname, cert); } + + return false; } static void interactResult(int decisionId, int choice) {