summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ProviderAPI.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-02-11 20:28:59 +0100
committerParménides GV <parmegv@sdf.org>2013-02-11 20:28:59 +0100
commit162afa5bfa6485f3aacb3f60e9c92fa0c3bfa7a7 (patch)
treec9fabab994e1e51e8ec90bc8b2c78cc55d219e3e /src/se/leap/leapclient/ProviderAPI.java
parent8db161017f55a710bd91aa14fe9c1b24d4efdeab (diff)
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.
Diffstat (limited to 'src/se/leap/leapclient/ProviderAPI.java')
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java21
1 files changed, 20 insertions, 1 deletions
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 {