From 162afa5bfa6485f3aacb3f60e9c92fa0c3bfa7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 11 Feb 2013 20:28:59 +0100 Subject: Gets provider.json from custom url (assuming the file is at the root of the website, just as bitmask.net/provider.json), and writes it to a file in ~/leap_android. Next steps: parse that file and download eip-service and cert. --- src/se/leap/leapclient/ProviderAPI.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/se/leap/leapclient/ProviderAPI.java') diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java index 5a8f9572..c21e17a4 100644 --- a/src/se/leap/leapclient/ProviderAPI.java +++ b/src/se/leap/leapclient/ProviderAPI.java @@ -27,7 +27,7 @@ public class ProviderAPI extends IntentService { protected void onHandleIntent(Intent task_for) { Bundle task; System.out.println("onHandleIntent called"); - if (!(task = task_for.getBundleExtra(ConfigHelper.downloadJsonFilesBundleExtra)).isEmpty()) { + if((task = task_for.getBundleExtra(ConfigHelper.downloadJsonFilesBundleExtra)) != null) { String cert_url = (String) task.get(ConfigHelper.cert_key); String eip_service_json_url = (String) task.get(ConfigHelper.eip_service_key); try { @@ -45,6 +45,25 @@ public class ProviderAPI extends IntentService { e.printStackTrace(); } } + else if ((task = task_for.getBundleExtra(ConfigHelper.downloadNewProviderDotJSON)) != null) { + String provider_main_url = (String) task.get(ConfigHelper.provider_key_url); + String provider_json_url = guessURL(provider_main_url); + try { + JSONObject provider_json = getJSONFromProvider(provider_json_url); + String filename = provider_json_url.replaceFirst("http[s]?://", "").replaceFirst("\\/", "_") + "_provider.json".replaceFirst("__", "_"); + ConfigHelper.saveFile(filename, provider_json.toString()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + private String guessURL(String provider_main_url) { + return provider_main_url + "/provider.json"; } private String getStringFromProvider(String string_url) throws IOException { -- cgit v1.2.3