summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient/ConfigurationWizard.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-09-09 20:08:00 +0200
committerParménides GV <parmegv@sdf.org>2013-12-10 18:08:21 +0100
commit50ad1c04cee7fe3409a1c2958d4dba98882cd45d (patch)
tree4c4928207456580d08d71212aebcbb62d0e0ad37 /src/se/leap/bitmaskclient/ConfigurationWizard.java
parent576bb02d7a087a32863d310363968d304b3af52f (diff)
Preseeded providers only have provider.json url
I've refactored everything to be able to remove all but provider.json url at urls files.
Diffstat (limited to 'src/se/leap/bitmaskclient/ConfigurationWizard.java')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index 532debfd..6d088a85 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -165,7 +165,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
mProgressBar.incrementProgressBy(1);
}
- downloadJSONFiles(mSelectedProvider);
+ downloadJSONFiles(provider_json, danger_on);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -366,7 +366,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
mProgressBar.incrementProgressBy(1);
- downloadJSONFiles(mSelectedProvider);
+ downloadJSONFiles(provider_json, provider.completelyTrusted());
}
} catch (JSONException e) {
setResult(RESULT_CANCELED);
@@ -378,23 +378,28 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
* Asks ProviderAPI to download provider site's certificate and eip-service.json
*
* URLs are fetched from the provider parameter
- * @param provider from which certificate and eip-service.json files are going to be downloaded
- */
- private void downloadJSONFiles(ProviderItem provider) {
- Intent provider_API_command = new Intent(this, ProviderAPI.class);
-
- Bundle parameters = new Bundle();
-
- parameters.putString(Provider.KEY, provider.name());
- parameters.putString(Provider.CA_CERT, provider.cert_json_url);
- parameters.putString(EIP.KEY, provider.eip_service_json_url);
- parameters.putBoolean(ProviderItem.DANGER_ON, provider.completelyTrusted());
-
- provider_API_command.setAction(ProviderAPI.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA);
- provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
- provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
-
- startService(provider_API_command);
+ * @param provider_json describing the provider from which certificate and eip-service.json files are going to be downloaded
+ */
+ private void downloadJSONFiles(JSONObject provider_json, boolean danger_on) {
+ try {
+ Intent provider_API_command = new Intent(this, ProviderAPI.class);
+
+ Bundle parameters = new Bundle();
+
+ parameters.putBoolean(ProviderItem.DANGER_ON, danger_on);
+ parameters.putString(Provider.CA_CERT, provider_json.getString("ca_cert_uri"));
+ String eip_service_url = provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION) + "/config/eip-service.json";
+ parameters.putString(EIP.KEY, eip_service_url);
+
+ provider_API_command.setAction(ProviderAPI.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA);
+ provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
+ provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
+
+ startService(provider_API_command);
+ } catch (JSONException e) {
+ //TODO Show error to the user. This will eventually be transformed to "unselectProvider()", which will show the graphical notice itself.
+ ConfigHelper.removeFromSharedPref(Provider.KEY);
+ }
}
/**