summaryrefslogtreecommitdiff
path: root/app/src/production/java
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/src/production/java
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/src/production/java')
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderApiManager.java84
-rw-r--r--app/src/production/java/se/leap/bitmaskclient/ProviderListActivity.java11
2 files changed, 40 insertions, 55 deletions
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);
}
}