From 6a015d337d6a786adb319c3f9de7b9b7e9ae80bb Mon Sep 17 00:00:00 2001 From: cyberta Date: Tue, 21 Jan 2020 16:10:59 -0600 Subject: implement no-dns fallback using okhttp's Dns interface --- .../java/se/leap/bitmaskclient/ProviderApiManager.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'app/src/production/java') diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java index 41a63ad7..6f1e3034 100644 --- a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java +++ b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java @@ -121,14 +121,13 @@ public class ProviderApiManager extends ProviderApiManagerBase { Bundle result = new Bundle(); String caCert = provider.getCaCert(); - JSONObject providerDefinition = provider.getDefinition(); String providerDotJsonString; - if(providerDefinition.length() == 0 || caCert.isEmpty()) { + if(provider.getDefinitionString().length() == 0 || caCert.isEmpty()) { String providerJsonUrl = provider.getMainUrlString() + "/provider.json"; providerDotJsonString = downloadWithCommercialCA(providerJsonUrl, provider); } else { - providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, providerDefinition); + providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, provider); } if (ConfigHelper.checkErroneousDownload(providerDotJsonString) || !isValidJson(providerDotJsonString)) { @@ -163,8 +162,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { Bundle result = new Bundle(); String eipServiceJsonString = ""; try { - JSONObject providerJson = provider.getDefinition(); - String eipServiceUrl = providerJson.getString(Provider.API_URL) + "/" + providerJson.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH; + String eipServiceUrl = provider.getApiUrlWithVersion() + "/" + EIP.SERVICE_API_PATH; eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl); JSONObject eipServiceJson = new JSONObject(eipServiceJsonString); if (BuildConfig.DEBUG) { @@ -278,10 +276,10 @@ public class ProviderApiManager extends ProviderApiManagerBase { * * @return an empty string if it fails, the response body if not. */ - private String downloadFromApiUrlWithProviderCA(String path, String caCert, JSONObject providerDefinition) { + private String downloadFromApiUrlWithProviderCA(String path, String caCert, Provider provider) { String responseString; JSONObject errorJson = new JSONObject(); - String baseUrl = getApiUrl(providerDefinition); + String baseUrl = provider.getApiUrlString(); OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(caCert, errorJson); if (okHttpClient == null) { return errorJson.toString(); -- cgit v1.2.3