From 8256666a9981ac347e4a6e769e1981007c408b3a Mon Sep 17 00:00:00 2001
From: cyBerta <cyberta@riseup.net>
Date: Tue, 20 Feb 2018 14:25:56 +0100
Subject: #8853 fix failing vpn cert download callback for insecure flavor and
 use new provider method to build the api url

---
 .../production/java/se/leap/bitmaskclient/ProviderApiManager.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'app/src/production')

diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
index e5ee6c49..de50c170 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
@@ -34,6 +34,7 @@ import se.leap.bitmaskclient.eip.EIP;
 
 import static android.text.TextUtils.isEmpty;
 import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_KEY;
+import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
 import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
 import static se.leap.bitmaskclient.ProviderAPI.ERRORS;
 import static se.leap.bitmaskclient.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CERTIFICATE_PINNING;
@@ -84,6 +85,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
 
         //provider details invalid
         if (currentDownload.containsKey(ERRORS)) {
+            currentDownload.putParcelable(PROVIDER_KEY, provider);
             return currentDownload;
         }
 
@@ -177,9 +179,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
     protected Bundle updateVpnCertificate(Provider provider) {
         Bundle result = new Bundle();
         try {
-            JSONObject providerJson = provider.getDefinition();
-            String providerMainUrl = providerJson.getString(Provider.API_URL);
-            URL newCertStringUrl = new URL(providerMainUrl + "/" + providerJson.getString(Provider.API_VERSION) + "/" + PROVIDER_VPN_CERTIFICATE);
+            URL newCertStringUrl = new URL(provider.getApiUrlWithVersion() + "/" + PROVIDER_VPN_CERTIFICATE);
 
             String certString = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString());
             if (ConfigHelper.checkErroneousDownload(certString)) {
@@ -194,7 +194,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
                 }
             }
             return loadCertificate(provider, certString);
-        } catch (IOException | JSONException e) {
+        } catch (IOException e) {
             // TODO try to get Provider Json
             setErrorResult(result, downloading_vpn_certificate_failed, null);
             e.printStackTrace();
-- 
cgit v1.2.3


From c6c9ca844a50d9469e632a3356389f08e7f6f455 Mon Sep 17 00:00:00 2001
From: cyBerta <cyberta@riseup.net>
Date: Tue, 20 Feb 2018 15:17:06 +0100
Subject: #8853 show 'It doesn\'t seem to be a Bitmask provider' if entered URL
 is crap

---
 app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'app/src/production')

diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
index de50c170..885d69db 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
@@ -123,7 +123,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
             providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, providerDefinition);
         }
 
-        if (!isValidJson(providerDotJsonString)) {
+        if (ConfigHelper.checkErroneousDownload(providerDotJsonString) || !isValidJson(providerDotJsonString)) {
             setErrorResult(result, malformed_url, null);
             return result;
         }
-- 
cgit v1.2.3


From e4f4521f9d50aad80a7c689eb949e75d1b521bac Mon Sep 17 00:00:00 2001
From: cyBerta <cyberta@riseup.net>
Date: Wed, 21 Feb 2018 11:12:21 +0100
Subject: #8858 add custom providers to the providers list on successful setup

---
 .../production/java/se/leap/bitmaskclient/ProviderListActivity.java    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'app/src/production')

diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java b/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
index b6e67331..cf1d1aa6 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
@@ -39,11 +39,10 @@ public class ProviderListActivity extends ProviderListBaseActivity {
         setUpProvider();
     }
 
+    @Override
     public void showAndSelectProvider(String provider_main_url) {
         try {
             provider = new Provider(new URL((provider_main_url)));
-            adapter.add(provider);
-            adapter.saveProviders();
             autoSelectProvider(provider);
         } catch (MalformedURLException e) {
             e.printStackTrace();
-- 
cgit v1.2.3