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-11-19 17:46:03 +0100
commite67c405e9a4e58cce55dac8c107e0b9010965f48 (patch)
tree72e629b34f591c0307e691c0792898b93bb37968 /src/se/leap/bitmaskclient/ConfigurationWizard.java
parentc88555a1f3844fe4d5c69496e4a7f4aa966e4b3b (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 389f7b49..016d9c52 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -164,7 +164,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();
@@ -364,7 +364,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
mProgressBar.incrementProgressBy(1);
- downloadJSONFiles(mSelectedProvider);
+ downloadJSONFiles(provider_json, provider.completelyTrusted());
}
} catch (JSONException e) {
setResult(RESULT_CANCELED);
@@ -376,23 +376,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);
+ }
}
/**