From 929fa9a3b7621e0a956ed8d7beffb87ed7f16249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 13 Mar 2013 21:01:53 +0100 Subject: ConfigurationWizard sets provider.json correctly for Dashboard once a custom provider is selected. Tested using https://bitmask.net as url for custom provider. --- src/se/leap/leapclient/ConfigurationWizard.java | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/se/leap/leapclient/ConfigurationWizard.java') diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index e252fa6..dcefb27 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -59,7 +59,7 @@ public class ConfigurationWizard extends Activity setContentView(R.layout.activity_configuration_wizard); - shared_preferences = getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE); + ConfigHelper.setSharedPreferences(getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE)); loadPreseededProviders(); @@ -118,10 +118,9 @@ public class ConfigurationWizard extends Activity if(current_provider_item.id.equalsIgnoreCase(id)) { try { - if(!current_provider_item.custom) - processAssetsFiles(current_provider_item); - // TODO ask Provider class to save provider.json, setResult(OK), finish() to ConfigurationWizard - downloadJSONFiles(current_provider_item); + saveProviderJson(current_provider_item); + downloadJSONFiles(current_provider_item); + } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -136,11 +135,15 @@ public class ConfigurationWizard extends Activity } } - private void processAssetsFiles(ProviderItem current_provider_item) { + private void saveProviderJson(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(); + String provider_contents = ""; + if(!current_provider_item.custom) + provider_contents = new Scanner(new InputStreamReader(assets_manager.open(current_provider_item.provider_json_filename))).useDelimiter("\\A").next(); + else + provider_contents = new Scanner(ConfigHelper.openFileInputStream(current_provider_item.provider_json_filename)).useDelimiter("\\A").next(); provider_json = new JSONObject(provider_contents); } catch (IOException e) { // TODO Auto-generated catch block @@ -152,16 +155,20 @@ public class ConfigurationWizard extends Activity } private void downloadJSONFiles(ProviderItem current_provider_item) throws IOException { + providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); + providerAPI_result_receiver.setReceiver(this); + Intent provider_API_command = new Intent(this, ProviderAPI.class); Bundle method_and_parameters = new Bundle(); + + method_and_parameters.putString(ConfigHelper.provider_key, current_provider_item.name); 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); - + provider_API_command.putExtra("receiver", providerAPI_result_receiver); startService(provider_API_command); - } public void addNewProvider(View view) { @@ -193,7 +200,6 @@ public class ConfigurationWizard extends Activity @Override public void onReceiveResult(int resultCode, Bundle resultData) { - // TODO Auto-generated method stub if(resultCode == ConfigHelper.CUSTOM_PROVIDER_ADDED){ ProviderListFragment providerList = new ProviderListFragment(); -- cgit v1.2.3 From 203c8caca5a305b90fd0e69c965e503afe979354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 14 Mar 2013 19:53:31 +0100 Subject: After downloading provider.json successfully, ConfigurationWizard now can download eip-service.json and ca.crt without having the latter as a predefined trusted certificate. It does not ask anything about trusting the new certificate as far as selecting a custom provider means that the user trusts that url. Next step: make provider.json also downloadable from https address using ca.cert not trusted. --- src/se/leap/leapclient/ConfigurationWizard.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/se/leap/leapclient/ConfigurationWizard.java') diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index dcefb27..69e13f1 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -1,6 +1,7 @@ package se.leap.leapclient; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.util.Iterator; import java.util.Scanner; @@ -63,6 +64,11 @@ public class ConfigurationWizard extends Activity loadPreseededProviders(); + if(ConfigHelper.getKeystore() == null) { + InputStream keystore_input_stream = getResources().openRawResource(R.raw.leapkeystore); + ConfigHelper.getNewKeystore(keystore_input_stream); + } + // Only create our fragments if we're not restoring a saved instance if ( savedInstanceState == null ){ // TODO Some welcome screen? -- cgit v1.2.3 From 1fcb255170a2be35eecc5645a7b1757101b844f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 18 Mar 2013 12:00:47 +0100 Subject: Refactored ProviderAPI code. ConfigurationWizard works without problem for both new and preseeded providers. I've added flow control for the activity to finish when all files have been downloaded, managing errors with setResult(RESULT_CANCELED). --- src/se/leap/leapclient/ConfigurationWizard.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/se/leap/leapclient/ConfigurationWizard.java') diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index 69e13f1..90e74e5 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -126,18 +126,12 @@ public class ConfigurationWizard extends Activity try { saveProviderJson(current_provider_item); downloadJSONFiles(current_provider_item); - } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } - - // FIXME!! We're going to have more Fragments and listeners, flow control? - // TODO There is no testing done to know if we're okay... - setResult(RESULT_OK); - finish(); } } @@ -214,5 +208,13 @@ public class ConfigurationWizard extends Activity .replace(R.id.configuration_wizard_layout, providerList, "providerlist") .commit(); } + else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_JSON_FILES) { + setResult(RESULT_OK); + finish(); + } + else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES) { + setResult(RESULT_CANCELED); + finish(); + } } } -- cgit v1.2.3 From c3d73145c746419d23ec1a337b62506c4ef70fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 15 Apr 2013 17:52:19 +0200 Subject: Added one "else if" that I missed during merge. Next step: understand why ca.cert from bitmask is not being downloaded correctly. --- src/se/leap/leapclient/ConfigurationWizard.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/se/leap/leapclient/ConfigurationWizard.java') diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index 5b93cbb..a61acfa 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -17,7 +17,6 @@ import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Intent; -import android.content.SharedPreferences; import android.content.res.AssetManager; import android.os.Bundle; import android.os.Handler; @@ -58,7 +57,7 @@ public class ConfigurationWizard extends Activity setContentView(R.layout.activity_configuration_wizard); - ConfigHelper.setSharedPreferences(getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE)); + ConfigHelper.setSharedPreferences(getSharedPreferences(ConfigHelper.PREFERENCES_KEY, MODE_PRIVATE)); loadPreseededProviders(); -- cgit v1.2.3 From 418264e2a78371d133b510122f5ac3c9bd940764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 15 Apr 2013 20:20:58 +0200 Subject: Fixed bug 2231. New provider dialog works OK. --- src/se/leap/leapclient/ConfigurationWizard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/se/leap/leapclient/ConfigurationWizard.java') diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index a61acfa..4fbba1d 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -182,14 +182,14 @@ public class ConfigurationWizard extends Activity } @Override - public void saveProvider(String provider_url) { + public void saveProvider(String provider_main_url) { providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); providerAPI_result_receiver.setReceiver(this); Intent provider_API_command = new Intent(this, ProviderAPI.class); Bundle method_and_parameters = new Bundle(); - method_and_parameters.putString(ConfigHelper.provider_key_url, provider_url); + method_and_parameters.putString(ConfigHelper.provider_main_url, provider_main_url); provider_API_command.putExtra(ConfigHelper.downloadNewProviderDotJSON, method_and_parameters); provider_API_command.putExtra("receiver", providerAPI_result_receiver); -- cgit v1.2.3 From fbfdf86a1df28ccf8f1854c2e2a4c7b3135d50ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 16 Apr 2013 18:14:47 +0200 Subject: Fixed bug #2225 (https://leap.se/code/issues/2225) --- src/se/leap/leapclient/ConfigurationWizard.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/se/leap/leapclient/ConfigurationWizard.java') diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index 4fbba1d..0d44522 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -21,6 +21,7 @@ import android.content.res.AssetManager; import android.os.Bundle; import android.os.Handler; import android.view.View; +import android.widget.Toast; /** @@ -213,7 +214,7 @@ public class ConfigurationWizard extends Activity } else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES) { setResult(RESULT_CANCELED); - finish(); + Toast.makeText(getApplicationContext(), "You have not entered a LEAP provider URL", Toast.LENGTH_LONG).show(); } } } -- cgit v1.2.3