summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/leapclient')
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java1
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java4
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java18
-rw-r--r--src/se/leap/leapclient/ProviderListContent.java17
4 files changed, 13 insertions, 27 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 11f95041..0e50c7dd 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -192,7 +192,6 @@ public class ConfigHelper {
public static void addTrustedCertificate(String provider, String certificate) {
String filename_to_save = provider + "_certificate.cer";
- saveFile(filename_to_save, certificate);
CertificateFactory cf;
try {
cf = CertificateFactory.getInstance("X.509");
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index 2a9b93b2..1dc00938 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -80,8 +80,8 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
boolean danger_on = resultData.getBoolean(ConfigHelper.DANGER_ON);
ConfigHelper.saveSharedPref(ConfigHelper.PROVIDER_KEY, provider_json);
ConfigHelper.saveSharedPref(ConfigHelper.DANGER_ON, danger_on);
- ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, provider_json.getBoolean(ConfigHelper.ALLOWED_ANON));
-
+ ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, provider_json.getJSONObject(ConfigHelper.SERVICE_KEY).getBoolean(ConfigHelper.ALLOWED_ANON));
+
mConfigState.setAction(PROVIDER_SET);
mProgressDialog.setMessage(getResources().getString(R.string.config_downloading_services));
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index 10f04c5d..471eb6cf 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -216,9 +216,7 @@ public class ProviderAPI extends IntentService {
} else {
ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, provider_json.getJSONObject(ConfigHelper.SERVICE_KEY).getBoolean(ConfigHelper.ALLOWED_ANON));
- String filename = provider_name + "_provider.json".replaceFirst("__", "_");
-
- ProviderListContent.addItem(new ProviderItem(provider_name, provider_json_url, filename, custom, danger_on));
+ ProviderListContent.addItem(new ProviderItem(provider_name, provider_json_url, provider_json, custom, danger_on));
result.putBoolean(ConfigHelper.RESULT_KEY, true);
result.putString(ConfigHelper.PROVIDER_KEY, provider_json.toString());
result.putBoolean(ConfigHelper.DANGER_ON, danger_on);
@@ -237,17 +235,17 @@ public class ProviderAPI extends IntentService {
String provider_main_url = (String) task.get(ConfigHelper.PROVIDER_MAIN_URL);
String provider_name = provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("\\/", "_");
String provider_json_url = guessURL(provider_main_url);
- JSONObject provider_json = null;
+
+ JSONObject provider_json;
try {
provider_json = getJSONFromProvider(provider_json_url, danger_on);
-
- String filename = provider_name + "_provider.json".replaceFirst("__", "_");
-
- ProviderListContent.addItem(new ProviderItem(provider_name, provider_json_url, filename, custom, danger_on));
- return true;
+ ProviderListContent.addItem(new ProviderItem(provider_name, provider_json_url, provider_json, custom, danger_on));
} catch (JSONException e) {
- return false;
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
+
+ return true;
}
private String getStringFromProviderWithoutValidate(
diff --git a/src/se/leap/leapclient/ProviderListContent.java b/src/se/leap/leapclient/ProviderListContent.java
index b83bbd8e..10dce578 100644
--- a/src/se/leap/leapclient/ProviderListContent.java
+++ b/src/se/leap/leapclient/ProviderListContent.java
@@ -1,6 +1,5 @@
package se.leap.leapclient;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -78,21 +77,14 @@ public class ProviderListContent {
}
}
- public ProviderItem(String name, String provider_json_url, String provider_json_filename, boolean custom, boolean danger_on) {
+ public ProviderItem(String name, String provider_json_url, JSONObject provider_json, boolean custom, boolean danger_on) {
-
- FileInputStream provider_json = ConfigHelper.openFileInputStream(provider_json_filename);
try {
- byte[] urls_file_bytes = new byte[provider_json.available()];
- provider_json.read(urls_file_bytes);
- String urls_file_content = new String(urls_file_bytes);
- JSONObject file_contents = new JSONObject(urls_file_content);
id = name;
this.name = name;
this.provider_json_url = provider_json_url;
- this.provider_json_filename = provider_json_filename;
- eip_service_json_url = file_contents.getString("api_uri") + "/" + file_contents.getString("api_version") + "/" + ConfigHelper.EIP_SERVICE_API_PATH;
- cert_json_url = (String) file_contents.get("ca_cert_uri");
+ eip_service_json_url = provider_json.getString("api_uri") + "/" + provider_json.getString("api_version") + "/" + ConfigHelper.EIP_SERVICE_API_PATH;
+ cert_json_url = (String) provider_json.get("ca_cert_uri");
this.custom = custom;
this.danger_on = danger_on;
if(custom)
@@ -100,9 +92,6 @@ public class ProviderListContent {
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
}