summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xres/values/strings.xml10
-rwxr-xr-xres/values/values-nl/arrays.xml27
-rwxr-xr-xres/values/values-nl/strings.xml108
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java63
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java146
-rw-r--r--src/se/leap/leapclient/Dashboard.java58
-rw-r--r--src/se/leap/leapclient/LeapHttpClient.java16
-rw-r--r--src/se/leap/leapclient/LeapSRPSession.java2
-rw-r--r--src/se/leap/leapclient/LogInDialog.java5
-rw-r--r--src/se/leap/leapclient/NewProviderDialog.java3
-rw-r--r--src/se/leap/leapclient/Provider.java3
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java21
-rw-r--r--src/se/leap/leapclient/ProviderListFragment.java3
13 files changed, 330 insertions, 135 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 03de1ee8..4501ac1d 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -271,5 +271,15 @@
<string name="login_button">Log In</string>
<string name="logout_button">Log Out</string>
<string name="danger_checkbox">Trust completely</string>
+ <string name="setup_error_title">Configuration Error</string>
+ <string name="setup_error_configure_button">Configure</string>
+ <string name="setup_error_close_button">Exit</string>
+ <string name="setup_error_text">There was an error configuring LEAP with your chosen provider.\n\nYou may choose to reconfigure, or exit and configure a provider upon next launch.</string>
+ <string name="config_wait_title">Configuring LEAP provider</string>
+ <string name="config_connecting_provider">Downloading provider configuration</string>
+ <string name="config_downloading_services">Downloading service definitions</string>
+ <string name="config_downloading_certificates">Downloading authentication certificates</string>
+ <string name="config_error_parsing">Error parsing provider\'s responses!</string>
+ <string name="success">Success!</string>
</resources> \ No newline at end of file
diff --git a/res/values/values-nl/arrays.xml b/res/values/values-nl/arrays.xml
new file mode 100755
index 00000000..9be2a9d4
--- /dev/null
+++ b/res/values/values-nl/arrays.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<resources>
+ <string-array name="vpn_types">
+ <item>Certificaten</item>
+ <item>PKCS12 Bestand</item>
+ <item>Android Certificaat</item>
+ <item>Gebruikersnaam/Wachtwoord</item>
+ <item>Statische Sleutels</item>
+ <item>Gebruiker/WW + Certificaten</item>
+ <item>Gebruiker/WW + PKCS12 </item>
+ <item>Gebruiker/WW + Android</item>
+ </string-array>
+ <string-array name="tls_directions_entries">
+ <item>0</item>
+ <item>1</item>
+ <item>Niet-gespecificeerd</item>
+ </string-array>
+ <string-array name="verb_entries">
+ <item>0 - Geen logboek</item>
+ <item>1 - Standaard logboek</item>
+ <item>2 - Uitgebreid logboek</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5 - Debug logboek</item>
+ </string-array>
+</resources>
diff --git a/res/values/values-nl/strings.xml b/res/values/values-nl/strings.xml
new file mode 100755
index 00000000..459c80ec
--- /dev/null
+++ b/res/values/values-nl/strings.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.net-->
+<resources>
+ <string name="app">LEAP voor Android</string>
+ <string name="address">Server Adres:</string>
+ <string name="port">Server Poort:</string>
+ <string name="location">Locatie</string>
+ <string name="select">Selecteer</string>
+ <string name="cancel">Annuleer</string>
+ <string name="no_data">Geen Gegevens</string>
+ <string name="useLZO">LZO Compressie</string>
+ <string name="client_no_certificate">Geen Certificaat</string>
+ <string name="client_certificate_title">Client Certificaat</string>
+ <string name="client_key_title">Client Certificaat Sleutel</string>
+ <string name="client_pkcs12_title">PKCS12 Bestand</string>
+ <string name="ca_title">CA Certificaat</string>
+ <string name="about">Over</string>
+ <string name="about_summary">Over LEAP voor Android</string>
+ <string name="vpn_list_summary">Lijst van alle geconfigureerde VPN verbindingen</string>
+ <string name="vpn_list_title">VPN Profielen</string>
+ <string name="vpn_type">Type</string>
+ <string name="pkcs12pwquery">PKCS12 Wachtwoord</string>
+ <string name="file_select">Selecteer…</string>
+ <string name="useTLSAuth">Gebruik TLS autentificatie</string>
+ <string name="tls_direction">TLS Richting</string>
+ <string name="ipv6_dialog_tile">Voer een IPv6 Adres/Netmask in met het CIDR Formaat (v.b. 2000:dd::23/64)</string>
+ <string name="ipv4_dialog_title">Voer een IPv4 Adres/Netmask in met het CIDR Formaat (v.b. 1.2.3.4/24)</string>
+ <string name="ipv4_address">IPv4 Adres</string>
+ <string name="ipv6_address">IPv4 Adres</string>
+ <string name="auth_username">Gebruikersnaam</string>
+ <string name="auth_pwquery">wachtwoord</string>
+ <string name="configure_the_vpn">VPN configureren</string>
+ <string name="menu_add_profile">Profiel toevoegen</string>
+ <string name="add_profile_name_prompt">Voer een naam in voor het nieuwe Profiel</string>
+ <string name="profilename">Profiel name</string>
+ <string name="no_error_found">Geen fout.</string>
+ <string name="config_error_found">Fout in de configuratie</string>
+ <string name="vpn_shortcut">Open VPN shortcut</string>
+ <string name="vpn_launch_title">Met VPN verbinden</string>
+ <string name="shortcut_profile_notfound">Het profiel zoals aangegeven in de snelkoppeling kon niet gevonden worden.</string>
+ <string name="random_host_prefix">Willekeurig Host Voorvoegsel</string>
+ <string name="random_host_summary">Voegt 6 willekeurige tekens toe voor de hostname</string>
+ <string name="custom_config_title">Eigen configuratie opties</string>
+ <string name="custom_config_summary">Geef je eigen configuratieopties aan. Wees voorzichtig!</string>
+ <string name="route_rejected">Route geweigert door Android</string>
+ <string name="cancel_connection">Verbinding verbreken</string>
+ <string name="clear_log">logboek wissen</string>
+ <string name="title_cancel">Annuleer bevestiging</string>
+ <string name="cancel_connection_query">Sluit de verbonden VPN af/annuleer de verbindingspoging?</string>
+ <string name="remove_vpn">VPN wissen</string>
+ <string name="check_remote_tlscert">Checkt of de server een TLS server certificaat gebruikt.</string>
+ <string name="remote_tlscn_check_title">Controleer Certificaat Hostname</string>
+ <string name="enter_tlscn_title">Externe Hostname(CN)</string>
+ <string name="tls_auth_file">TLS Auth Bestand</string>
+ <string name="pull_on_summary">Vraag IP adres, routes en timing opties van de server.</string>
+ <string name="use_pull">Pull Instellingen</string>
+ <string name="dns">DNS</string>
+ <string name="override_dns">DNS Instellingen van Server Overschrijven</string>
+ <string name="dns_override_summary">Gebruik eigen DNS Servers</string>
+ <string name="searchdomain">Zoekd domein</string>
+ <string name="dns1_summary">Primaire DNS server</string>
+ <string name="dns_server">DNS Server</string>
+ <string name="secondary_dns_message">Secundaire DNS server. Deze wordt gebruikt voor het geval dat de primaire DNS server niet bereikbaar is</string>
+ <string name="backup_dns">Backup DNS server</string>
+ <string name="ignored_pushed_routes">Negeer ontvangen routes</string>
+ <string name="ignore_routes_summary">Negeer routes ontvangen van de server.</string>
+ <string name="default_route_summary">Leid al het Verkeer over de VPN</string>
+ <string name="use_default_title">Gebruik standaard Route</string>
+ <string name="custom_routes_title">Eigen routes</string>
+ <string name="float_summary">Geverifieerde pakketen zijn vanuit elk IP toegestaan</string>
+ <string name="float_title">Zwevende server toestaan</string>
+ <string name="custom_options_title">Aangepaste Opties</string>
+ <string name="edit_vpn">VPN Instellingen Bewerken</string>
+ <string name="error">"Fout:"</string>
+ <string name="clear">Leeg maken</string>
+ <string name="info">info</string>
+ <string name="show_connection_details">Details van de verbinding weergeven</string>
+ <string name="last_openvpn_tun_config">Laatste interfaceconfiguratie van OpenVPN:</string>
+ <string name="local_ip_info">Lokaal IPv4: %1$s/%2$d IPv6: %3$s MTU: %4$d</string>
+ <string name="dns_server_info">DNS Server: %s</string>
+ <string name="dns_domain_info">DNS Domein: %s</string>
+ <string name="routes_info">Routes: %s</string>
+ <string name="routes_info6">Routes IPv6: %s</string>
+ <string name="version_info">%1$s %2$s</string>
+ <string name="send_logfile">Logboek verzenden</string>
+ <string name="send">Verzenden</string>
+ <string name="tap_mode">Tap mode</string>
+ <string name="faq_tap_mode">De VPN API van Android werkt zonder rooten van de telefoon en ondersteunt alleen de tun modus. Daarom is de tap modus niet mogelijk met deze app.</string>
+ <string name="import_configuration_file">configuratie bestand importeren</string>
+ <string name="faq_security_title">Beveiligingsoverwegingen</string>
+ <string name="import_vpn">Importeren</string>
+ <string name="broken_image_cert_title">Fout bij het weergeven van de certificaat selectie</string>
+ <string name="ipv4">IPv4</string>
+ <string name="ipv6">IPv6</string>
+ <string name="speed_waiting">Wachten op status bericht…</string>
+ <string name="converted_profile">Geïmporteerd profiel</string>
+ <string name="converted_profile_i">Geïmporteerd profiel %d</string>
+ <string name="broken_images">Niet Werkende Afbeeldingen</string>
+ <string name="error_empty_username">De gebruikersnaam moet niet leeg zijn.</string>
+ <string name="pkcs12_file_encryption_key">PKCS12 Bestand Encryptie Sleutel</string>
+ <string name="private_key_password">Privé Sleutel Wachtwoord</string>
+ <string name="password">Wachtwoord</string>
+ <string name="file_icon">bestands pictogram</string>
+ <string name="tls_authentication">TLS Verificatie</string>
+ <string name="generated_config">Gegenereerde Configuratie</string>
+ <string name="generalsettings">Algemene Instellingen</string>
+ <string name="ipdns">IP en DNS</string>
+</resources>
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 6a70378f..e8bc27c5 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -18,6 +18,7 @@ import java.security.cert.X509Certificate;
import org.json.JSONException;
import org.json.JSONObject;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Environment;
import android.util.Log;
@@ -88,6 +89,17 @@ public class ConfigHelper {
INCORRECTLY_DOWNLOADED_ANON_CERTIFICATE = 14
;
+
+ private static boolean checkSharedPrefs() {
+ try {
+ shared_preferences = Dashboard.getAppContext().getSharedPreferences(PREFERENCES_KEY,Context.MODE_PRIVATE);
+ } catch (Exception e) {
+ return false;
+ }
+
+ return true;
+ }
+
public static void saveSharedPref(String shared_preferences_key, JSONObject content) {
SharedPreferences.Editor shared_preferences_editor = shared_preferences
@@ -97,16 +109,49 @@ public class ConfigHelper {
shared_preferences_editor.commit();
}
+ public static void saveSharedPref(String shared_preferences_key, String content) {
+
+ SharedPreferences.Editor shared_preferences_editor = shared_preferences
+ .edit();
+ shared_preferences_editor.putString(shared_preferences_key,
+ content);
+ shared_preferences_editor.commit();
+ }
+
+ public static void saveSharedPref(String shared_preferences_key, boolean content) {
+
+ SharedPreferences.Editor shared_preferences_editor = shared_preferences
+ .edit();
+ shared_preferences_editor.putBoolean(shared_preferences_key, content);
+ shared_preferences_editor.commit();
+ }
+
public static String getStringFromSharedPref(String shared_preferences_key) {
- String value = "";
- if(shared_preferences != null) {
- String content = shared_preferences.getString(shared_preferences_key, "");
- try {
- JSONObject json_object = new JSONObject(content);
- value = json_object.toString();
- } catch (JSONException e) {
- value = content;
- }
+ String content = null;
+ if ( checkSharedPrefs() ) {
+ content = shared_preferences.getString(shared_preferences_key, "");
+ }
+ return content;
+ }
+
+ public static JSONObject getJsonFromSharedPref(String shared_preferences_key) throws JSONException {
+ JSONObject content = null;
+ if ( checkSharedPrefs() ) {
+ content = new JSONObject( shared_preferences.getString(shared_preferences_key, "") );
+ }
+
+ return content;
+ }
+
+ /*
+ * This method defaults to false.
+ * If you use this method, be sure to fail-closed on false!
+ * TODO This is obviously less than ideal...solve it!
+ */
+ public static boolean getBoolFromSharedPref(String shared_preferences_key) {
+ boolean value = false;
+ if ( checkSharedPrefs() ) {
+ value = shared_preferences.getBoolean(shared_preferences_key, false);
}
return value;
}
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index fff155a8..2a9b93b2 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -10,13 +10,12 @@ import org.json.JSONObject;
import se.leap.leapclient.ProviderAPIResultReceiver.Receiver;
import se.leap.leapclient.ProviderListContent.ProviderItem;
import se.leap.leapclient.R;
-import se.leap.leapclient.R.id;
-import se.leap.leapclient.R.layout;
import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
+import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.AssetManager;
import android.os.Bundle;
@@ -25,15 +24,15 @@ import android.view.View;
import android.widget.Toast;
public class ConfigurationWizard extends Activity
- implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogInterface, Receiver {
+implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogInterface, Receiver {
-
- /**
- * Whether or not the activity is in two-pane mode, i.e. running on a tablet
- * device.
- */
- private boolean mTwoPane;
+ private ProviderItem mSelectedProvider;
+ private ProgressDialog mProgressDialog;
+ private Intent mConfigState = new Intent();
+ protected static final String PROVIDER_SET = "PROVIDER SET";
+ protected static final String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
+
public ProviderAPIResultReceiver providerAPI_result_receiver;
@Override
@@ -41,6 +40,9 @@ public class ConfigurationWizard extends Activity
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_configuration_wizard);
+
+ providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
+ providerAPI_result_receiver.setReceiver(this);
ConfigHelper.setSharedPreferences(getSharedPreferences(ConfigHelper.PREFERENCES_KEY, MODE_PRIVATE));
@@ -71,36 +73,64 @@ 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);
- }
- else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES) {
- setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "You have not entered a LEAP provider URL or it is unavailable", Toast.LENGTH_LONG).show();
- }
else if(resultCode == ConfigHelper.CORRECTLY_UPDATED_PROVIDER_DOT_JSON) {
JSONObject provider_json;
try {
provider_json = new JSONObject(resultData.getString(ConfigHelper.PROVIDER_KEY));
boolean danger_on = resultData.getBoolean(ConfigHelper.DANGER_ON);
ConfigHelper.saveSharedPref(ConfigHelper.PROVIDER_KEY, provider_json);
- ConfigHelper.saveSharedPref(ConfigHelper.DANGER_ON, new JSONObject().put(ConfigHelper.DANGER_ON, danger_on));
- downloadAnonCert();
+ ConfigHelper.saveSharedPref(ConfigHelper.DANGER_ON, danger_on);
+ ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, provider_json.getBoolean(ConfigHelper.ALLOWED_ANON));
+
+ mConfigState.setAction(PROVIDER_SET);
+
+ mProgressDialog.setMessage(getResources().getString(R.string.config_downloading_services));
+ downloadJSONFiles(mSelectedProvider);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
+
+ mProgressDialog.dismiss();
+ Toast.makeText(this, getResources().getString(R.string.config_error_parsing), Toast.LENGTH_LONG);
+ setResult(RESULT_CANCELED, mConfigState);
+ finish();
}
}
else if(resultCode == ConfigHelper.INCORRECTLY_UPDATED_PROVIDER_DOT_JSON) {
+ mProgressDialog.dismiss();
Toast.makeText(getApplicationContext(), "Install a new version of this app.", Toast.LENGTH_LONG).show();
+ setResult(RESULT_CANCELED, mConfigState);
+ finish();
+ }
+ else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_JSON_FILES) {
+ if (ConfigHelper.getBoolFromSharedPref(ConfigHelper.ALLOWED_ANON)){
+ mProgressDialog.setMessage(getResources().getString(R.string.config_downloading_certificates));
+ mConfigState.putExtra(SERVICES_RETRIEVED, true);
+ downloadAnonCert();
+ } else {
+ mProgressDialog.dismiss();
+ Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG).show();
+ setResult(RESULT_OK);
+ finish();
+ }
+ }
+ else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES) {
+ Toast.makeText(getApplicationContext(), "You have not entered a LEAP provider URL or it is unavailable", Toast.LENGTH_LONG).show();
+ setResult(RESULT_CANCELED, mConfigState);
+ finish();
}
else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_CERTIFICATE) {
- setResult(RESULT_OK);
+ mProgressDialog.dismiss();
Toast.makeText(getApplicationContext(), "Your anon cert has been correctly downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG).show();
+ //mConfigState.putExtra(CERTIFICATE_RETRIEVED, true); // If this isn't the last step and finish() is moved...
+ setResult(RESULT_OK);
finish();
} else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
- setResult(RESULT_CANCELED);
+ mProgressDialog.dismiss();
Toast.makeText(getApplicationContext(), "Your anon cert was not downloaded", Toast.LENGTH_LONG).show();
+ setResult(RESULT_CANCELED, mConfigState);
+ finish();
}
}
@@ -114,16 +144,12 @@ public class ConfigurationWizard extends Activity
Iterator<ProviderItem> preseeded_providers_iterator = ProviderListContent.ITEMS.iterator();
while(preseeded_providers_iterator.hasNext())
{
- ProviderItem current_provider_item = preseeded_providers_iterator.next();
- if(current_provider_item.id.equalsIgnoreCase(id))
+ ProviderItem provider = preseeded_providers_iterator.next();
+ if(provider.id.equalsIgnoreCase(id))
{
- try {
- saveProviderJson(current_provider_item);
- downloadJSONFiles(current_provider_item);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ mProgressDialog = ProgressDialog.show(this, getResources().getString(R.string.config_wait_title), getResources().getString(R.string.config_connecting_provider), true);
+ mSelectedProvider = provider;
+ saveProviderJson(mSelectedProvider);
}
}
}
@@ -152,31 +178,32 @@ public class ConfigurationWizard extends Activity
return loaded_preseeded_providers;
}
- private boolean saveProviderJson(ProviderItem current_provider_item) {
+ private void saveProviderJson(ProviderItem current_provider_item) {
JSONObject provider_json = new JSONObject();
try {
String provider_contents = "";
if(!current_provider_item.custom) {
updateProviderDotJson(current_provider_item.name, current_provider_item.provider_json_url, current_provider_item.danger_on);
- return true;
} else {
+ // FIXME!! We should we be updating our seeded providers list at ConfigurationWizard onStart() ?
+ // I think yes, but if so, where does this list live? leap.se, as it's the non-profit project for the software?
+ // If not, we should just be getting names/urls, and fetching the provider.json like in custom entries
provider_contents = new Scanner(ConfigHelper.openFileInputStream(current_provider_item.provider_json_filename)).useDelimiter("\\A").next();
provider_json = new JSONObject(provider_contents);
ConfigHelper.saveSharedPref(ConfigHelper.PROVIDER_KEY, provider_json);
- ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, new JSONObject().put(ConfigHelper.ALLOWED_ANON, provider_json.getJSONObject(ConfigHelper.SERVICE_KEY).getBoolean(ConfigHelper.ALLOWED_ANON)));
- ConfigHelper.saveSharedPref(ConfigHelper.DANGER_ON, new JSONObject().put(ConfigHelper.DANGER_ON, current_provider_item.danger_on));
- downloadAnonCert();
- return true;
+ ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, provider_json.getJSONObject(ConfigHelper.SERVICE_KEY).getBoolean(ConfigHelper.ALLOWED_ANON));
+ ConfigHelper.saveSharedPref(ConfigHelper.DANGER_ON, current_provider_item.danger_on);
+
+ mProgressDialog.setMessage(getResources().getString(R.string.config_downloading_services));
+ downloadJSONFiles(mSelectedProvider);
}
} catch (JSONException e) {
- return false;
+ setResult(RESULT_CANCELED);
+ finish();
}
}
- private void downloadJSONFiles(ProviderItem current_provider_item) throws IOException {
- providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
- providerAPI_result_receiver.setReceiver(this);
-
+ private void downloadJSONFiles(ProviderItem current_provider_item) {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
Bundle method_and_parameters = new Bundle();
@@ -193,32 +220,19 @@ public class ConfigurationWizard extends Activity
}
private boolean downloadAnonCert() {
+ Intent provider_API_command = new Intent(this, ProviderAPI.class);
- JSONObject allowed_anon;
- try {
- allowed_anon = new JSONObject(ConfigHelper.getStringFromSharedPref(ConfigHelper.ALLOWED_ANON));
- if(allowed_anon.getBoolean(ConfigHelper.ALLOWED_ANON)) {
- 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.TYPE_OF_CERTIFICATE, ConfigHelper.ANON_CERTIFICATE);
-
- provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ Bundle method_and_parameters = new Bundle();
- startService(provider_API_command);
- return true;
- } else {
- return false;
- }
- } catch (JSONException e) {
- return false;
- }
+ method_and_parameters.putString(ConfigHelper.TYPE_OF_CERTIFICATE, ConfigHelper.ANON_CERTIFICATE);
+
+ provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
+ provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+
+ startService(provider_API_command);
+ return true;
}
+
public void addNewProvider(View view) {
FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction();
Fragment previous_new_provider_dialog = getFragmentManager().findFragmentByTag(ConfigHelper.NEW_PROVIDER_DIALOG);
@@ -233,9 +247,6 @@ public class ConfigurationWizard extends Activity
@Override
public void saveProvider(String provider_main_url, boolean danger_on) {
- 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();
@@ -249,9 +260,6 @@ public class ConfigurationWizard extends Activity
}
public void updateProviderDotJson(String provider_name, String provider_json_url, boolean danger_on) {
- 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();
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java
index 5ffbc19e..c1f4697d 100644
--- a/src/se/leap/leapclient/Dashboard.java
+++ b/src/se/leap/leapclient/Dashboard.java
@@ -7,15 +7,15 @@ import org.json.JSONObject;
import se.leap.leapclient.ProviderAPIResultReceiver.Receiver;
import se.leap.leapclient.R;
-import se.leap.leapclient.R.id;
-import se.leap.leapclient.R.layout;
-import se.leap.leapclient.R.menu;
import se.leap.openvpn.AboutFragment;
import se.leap.openvpn.MainActivity;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
+import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -34,6 +34,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
protected static final int CONFIGURE_LEAP = 0;
+ private static Context app;
private static SharedPreferences preferences;
private static Provider provider;
@@ -45,6 +46,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ app = this;
+
setContentView(R.layout.client_dashboard);
preferences = getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE);
@@ -53,10 +57,10 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
// Check if we have preferences, run configuration wizard if not
// TODO We should do a better check for config that this!
- if (!preferences.contains("provider") )
- startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
- else
+ if (preferences.contains("provider") && preferences.getString(ConfigHelper.PROVIDER_KEY, null) != null)
buildDashboard();
+ else
+ startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
}
@Override
@@ -68,8 +72,26 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
buildDashboard();
} else {
- // Something went wrong... TODO figure out what
- // TODO Error dialog
+ // Something went wrong in configuration
+ AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getAppContext());
+ alertBuilder.setTitle(getResources().getString(R.string.setup_error_title));
+ alertBuilder
+ .setMessage(getResources().getString(R.string.setup_error_text))
+ .setCancelable(false)
+ .setPositiveButton(getResources().getString(R.string.setup_error_configure_button), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startActivityForResult(new Intent(getAppContext(),ConfigurationWizard.class),CONFIGURE_LEAP);
+ }
+ })
+ .setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences.Editor prefsEdit = getSharedPreferences(ConfigHelper.PREFERENCES_KEY, MODE_PRIVATE).edit();
+ prefsEdit.remove(ConfigHelper.PROVIDER_KEY).commit();
+ finish();
+ }
+ });
}
}
}
@@ -91,7 +113,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
private void serviceItemEIP() {
// FIXME Provider service (eip/openvpn)
- View eipOverview = ((ViewStub) findViewById(R.id.eipOverviewStub)).inflate();
+ ((ViewStub) findViewById(R.id.eipOverviewStub)).inflate();
// Set our EIP type title
eipTypeTV = (TextView) findViewById(R.id.eipType);
@@ -120,21 +142,19 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- String provider_json_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.PROVIDER_KEY);
+ JSONObject provider_json;
try {
- JSONObject provider_json = new JSONObject(provider_json_string);
+ provider_json = ConfigHelper.getJsonFromSharedPref(ConfigHelper.PROVIDER_KEY);
JSONObject service_description = provider_json.getJSONObject(ConfigHelper.SERVICE_KEY);
if(service_description.getBoolean(ConfigHelper.ALLOW_REGISTRATION_KEY)) {
menu.findItem(R.id.login_button).setVisible(true);
menu.findItem(R.id.logout_button).setVisible(true);
- return true;
}
} catch (JSONException e) {
- menu.findItem(R.id.login_button).setVisible(false);
- menu.findItem(R.id.logout_button).setVisible(false);
- return false;
- }
- return false;
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return true;
}
@Override
@@ -288,4 +308,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
}
+ // Used for getting Context when outside of a class extending Context
+ public static Context getAppContext() {
+ return app;
+ }
}
diff --git a/src/se/leap/leapclient/LeapHttpClient.java b/src/se/leap/leapclient/LeapHttpClient.java
index a2ee8ad6..3eeebe95 100644
--- a/src/se/leap/leapclient/LeapHttpClient.java
+++ b/src/se/leap/leapclient/LeapHttpClient.java
@@ -9,9 +9,6 @@ import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import android.content.Context;
public class LeapHttpClient extends DefaultHttpClient {
@@ -22,16 +19,9 @@ public class LeapHttpClient extends DefaultHttpClient {
public static LeapHttpClient getInstance(Context context) {
if(client == null) {
client = new LeapHttpClient(context);
- String cert_json_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.MAIN_CERT_KEY);
- String cert_string;
- try {
- cert_string = new JSONObject(cert_json_string).getString(ConfigHelper.MAIN_CERT_KEY);
- if(!cert_string.isEmpty()) {
- ConfigHelper.addTrustedCertificate("recovered_certificate", cert_string);
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ String cert_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.MAIN_CERT_KEY);
+ if(cert_string != null) {
+ ConfigHelper.addTrustedCertificate("recovered_certificate", cert_string);
}
}
return client;
diff --git a/src/se/leap/leapclient/LeapSRPSession.java b/src/se/leap/leapclient/LeapSRPSession.java
index 47dff276..8eb28c4d 100644
--- a/src/se/leap/leapclient/LeapSRPSession.java
+++ b/src/se/leap/leapclient/LeapSRPSession.java
@@ -7,9 +7,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import org.jboss.security.Util;
-import org.jboss.security.srp.SRPClientSession;
import org.jboss.security.srp.SRPParameters;
-import org.jboss.security.srp.SRPPermission;
public class LeapSRPSession {
diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java
index 370a138c..c20413d7 100644
--- a/src/se/leap/leapclient/LogInDialog.java
+++ b/src/se/leap/leapclient/LogInDialog.java
@@ -1,9 +1,6 @@
package se.leap.leapclient;
import se.leap.leapclient.R;
-import se.leap.leapclient.R.id;
-import se.leap.leapclient.R.layout;
-import se.leap.leapclient.R.string;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DialogFragment;
@@ -47,7 +44,7 @@ public class LogInDialog extends DialogFragment {
}
boolean wellFormedPassword(String entered_password) {
- return entered_password.length() > 8;
+ return entered_password.length() >= 8;
}
public interface LogInDialogInterface {
diff --git a/src/se/leap/leapclient/NewProviderDialog.java b/src/se/leap/leapclient/NewProviderDialog.java
index 07185b47..60ac8d2a 100644
--- a/src/se/leap/leapclient/NewProviderDialog.java
+++ b/src/se/leap/leapclient/NewProviderDialog.java
@@ -1,9 +1,6 @@
package se.leap.leapclient;
import se.leap.leapclient.R;
-import se.leap.leapclient.R.id;
-import se.leap.leapclient.R.layout;
-import se.leap.leapclient.R.string;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
diff --git a/src/se/leap/leapclient/Provider.java b/src/se/leap/leapclient/Provider.java
index f86bbf59..50bd2925 100644
--- a/src/se/leap/leapclient/Provider.java
+++ b/src/se/leap/leapclient/Provider.java
@@ -11,6 +11,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import android.content.Context;
import android.app.Activity;
import android.content.SharedPreferences;
@@ -67,7 +68,7 @@ public final class Provider implements Serializable {
//preferences = context.getgetPreferences(0); // 0 == MODE_PRIVATE, but we don't extend Android's classes...
// Load SharedPreferences
- preferences = activity.getSharedPreferences(ConfigHelper.PREFERENCES_KEY,0); // We don't get MODE_PRIVATE by importing SharedPreferences; i guess it's in Activity?
+ preferences = activity.getSharedPreferences(ConfigHelper.PREFERENCES_KEY,Context.MODE_PRIVATE);
// Inflate our provider.json data
try {
definition = new JSONObject( preferences.getString("provider", "") );
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index a6a2d6be..cd19da04 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -117,8 +117,7 @@ public class ProviderAPI extends IntentService {
boolean danger_on = task.getBoolean(ConfigHelper.DANGER_ON);
try {
String cert_string = getStringFromProvider(cert_url, danger_on);
- JSONObject cert_json = new JSONObject().put(ConfigHelper.MAIN_CERT_KEY, cert_string);
- ConfigHelper.saveSharedPref(ConfigHelper.MAIN_CERT_KEY, cert_json);
+ ConfigHelper.saveSharedPref(ConfigHelper.MAIN_CERT_KEY, cert_string);
JSONObject eip_service_json = getJSONFromProvider(eip_service_json_url, danger_on);
ConfigHelper.saveSharedPref(ConfigHelper.EIP_SERVICE_KEY, eip_service_json);
return true;
@@ -227,7 +226,7 @@ public class ProviderAPI extends IntentService {
if(provider_json == null) {
result.putBoolean(ConfigHelper.RESULT_KEY, false);
} else {
- ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, new JSONObject().put(ConfigHelper.ALLOWED_ANON, provider_json.getJSONObject(ConfigHelper.SERVICE_KEY).getBoolean(ConfigHelper.ALLOWED_ANON)));
+ ConfigHelper.saveSharedPref(ConfigHelper.ALLOWED_ANON, provider_json.getJSONObject(ConfigHelper.SERVICE_KEY).getBoolean(ConfigHelper.ALLOWED_ANON));
String filename = provider_name + "_provider.json".replaceFirst("__", "_");
ConfigHelper.saveFile(filename, provider_json.toString());
@@ -333,8 +332,7 @@ public class ProviderAPI extends IntentService {
try {
cf = CertificateFactory.getInstance("X.509");
- String cert_json_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.MAIN_CERT_KEY);
- String cert_string = new JSONObject(cert_json_string).getString(ConfigHelper.MAIN_CERT_KEY);
+ String cert_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.MAIN_CERT_KEY);
cert_string = cert_string.replaceFirst("-----BEGIN CERTIFICATE-----", "").replaceFirst("-----END CERTIFICATE-----", "").trim();
byte[] cert_bytes = Base64.decode(cert_string, Base64.DEFAULT);
InputStream caInput = new ByteArrayInputStream(cert_bytes);
@@ -381,10 +379,8 @@ public class ProviderAPI extends IntentService {
} catch (KeyManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
+
return json_file_content;
}
@@ -424,10 +420,9 @@ public class ProviderAPI extends IntentService {
}
private boolean getNewCert(Bundle task) {
- String provider_json_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.PROVIDER_KEY);
String type_of_certificate = task.getString(ConfigHelper.TYPE_OF_CERTIFICATE);
try {
- JSONObject provider_json = new JSONObject(provider_json_string);
+ JSONObject provider_json = ConfigHelper.getJsonFromSharedPref(ConfigHelper.PROVIDER_KEY);
URL provider_main_url = new URL(provider_json.getString(ConfigHelper.API_URL_KEY).replace("api.", ""));
String new_cert_string_url = provider_main_url.getProtocol() + "://" + provider_main_url.getHost() + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY) + "/" + ConfigHelper.CERT_KEY;
@@ -439,12 +434,10 @@ public class ProviderAPI extends IntentService {
CookieHandler.setDefault(cookieManager);
}
- String danger_on_json_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.DANGER_ON);
- boolean danger_on = new JSONObject(danger_on_json_string).getBoolean(ConfigHelper.DANGER_ON);
+ boolean danger_on = ConfigHelper.getBoolFromSharedPref(ConfigHelper.DANGER_ON);
String cert_string = getStringFromProvider(new_cert_string_url, danger_on);
if(!cert_string.isEmpty()) {
- JSONObject cert_json = new JSONObject().put(ConfigHelper.CERT_KEY, cert_string);
- ConfigHelper.saveSharedPref(ConfigHelper.CERT_KEY, cert_json);
+ ConfigHelper.saveSharedPref(ConfigHelper.CERT_KEY, cert_string);
return true;
} else {
return false;
diff --git a/src/se/leap/leapclient/ProviderListFragment.java b/src/se/leap/leapclient/ProviderListFragment.java
index 4316e9f3..ee3ee8ea 100644
--- a/src/se/leap/leapclient/ProviderListFragment.java
+++ b/src/se/leap/leapclient/ProviderListFragment.java
@@ -2,9 +2,6 @@ package se.leap.leapclient;
import se.leap.leapclient.ProviderListContent.ProviderItem;
import android.app.Activity;
-import android.app.DialogFragment;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;