summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-02-09 14:33:20 +0100
committerFup Duck <fupduck@sacknagel.com>2018-02-09 14:33:20 +0100
commit9f6e74680e5cfe6507bd1e37ea217cf2887af3cc (patch)
tree5ec6cbcf049278ef496e392f9b3dc54b0147f5aa /app
parent9e6fe0e215e32343b38cdf20080de209a31287dd (diff)
8827 - resolve discussions
* remove stop for providerApi * enable retrySetUpProvider * renamed PROVIDER_KEY for EIP_JSON to PROVIDER_EIP_DEFINITION
Diffstat (limited to 'app')
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java66
-rw-r--r--app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Constants.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java15
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/MainActivity.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java15
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java20
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/StartActivity.java9
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java4
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java84
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java11
15 files changed, 107 insertions, 148 deletions
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java
index 624b797b..dfc98ffb 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java
@@ -110,8 +110,6 @@ public class ProviderApiManager extends ProviderApiManagerBase {
resetProviderDetails(provider);
}
- go_ahead = true;
-
if (!provider.hasDefinition())
currentDownload = getAndSetProviderJson(provider, lastDangerOn);
if (provider.hasDefinition() || (currentDownload.containsKey(BROADCAST_RESULT_KEY) && currentDownload.getBoolean(BROADCAST_RESULT_KEY))) {
@@ -132,30 +130,28 @@ public class ProviderApiManager extends ProviderApiManagerBase {
String caCert = provider.getCaCert();
String providerMainUrl = provider.getMainUrlString();
- if (go_ahead) {
- String providerDotJsonString;
- if(providerDefinition.length() == 0 || caCert.isEmpty())
- providerDotJsonString = downloadWithCommercialCA(providerMainUrl + "/provider.json", dangerOn);
- else
- providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, providerDefinition, dangerOn);
+ String providerDotJsonString;
+ if(providerDefinition.length() == 0 || caCert.isEmpty())
+ providerDotJsonString = downloadWithCommercialCA(providerMainUrl + "/provider.json", dangerOn);
+ else
+ providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, providerDefinition, dangerOn);
- if (!isValidJson(providerDotJsonString)) {
- result.putString(ERRORS, resources.getString(malformed_url));
- result.putBoolean(BROADCAST_RESULT_KEY, false);
- return result;
- }
+ if (!isValidJson(providerDotJsonString)) {
+ result.putString(ERRORS, resources.getString(malformed_url));
+ result.putBoolean(BROADCAST_RESULT_KEY, false);
+ return result;
+ }
- try {
- JSONObject providerJson = new JSONObject(providerDotJsonString);
+ try {
+ JSONObject providerJson = new JSONObject(providerDotJsonString);
- provider.define(providerJson);
+ provider.define(providerJson);
- result.putBoolean(BROADCAST_RESULT_KEY, true);
- } catch (JSONException e) {
- String reason_to_fail = pickErrorMessage(providerDotJsonString);
- result.putString(ERRORS, reason_to_fail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
- }
+ result.putBoolean(BROADCAST_RESULT_KEY, true);
+ } catch (JSONException e) {
+ String reason_to_fail = pickErrorMessage(providerDotJsonString);
+ result.putString(ERRORS, reason_to_fail);
+ result.putBoolean(BROADCAST_RESULT_KEY, false);
}
result.putParcelable(PROVIDER_KEY, provider);
return result;
@@ -169,21 +165,19 @@ public class ProviderApiManager extends ProviderApiManagerBase {
protected Bundle getAndSetEipServiceJson(Provider provider) {
Bundle result = new Bundle();
String eipServiceJsonString = "";
- if (go_ahead) {
- try {
- JSONObject providerDefinition = provider.getDefinition();
- String eipServiceUrl = providerDefinition.getString(Provider.API_URL) + "/" + providerDefinition.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH;
- eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl, lastDangerOn);
+ try {
+ JSONObject providerDefinition = provider.getDefinition();
+ String eipServiceUrl = providerDefinition.getString(Provider.API_URL) + "/" + providerDefinition.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH;
+ eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl, lastDangerOn);
- JSONObject eipServiceJson = new JSONObject(eipServiceJsonString);
- provider.setEipServiceJson(eipServiceJson);
+ JSONObject eipServiceJson = new JSONObject(eipServiceJsonString);
+ provider.setEipServiceJson(eipServiceJson);
- result.putBoolean(BROADCAST_RESULT_KEY, true);
- } catch (NullPointerException | JSONException e) {
- String reasonToFail = pickErrorMessage(eipServiceJsonString);
- result.putString(ERRORS, reasonToFail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
- }
+ result.putBoolean(BROADCAST_RESULT_KEY, true);
+ } catch (NullPointerException | JSONException e) {
+ String reasonToFail = pickErrorMessage(eipServiceJsonString);
+ result.putString(ERRORS, reasonToFail);
+ result.putBoolean(BROADCAST_RESULT_KEY, false);
}
result.putParcelable(PROVIDER_KEY, provider);
return result;
@@ -228,7 +222,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
String certString = downloadWithCommercialCA(caCertUrl, dangerOn);
- if (validCertificate(provider, certString) && go_ahead) {
+ if (validCertificate(provider, certString)) {
provider.setCaCert(certString);
preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply();
result.putBoolean(BROADCAST_RESULT_KEY, true);
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java
index 531c438a..5ad7ea44 100644
--- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java
+++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderListActivity.java
@@ -101,14 +101,7 @@ public class ProviderListActivity extends ProviderListBaseActivity {
*/
@Override
public void retrySetUpProvider(@NonNull Provider provider) {
- cancelSettingUpProvider();
- if (!provider.hasCaCert()) {
- addAndSelectNewProvider(provider.getMainUrlString(), ProviderAPI.lastDangerOn());
- } else {
- showProgressBar();
-
- ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider);
- }
+ ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
index 2e9e1897..238f0ea1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java
@@ -55,7 +55,7 @@ import java.util.Map;
import static android.R.attr.name;
import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION;
import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED;
-import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
+import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION;
/**
* Stores constants, and implements auxiliary methods used across all Bitmask Android classes.
@@ -355,7 +355,7 @@ public class ConfigHelper {
putString(Provider.MAIN_URL, provider.getMainUrlString()).
putString(Provider.KEY, provider.getDefinitionString()).
putString(Provider.CA_CERT, provider.getCaCert()).
- putString(PROVIDER_KEY, provider.getEipServiceJsonString()).
+ putString(PROVIDER_EIP_DEFINITION, provider.getEipServiceJsonString()).
commit();
String providerDomain = provider.getDomain();
@@ -363,7 +363,7 @@ public class ConfigHelper {
putString(Provider.MAIN_URL + "." + providerDomain, provider.getMainUrlString()).
putString(Provider.KEY + "." + providerDomain, provider.getDefinitionString()).
putString(Provider.CA_CERT + "." + providerDomain, provider.getCaCert()).
- putString(PROVIDER_KEY + "." + providerDomain, provider.getEipServiceJsonString()).
+ putString(PROVIDER_EIP_DEFINITION + "." + providerDomain, provider.getEipServiceJsonString()).
apply();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java
index 6b5c6bb7..680c10bf 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java
@@ -58,6 +58,7 @@ public interface Constants {
String PROVIDER_PRIVATE_KEY = "Constants.PROVIDER_PRIVATE_KEY";
String PROVIDER_KEY = "Constants.PROVIDER_KEY";
String PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED";
+ String PROVIDER_EIP_DEFINITION = "Constants.EIP_DEFINITION";
//////////////////////////////////////////////
// CREDENTIAL CONSTANTS
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index 2f129d02..48dce1c2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -47,7 +47,7 @@ import static se.leap.bitmaskclient.Constants.APP_ACTION_QUIT;
import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON;
import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED;
-import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
+import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_KEY;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_SWITCH_PROVIDER;
@@ -161,7 +161,7 @@ public class Dashboard extends ButterKnifeActivity {
switch (versionCode) {
case 91: // 0.6.0 without Bug #5999
case 101: // 0.8.0
- if (!preferences.getString(PROVIDER_KEY, "").isEmpty())
+ if (!preferences.getString(PROVIDER_EIP_DEFINITION, "").isEmpty())
EipCommand.updateEipService(this);
break;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java
index 8d56cdf8..8a6d981d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java
+++ b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java
@@ -86,12 +86,13 @@ public class DownloadFailedDialog extends DialogFragment {
}
@Override
+ @NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(reasonToFail)
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- interface_with_ConfigurationWizard.cancelSettingUpProvider();
+ interfaceWithConfigurationWizard.cancelSettingUpProvider();
dialog.dismiss();
}
});
@@ -101,7 +102,7 @@ switch (downloadError) {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
- interface_with_ConfigurationWizard.updateProviderDetails();
+ interfaceWithConfigurationWizard.updateProviderDetails();
}
});
break;
@@ -111,7 +112,7 @@ switch (downloadError) {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
- interface_with_ConfigurationWizard.updateProviderDetails();
+ interfaceWithConfigurationWizard.updateProviderDetails();
}
});
break;
@@ -119,7 +120,7 @@ switch (downloadError) {
builder.setPositiveButton(R.string.retry, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dismiss();
- interface_with_ConfigurationWizard.retrySetUpProvider(provider);
+ interfaceWithConfigurationWizard.retrySetUpProvider(provider);
}
});
break;
@@ -137,13 +138,13 @@ switch (downloadError) {
void updateProviderDetails();
}
- DownloadFailedDialogInterface interface_with_ConfigurationWizard;
+ DownloadFailedDialogInterface interfaceWithConfigurationWizard;
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
- interface_with_ConfigurationWizard = (DownloadFailedDialogInterface) context;
+ interfaceWithConfigurationWizard = (DownloadFailedDialogInterface) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement NoticeDialogListener");
@@ -152,7 +153,7 @@ switch (downloadError) {
@Override
public void onCancel(DialogInterface dialog) {
- interface_with_ConfigurationWizard.cancelSettingUpProvider();
+ interfaceWithConfigurationWizard.cancelSettingUpProvider();
dialog.dismiss();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
index b2a39c1a..969f006a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
+++ b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
@@ -2,4 +2,5 @@ package se.leap.bitmaskclient;
public interface FeatureVersionCode {
int MULTIPLE_PROFILES = 132;
+ int RENAMED_EIP_IN_PREFERENCES = 132;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
index 9c047bc9..06a66e43 100644
--- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java
@@ -71,11 +71,12 @@ public class MainActivity extends AppCompatActivity {
switch (intent.getAction()) {
case ACTION_SHOW_VPN_FRAGMENT:
fragment = new EipFragment();
+ Bundle bundle = new Bundle();
if (intent.hasExtra(ASK_TO_CANCEL_VPN)) {
- Bundle bundle = new Bundle();
bundle.putBoolean(ASK_TO_CANCEL_VPN, true);
- fragment.setArguments(bundle);
}
+ bundle.putParcelable(PROVIDER_KEY, provider);
+ fragment.setArguments(bundle);
break;
default:
break;
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
index 73f5c530..4bffd1b2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -76,11 +76,6 @@ public class ProviderAPI extends IntentService implements ProviderApiManagerBase
}
//TODO: refactor me, please!
- public static void stop() {
- ProviderApiManager.stop();
- }
-
- //TODO: refactor me, please!
//used in insecure flavor only
@SuppressLint("unused")
public static boolean lastDangerOn() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
index 6b6aa89d..f1c0ecef 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
@@ -115,15 +115,10 @@ public abstract class ProviderApiManagerBase {
private ProviderApiServiceCallback serviceCallback;
- static boolean go_ahead = true;
protected SharedPreferences preferences;
protected Resources resources;
OkHttpClientGenerator clientGenerator;
- public static void stop() {
- go_ahead = false;
- }
-
ProviderApiManagerBase(SharedPreferences preferences, Resources resources, OkHttpClientGenerator clientGenerator, ProviderApiServiceCallback callback) {
this.preferences = preferences;
this.resources = resources;
@@ -158,12 +153,10 @@ public abstract class ProviderApiManagerBase {
}
} else if (action.equalsIgnoreCase(SET_UP_PROVIDER)) {
Bundle result = setUpProvider(provider, parameters);
- if (go_ahead) {
- if (result.getBoolean(BROADCAST_RESULT_KEY)) {
- sendToReceiverOrBroadcast(receiver, PROVIDER_OK, result, provider);
- } else {
- sendToReceiverOrBroadcast(receiver, PROVIDER_NOK, result, provider);
- }
+ if (result.getBoolean(BROADCAST_RESULT_KEY)) {
+ sendToReceiverOrBroadcast(receiver, PROVIDER_OK, result, provider);
+ } else {
+ sendToReceiverOrBroadcast(receiver, PROVIDER_NOK, result, provider);
}
} else if (action.equalsIgnoreCase(SIGN_UP)) {
Bundle result = tryToRegister(parameters);
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
index 6a76dd55..6fa3b503 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
@@ -46,7 +46,6 @@ import butterknife.InjectView;
import butterknife.OnItemClick;
import se.leap.bitmaskclient.fragments.AboutFragment;
-import static android.view.View.GONE;
import static se.leap.bitmaskclient.Constants.APP_ACTION_QUIT;
import static se.leap.bitmaskclient.Constants.BROADCAST_PROVIDER_API_EVENT;
import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_CODE;
@@ -229,10 +228,6 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity
}
void handleProviderSetupFailed(Bundle resultData) {
- mConfigState.setAction(PROVIDER_NOT_SET);
-
- setResult(RESULT_CANCELED, mConfigState);
-
reasonToFail = resultData.getString(ERRORS);
showDownloadFailedDialog();
}
@@ -242,8 +237,7 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity
}
void handleIncorrectlyDownloadedCertificate() {
- mConfigState.setAction(PROVIDER_NOT_SET);
- hideProgressBar();
+ cancelSettingUpProvider();
setResult(RESULT_CANCELED, mConfigState);
}
@@ -289,26 +283,18 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity
}
private void stopSettingUpProvider() {
- ProviderAPI.stop();
- loadingScreen.setVisibility(GONE);
-
cancelSettingUpProvider();
}
@Override
public void cancelSettingUpProvider() {
- hideProgressBar();
mConfigState.setAction(PROVIDER_NOT_SET);
+ hideProgressBar();
}
@Override
public void updateProviderDetails() {
- mConfigState.setAction(SETTING_UP_PROVIDER);
-
- Bundle parameters = new Bundle();
- parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString());
-
- ProviderAPICommand.execute(this, UPDATE_PROVIDER_DETAILS, parameters, provider);
+ ProviderAPICommand.execute(this, UPDATE_PROVIDER_DETAILS, provider);
}
public void checkProviderSetUp() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
index a7b713c5..288b157f 100644
--- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
@@ -20,6 +20,8 @@ import static se.leap.bitmaskclient.Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PRO
import static se.leap.bitmaskclient.Constants.EIP_ACTION_START;
import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION;
+import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION;
+import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
import static se.leap.bitmaskclient.MainActivity.ACTION_SHOW_VPN_FRAGMENT;
@@ -127,6 +129,13 @@ public class StartActivity extends Activity {
if (hasNewFeature(FeatureVersionCode.MULTIPLE_PROFILES)) {
// TODO prepare usage of multiple profiles
}
+ if (hasNewFeature(FeatureVersionCode.RENAMED_EIP_IN_PREFERENCES)) {
+ String eipJson = preferences.getString(PROVIDER_KEY, null);
+ if (eipJson != null) {
+ preferences.edit().putString(PROVIDER_EIP_DEFINITION, eipJson).
+ remove(PROVIDER_KEY).apply();
+ }
+ }
// ensure all upgrades have passed before storing new information
storeAppVersion();
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
index 474bf045..bfecda22 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -44,7 +44,7 @@ import static se.leap.bitmaskclient.Constants.EIP_ACTION_UPDATE;
import static se.leap.bitmaskclient.Constants.EIP_RECEIVER;
import static se.leap.bitmaskclient.Constants.EIP_REQUEST;
import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
-import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
+import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION;
import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
@@ -214,7 +214,7 @@ public final class EIP extends IntentService {
private JSONObject eipDefinitionFromPreferences() {
JSONObject result = new JSONObject();
try {
- String eipDefinitionString = preferences.getString(PROVIDER_KEY, "");
+ String eipDefinitionString = preferences.getString(PROVIDER_EIP_DEFINITION, "");
if (!eipDefinitionString.isEmpty()) {
result = new JSONObject(eipDefinitionString);
}
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
index 1783135d..307e8e05 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java
@@ -88,8 +88,6 @@ public class ProviderApiManager extends ProviderApiManagerBase {
resetProviderDetails(provider);
}
- go_ahead = true;
-
if (!provider.hasDefinition()) {
currentDownload = getAndSetProviderJson(provider);
}
@@ -111,30 +109,28 @@ public class ProviderApiManager extends ProviderApiManagerBase {
String caCert = provider.getCaCert();
JSONObject providerDefinition = provider.getDefinition();
- if (go_ahead) {
- String providerDotJsonString;
- if(providerDefinition.length() == 0 || caCert.isEmpty()) {
- String providerJsonUrl = provider.getMainUrlString() + "/provider.json";
- providerDotJsonString = downloadWithCommercialCA(providerJsonUrl, provider);
- } else {
- providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, providerDefinition);
- }
+ String providerDotJsonString;
+ if(providerDefinition.length() == 0 || caCert.isEmpty()) {
+ String providerJsonUrl = provider.getMainUrlString() + "/provider.json";
+ providerDotJsonString = downloadWithCommercialCA(providerJsonUrl, provider);
+ } else {
+ providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", caCert, providerDefinition);
+ }
- if (!isValidJson(providerDotJsonString)) {
- setErrorResult(result, malformed_url, null);
- return result;
- }
+ if (!isValidJson(providerDotJsonString)) {
+ setErrorResult(result, malformed_url, null);
+ return result;
+ }
- try {
- JSONObject providerJson = new JSONObject(providerDotJsonString);
- provider.define(providerJson);
+ try {
+ JSONObject providerJson = new JSONObject(providerDotJsonString);
+ provider.define(providerJson);
- result.putBoolean(BROADCAST_RESULT_KEY, true);
- } catch (JSONException e) {
- String reason_to_fail = pickErrorMessage(providerDotJsonString);
- result.putString(ERRORS, reason_to_fail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
- }
+ result.putBoolean(BROADCAST_RESULT_KEY, true);
+ } catch (JSONException e) {
+ String reason_to_fail = pickErrorMessage(providerDotJsonString);
+ result.putString(ERRORS, reason_to_fail);
+ result.putBoolean(BROADCAST_RESULT_KEY, false);
}
return result;
}
@@ -147,22 +143,20 @@ public class ProviderApiManager extends ProviderApiManagerBase {
protected Bundle getAndSetEipServiceJson(Provider provider) {
Bundle result = new Bundle();
String eipServiceJsonString = "";
- if (go_ahead) {
- try {
- JSONObject provider_json = provider.getDefinition();
- String eipServiceUrl = provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH;
- eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl);
- JSONObject eipServiceJson = new JSONObject(eipServiceJsonString);
- eipServiceJson.getInt(Provider.API_RETURN_SERIAL);
-
- provider.setEipServiceJson(eipServiceJson);
-
- result.putBoolean(BROADCAST_RESULT_KEY, true);
- } catch (NullPointerException | JSONException e) {
- String reason_to_fail = pickErrorMessage(eipServiceJsonString);
- result.putString(ERRORS, reason_to_fail);
- result.putBoolean(BROADCAST_RESULT_KEY, false);
- }
+ try {
+ JSONObject providerJson = provider.getDefinition();
+ String eipServiceUrl = providerJson.getString(Provider.API_URL) + "/" + providerJson.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH;
+ eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl);
+ JSONObject eipServiceJson = new JSONObject(eipServiceJsonString);
+ eipServiceJson.getInt(Provider.API_RETURN_SERIAL);
+
+ provider.setEipServiceJson(eipServiceJson);
+
+ result.putBoolean(BROADCAST_RESULT_KEY, true);
+ } catch (NullPointerException | JSONException e) {
+ String reasonToFail = pickErrorMessage(eipServiceJsonString);
+ result.putString(ERRORS, reasonToFail);
+ result.putBoolean(BROADCAST_RESULT_KEY, false);
}
return result;
}
@@ -176,15 +170,15 @@ public class ProviderApiManager extends ProviderApiManagerBase {
protected boolean updateVpnCertificate(Provider provider) {
try {
JSONObject providerJson = provider.getDefinition();
- String provider_main_url = providerJson.getString(Provider.API_URL);
- URL newCertStringUrl = new URL(provider_main_url + "/" + providerJson.getString(Provider.API_VERSION) + "/" + PROVIDER_VPN_CERTIFICATE);
+ String providerMainUrl = providerJson.getString(Provider.API_URL);
+ URL newCertStringUrl = new URL(providerMainUrl + "/" + providerJson.getString(Provider.API_VERSION) + "/" + PROVIDER_VPN_CERTIFICATE);
- String cert_string = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString());
+ String certString = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString());
- if (ConfigHelper.checkErroneousDownload(cert_string))
+ if (ConfigHelper.checkErroneousDownload(certString))
return false;
else
- return loadCertificate(cert_string);
+ return loadCertificate(certString);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -203,7 +197,7 @@ public class ProviderApiManager extends ProviderApiManagerBase {
String providerDomain = getDomainFromMainURL(provider.getMainUrlString());
String certString = downloadWithCommercialCA(caCertUrl, provider);
- if (validCertificate(provider, certString) && go_ahead) {
+ if (validCertificate(provider, certString)) {
provider.setCaCert(certString);
preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply();
result.putBoolean(BROADCAST_RESULT_KEY, true);
diff --git a/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java b/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
index 2df0ffa1..725ede3e 100644
--- a/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
+++ b/app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java
@@ -16,8 +16,6 @@
*/
package se.leap.bitmaskclient;
-import android.content.Intent;
-import android.os.Bundle;
import android.support.annotation.NonNull;
import java.net.MalformedURLException;
@@ -69,14 +67,7 @@ public class ProviderListActivity extends ProviderListBaseActivity {
@Override
public void retrySetUpProvider(@NonNull Provider provider) {
- cancelSettingUpProvider();
- if (!provider.hasCaCert()) {
- addAndSelectNewProvider(provider.getMainUrlString());
- } else {
- showProgressBar();
-
- ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider);
- }
+ ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider);
}
}