diff options
author | Parménides GV <parmegv@sdf.org> | 2013-09-09 20:08:00 +0200 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2013-12-09 18:53:00 +0100 |
commit | 8fe314897cb59067c10cee376afbe01d623a9661 (patch) | |
tree | 4c4928207456580d08d71212aebcbb62d0e0ad37 /src/se/leap | |
parent | 5ceb82f87fb4f94984d3720f68187bf6ba00d1e0 (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')
4 files changed, 33 insertions, 23 deletions
diff --git a/src/se/leap/bitmaskclient/AboutFragment.java b/src/se/leap/bitmaskclient/AboutFragment.java index d751dc2f..4d03a44b 100644 --- a/src/se/leap/bitmaskclient/AboutFragment.java +++ b/src/se/leap/bitmaskclient/AboutFragment.java @@ -4,9 +4,6 @@ import android.app.Fragment; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; -import android.text.Html; -import android.text.Spanned; -import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; 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);
+ }
}
/**
diff --git a/src/se/leap/bitmaskclient/ProviderListContent.java b/src/se/leap/bitmaskclient/ProviderListContent.java index 42cac792..a6da5620 100644 --- a/src/se/leap/bitmaskclient/ProviderListContent.java +++ b/src/se/leap/bitmaskclient/ProviderListContent.java @@ -110,6 +110,14 @@ public class ProviderListContent { public String providerJsonUrl() { return provider_json_url; }
+ public String domain() {
+ try {
+ return new URL(provider_json_url).getHost();
+ } catch (MalformedURLException e) {
+ return provider_json_url.replaceFirst("http[s]?://", "").replaceFirst("/.*", "");
+ }
+ }
+
public boolean completelyTrusted() { return danger_on; }
}
}
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java index 84d46a11..ca66d295 100644 --- a/src/se/leap/bitmaskclient/ProviderListFragment.java +++ b/src/se/leap/bitmaskclient/ProviderListFragment.java @@ -155,7 +155,7 @@ public class ProviderListFragment extends ListFragment { // Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
- mCallbacks.onItemSelected(ProviderListContent.ITEMS.get(position).id);
+ mCallbacks.onItemSelected(ProviderListContent.ITEMS.get(position).name());
for(int item_position = 0; item_position < listView.getCount(); item_position++) {
if(item_position != position)
|