summaryrefslogtreecommitdiff
path: root/app/src/production
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2020-01-21 16:10:59 -0600
committercyberta <cyberta@riseup.net>2020-01-21 16:10:59 -0600
commit6a015d337d6a786adb319c3f9de7b9b7e9ae80bb (patch)
treeae19d8d28d15d3b871d82e804994d810f79ad811 /app/src/production
parent14b84f691e369e2a4ef3fe8687688f5ba98fa719 (diff)
implement no-dns fallback using okhttp's Dns interface
Diffstat (limited to 'app/src/production')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java12
1 files changed, 5 insertions, 7 deletions
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();