diff options
author | cyBerta <cyberta@riseup.net> | 2019-05-21 11:54:20 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-05-21 11:54:20 +0200 |
commit | caadb236f39b4b6139a697eec57aa2796595422f (patch) | |
tree | c6b53be2133d74feb7d982e59d73cc4d29e4b6e7 /app/src/main/java/se/leap/bitmaskclient | |
parent | 5fd9cd738f26797cf16576bf4011852c9f3052a8 (diff) |
* show error dialog if provider is misconfigured and has not allowed registration nor anonymous usage
* always download provider.json, Use preseeded provider.json only to check if the client
can connect with preseeded certificate. Keeps the provider.json updated if provider changes it's
config
* Tests for both cases
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient')
4 files changed, 15 insertions, 38 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java index 5e5a3a62..c81f5739 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Provider.java +++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java @@ -230,14 +230,6 @@ public final class Provider implements Parcelable { && !getEipServiceJson().has(ERRORS); } - public boolean allowsRegistration() { - try { - return definition.getJSONObject(Provider.SERVICE).getBoolean(Provider.ALLOW_REGISTRATION); - } catch (JSONException e) { - return false; - } - } - @Override public int describeContents() { return 0; diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java index 5cf27854..15c7457e 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java @@ -595,7 +595,7 @@ public abstract class ProviderApiManagerBase { private boolean canConnect(String caCert, JSONObject providerDefinition, Bundle result) { JSONObject errorJson = new JSONObject(); - String baseUrl = getApiUrl(providerDefinition); + String providerUrl = getApiUrl(providerDefinition) + "/provider.json"; OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(caCert, errorJson); if (okHttpClient == null) { @@ -605,7 +605,7 @@ public abstract class ProviderApiManagerBase { try { - return ProviderApiConnector.canConnect(okHttpClient, baseUrl); + return ProviderApiConnector.canConnect(okHttpClient, providerUrl); } catch (UnknownHostException | SocketTimeoutException e) { setErrorResult(result, server_unreachable_message, null); diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java index 2aa7de2a..3b8df0a8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java @@ -20,7 +20,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; -import android.os.PersistableBundle; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentTransaction; diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderSetupFailedDialog.java b/app/src/main/java/se/leap/bitmaskclient/ProviderSetupFailedDialog.java index 71b67df1..e2f3e173 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderSetupFailedDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderSetupFailedDialog.java @@ -48,6 +48,9 @@ public class ProviderSetupFailedDialog extends DialogFragment { private Provider provider; + /** + * Represent error types that need different error handling actions + */ public enum DOWNLOAD_ERRORS { DEFAULT, ERROR_CORRUPTED_PROVIDER_JSON, @@ -103,42 +106,25 @@ public class ProviderSetupFailedDialog extends DialogFragment { 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) { - interfaceWithConfigurationWizard.cancelSettingUpProvider(); - } - }); + .setNegativeButton(R.string.cancel, (dialog, id) + -> interfaceWithConfigurationWizard.cancelSettingUpProvider()); switch (downloadError) { case ERROR_CORRUPTED_PROVIDER_JSON: - builder.setPositiveButton(R.string.update_provider_details, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - interfaceWithConfigurationWizard.updateProviderDetails(); - } - }); + builder.setPositiveButton(R.string.update_provider_details, (dialog, which) + -> interfaceWithConfigurationWizard.updateProviderDetails()); break; case ERROR_CERTIFICATE_PINNING: case ERROR_INVALID_CERTIFICATE: - builder.setPositiveButton(R.string.update_certificate, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - interfaceWithConfigurationWizard.updateProviderDetails(); - } - }); + builder.setPositiveButton(R.string.update_certificate, (dialog, which) + -> interfaceWithConfigurationWizard.updateProviderDetails()); break; case ERROR_NEW_URL_NO_VPN_PROVIDER: - builder.setPositiveButton(R.string.retry, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - interfaceWithConfigurationWizard.addAndSelectNewProvider(provider.getMainUrlString()); - } - }); + builder.setPositiveButton(R.string.retry, (dialog, id) + -> interfaceWithConfigurationWizard.addAndSelectNewProvider(provider.getMainUrlString())); break; default: - builder.setPositiveButton(R.string.retry, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - interfaceWithConfigurationWizard.retrySetUpProvider(provider); - } - }); + builder.setPositiveButton(R.string.retry, (dialog, id) + -> interfaceWithConfigurationWizard.retrySetUpProvider(provider)); break; } |