summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ProviderListActivity.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-02-05 20:46:33 +0100
committerParménides GV <parmegv@sdf.org>2013-02-05 20:46:33 +0100
commit1d5f1c320ee67cfadd62aeef056a043bee75096d (patch)
treed92f986b1579e6a2b365e774115f39c658d74fca /src/se/leap/leapclient/ProviderListActivity.java
parent45b86cd7c8922cfd03a7f056941852273c2d122a (diff)
Simplified certificates and urls: only 1 certificate, and no :443 port
in eip. Downloads certificate and eip from web, and loads provider from assets. KeyStore not created with latest version of BouncyCastle. Looking forward to file a bug and look for a solution.
Diffstat (limited to 'src/se/leap/leapclient/ProviderListActivity.java')
-rw-r--r--src/se/leap/leapclient/ProviderListActivity.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/se/leap/leapclient/ProviderListActivity.java b/src/se/leap/leapclient/ProviderListActivity.java
index 088b464d..808c12ce 100644
--- a/src/se/leap/leapclient/ProviderListActivity.java
+++ b/src/se/leap/leapclient/ProviderListActivity.java
@@ -1,9 +1,11 @@
package se.leap.leapclient;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@@ -11,6 +13,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import se.leap.leapclient.ProviderListContent;
import se.leap.leapclient.ProviderListContent.ProviderItem;
import android.app.DownloadManager;
@@ -103,6 +108,7 @@ public class ProviderListActivity extends FragmentActivity
if(current_provider_item.id.equalsIgnoreCase(id))
{
try {
+ processAssetsFiles(current_provider_item);
downloadJSONFiles(current_provider_item);
} catch (IOException e) {
// TODO Auto-generated catch block
@@ -116,12 +122,27 @@ public class ProviderListActivity extends FragmentActivity
}
}
+ private void processAssetsFiles(ProviderItem current_provider_item) {
+ AssetManager assets_manager = getAssets();
+ JSONObject provider_json = new JSONObject();
+ try {
+ String provider_contents = new Scanner(new InputStreamReader(assets_manager.open(current_provider_item.provider_json_assets))).useDelimiter("\\A").next();
+ provider_json = new JSONObject(provider_contents);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JSONException e) {
+ ConfigHelper.rescueJSONException(e);
+ }
+ ConfigHelper.saveSharedPref(ConfigHelper.provider_key, provider_json);
+ }
+
private void downloadJSONFiles(ProviderItem current_provider_item) throws IOException {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
Bundle method_and_parameters = new Bundle();
- method_and_parameters.putString("provider", current_provider_item.provider_json_url);
- method_and_parameters.putString("eip", current_provider_item.eip_service_json_url);
+ method_and_parameters.putString(ConfigHelper.cert_key, current_provider_item.cert_json_url);
+ method_and_parameters.putString(ConfigHelper.eip_service_key, current_provider_item.eip_service_json_url);
provider_API_command.putExtra(ConfigHelper.downloadJsonFilesBundleExtra, method_and_parameters);