summaryrefslogtreecommitdiff
path: root/app/src/production
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/production')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java43
1 files changed, 23 insertions, 20 deletions
diff --git a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
index 592db085..96d8ea69 100644
--- a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java
@@ -22,8 +22,6 @@ import android.content.res.Resources;
import android.os.Bundle;
import android.util.Pair;
-import androidx.multidex.BuildConfig;
-
import org.json.JSONException;
import org.json.JSONObject;
@@ -34,25 +32,26 @@ import java.util.List;
import de.blinkt.openvpn.core.VpnStatus;
import okhttp3.OkHttpClient;
import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.eip.EIP;
import se.leap.bitmaskclient.base.models.Provider;
-import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator;
import se.leap.bitmaskclient.base.utils.ConfigHelper;
+import se.leap.bitmaskclient.eip.EIP;
+import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator;
import static android.text.TextUtils.isEmpty;
-import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY;
-import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY;
-import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_VPN_CERTIFICATE;
-import static se.leap.bitmaskclient.providersetup.ProviderAPI.ERRORS;
-import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CERTIFICATE_PINNING;
-import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CORRUPTED_PROVIDER_JSON;
+import static se.leap.bitmaskclient.BuildConfig.DEBUG_MODE;
import static se.leap.bitmaskclient.R.string.downloading_vpn_certificate_failed;
import static se.leap.bitmaskclient.R.string.error_io_exception_user_message;
import static se.leap.bitmaskclient.R.string.malformed_url;
import static se.leap.bitmaskclient.R.string.setup_error_text;
import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_cert;
import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_details;
+import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY;
+import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY;
+import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_VPN_CERTIFICATE;
import static se.leap.bitmaskclient.base.utils.ConfigHelper.getProviderFormattedString;
+import static se.leap.bitmaskclient.providersetup.ProviderAPI.ERRORS;
+import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CERTIFICATE_PINNING;
+import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CORRUPTED_PROVIDER_JSON;
/**
* Implements the logic of the provider api http requests. The methods of this class need to be called from
@@ -88,6 +87,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
if (isEmpty(provider.getMainUrlString()) || provider.getMainUrl().isDefault()) {
currentDownload.putBoolean(BROADCAST_RESULT_KEY, false);
setErrorResult(currentDownload, malformed_url, null);
+ VpnStatus.logWarning("[API] MainURL String is not set. Cannot setup provider.");
return currentDownload;
}
@@ -139,8 +139,8 @@ public class ProviderApiManager extends ProviderApiManagerBase {
return result;
}
- if (BuildConfig.DEBUG) {
- VpnStatus.logDebug("PROVIDER JSON: " + providerDotJsonString);
+ if (DEBUG_MODE) {
+ VpnStatus.logDebug("[API] PROVIDER JSON: " + providerDotJsonString);
}
try {
JSONObject providerJson = new JSONObject(providerDotJsonString);
@@ -168,10 +168,10 @@ public class ProviderApiManager extends ProviderApiManagerBase {
try {
String eipServiceUrl = provider.getApiUrlWithVersion() + "/" + EIP.SERVICE_API_PATH;
eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl);
- JSONObject eipServiceJson = new JSONObject(eipServiceJsonString);
- if (BuildConfig.DEBUG) {
- VpnStatus.logDebug("EIP SERVICE JSON: " + eipServiceJsonString);
+ if (DEBUG_MODE) {
+ VpnStatus.logDebug("[API] EIP SERVICE JSON: " + eipServiceJsonString);
}
+ JSONObject eipServiceJson = new JSONObject(eipServiceJsonString);
if (eipServiceJson.has(ERRORS)) {
setErrorResult(result, eipServiceJsonString);
} else {
@@ -197,8 +197,8 @@ public class ProviderApiManager extends ProviderApiManagerBase {
URL newCertStringUrl = new URL(provider.getApiUrlWithVersion() + "/" + PROVIDER_VPN_CERTIFICATE);
String certString = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString());
- if (BuildConfig.DEBUG) {
- VpnStatus.logDebug("VPN CERT: " + certString);
+ if (DEBUG_MODE) {
+ VpnStatus.logDebug("[API] VPN CERT: " + certString);
}
if (ConfigHelper.checkErroneousDownload(certString)) {
if (certString == null || certString.isEmpty()) {
@@ -240,6 +240,9 @@ public class ProviderApiManager extends ProviderApiManagerBase {
URL geoIpUrl = provider.getGeoipUrl().getUrl();
String geoipJsonString = downloadFromUrlWithProviderCA(geoIpUrl.toString(), provider);
+ if (DEBUG_MODE) {
+ VpnStatus.logDebug("[API] MENSHEN JSON: " + geoipJsonString);
+ }
JSONObject geoipJson = new JSONObject(geoipJsonString);
if (geoipJson.has(ERRORS)) {
@@ -267,10 +270,10 @@ public class ProviderApiManager extends ProviderApiManagerBase {
if (validCertificate(provider, certString)) {
provider.setCaCert(certString);
- preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply();
- if (BuildConfig.DEBUG) {
- VpnStatus.logDebug("CA CERT: " + certString);
+ if (DEBUG_MODE) {
+ VpnStatus.logDebug("[API] CA CERT: " + certString);
}
+ preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply();
result.putBoolean(BROADCAST_RESULT_KEY, true);
} else {
setErrorResult(result, warning_corrupted_provider_cert, ERROR_CERTIFICATE_PINNING.toString());