summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-06-20 16:52:43 +0200
committerParménides GV <parmegv@sdf.org>2013-06-20 16:53:14 +0200
commitf4956bb818fb9ed04760e6de3b53b876272da5cc (patch)
tree94b7b8629ea75a6e4db730aa20232103799ae7a0
parentd475ae617d8dc0994a1294be7c8cca338a68fd9e (diff)
User messages are now in string.xml
Some more constants added to ConfigHelper. This solves #2908.
l---------[-rw-r--r--]README66
-rw-r--r--assets/urls/bitmask.url2
-rwxr-xr-xres/values/strings.xml14
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java6
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java16
-rw-r--r--src/se/leap/leapclient/Dashboard.java18
-rw-r--r--src/se/leap/leapclient/LogInDialog.java2
-rw-r--r--src/se/leap/leapclient/NewProviderDialog.java4
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java6
-rw-r--r--src/se/leap/leapclient/ProviderListContent.java6
10 files changed, 47 insertions, 93 deletions
diff --git a/README b/README
index 7d57a6e3..c3ca0746 100644..120000
--- a/README
+++ b/README
@@ -1,65 +1 @@
-Compiling
-=========
-
-Preconditions
-----------------
-
-1. Android SDK installed (follow instructions from http://developer.android.com/sdk/index.html)
-2. API version 16 or version installed.
-2. Ant 1.6 or greater
-
-Instructions to compile
------------------------
-
-1. cd $PROJECT_LOCATION/leap_android
-2. ./compile.sh
-
-Postconditions
---------------
-
-1. $PROJECT_LOCATION/leap_android/bin/LEAP Android-debug.apk exists
-
-Running on the emulator
-=========================
-
-Preconditions
------------------
-
-1. Android SDK is installed, and its tools are in the PATH.
-2. leap_android has been compiled.
-3. An avd exists in ~/.android/avd/ (if you do not have one, follow instructions from http://developer.android.com/tools/devices/managing-avds-cmdline.html)
-
-Instructions to run on the emulator
------------------------------------
-
-1. cd $PROJECT_LOCATION/leap_android
-1. Run script: ./run.sh @AVD-NAME . (avd names are the names of the files in ~/.android/avd with extension .avd).
-
-Postconditions
---------------
-
-1. LEAP Android is running.
-
-Debugging from console
-======================
-
-Preconditions
------------------
-
-1. Android SDK is installed, and its tools are in the PATH.
-2. leap_android has been compiled.
-3. An avd exists in ~/.android/avd/ (if you do not have one, follow instructions from http://developer.android.com/tools/devices/managing-avds-cmdline.html).
-4. jdb is installed (this program is part of OpenJDK 7)
-
-Instructions to debug from the console
------------------------------------
-
-1. cd $PROJECT_LOCATION/leap_android
-2. Run script: ./debug.sh @AVD-NAME . (avd names are the names of the files in ~/.android/avd with extension .avd).
-
-Postconditions
---------------
-
-1. LEAP Android is running.
-2. LEAP Android does not show the message "Application LEAP for Android (process se.leap.leapclient) is waiting for the debugger to attach".
-3. You are in a jdb debuggin session.
+README.txt \ No newline at end of file
diff --git a/assets/urls/bitmask.url b/assets/urls/bitmask.url
index 910f0400..a17a5ff8 100644
--- a/assets/urls/bitmask.url
+++ b/assets/urls/bitmask.url
@@ -1,7 +1,7 @@
{
"name" : "bitmask",
"assets_json_provider" : "providers/bitmask.net_provider.json",
- "json_provider" : "https://bitmask.net/provider.json",
+ "provider_json_url" : "https://bitmask.net/provider.json",
"cert" : "https://bitmask.net/ca.crt",
"json_eip_service" : "https://api.bitmask.net:4430/1/config/eip-service.json"
} \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4501ac1d..804964c1 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -265,6 +265,8 @@
<string name="introduce_new_provider">Introduce new provider</string>
<string name="save">Save</string>
<string name="new_provider_uri">New provider\'s main URL</string>
+ <string name="valid_url_entered">It seems your URL is well formed</string>
+ <string name="not_valid_url_entered">It seems your URL is not well formed</string>
<string name="username_ask">Introduce your username</string>
<string name="password_ask">Enter your password</string>
<string name="log_in_button">Log in</string>
@@ -281,5 +283,17 @@
<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>
+ <string name="incorrectly_downloaded_json_files_message">You have not entered a LEAP provider URL or it is unavailable</string>
+ <string name="correctly_downloaded_json_files_message">Your anon cert has been correctly downloaded</string>
+ <string name="incorrectly_downloaded_certificate_message">Your anon cert was not downloaded</string>
+ <string name="incorrectly_updated_provider_dot_json_message">Install a new version of this app.</string>
+ <string name="not_valid_password_message">Your password is not well-formed: it should have at least 8 characters.</string>
+ <string name="succesful_authentication_message">Authentication succeeded.</string>
+ <string name="authentication_failed_message">Authentication failed.</string>
+ <string name="successful_log_out_message">Logged out.</string>
+ <string name="log_out_failed_message">Didn\'t logged out.</string>
+ <string name="successful_authed_cert_downloaded_message">Your own cert has been correctly downloaded.</string>
+ <string name="authed_cert_download_failed_message">Your own cert has incorrectly been downloaded.</string>
+
</resources> \ No newline at end of file
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 5838f529..cb4a550f 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -40,11 +40,14 @@ public class ConfigHelper {
NEW_PROVIDER_DIALOG = "logInDialog",
SRP_REGISTER = "srpRegister",
SRP_AUTH = "srpAuth",
+ M1_KEY = "M1",
+ M2_KEY = "M2",
LOG_IN = "logIn",
LOG_OUT = "logOut",
DOWNLOAD_CERTIFICATE = "downloadUserAuthedCertificate",
API_VERSION_KEY = "api_version",
RESULT_KEY = "result",
+ RECEIVER_KEY = "receiver",
PROVIDER_KEY = "provider",
SERVICE_KEY = "service",
ALLOWED_ANON = "allow_anonymous",
@@ -68,7 +71,8 @@ public class ConfigHelper {
USERNAME_KEY = "username",
PASSWORD_KEY = "password",
ALLOW_REGISTRATION_KEY = "allow_registration",
- EIP_SERVICE_API_PATH = "config/eip-service.json"
+ EIP_SERVICE_API_PATH = "config/eip-service.json",
+ ERRORS_KEY = "errors"
;
final public static String NG_1024 =
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index 91b92d65..ce279425 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -105,7 +105,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
}
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();
+ Toast.makeText(getApplicationContext(), R.string.incorrectly_updated_provider_dot_json_message, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
finish();
}
@@ -122,20 +122,20 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
}
}
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();
+ Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_json_files_message, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
finish();
}
else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_CERTIFICATE) {
mProgressDialog.dismiss();
- Toast.makeText(getApplicationContext(), "Your anon cert has been correctly downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.correctly_downloaded_json_files_message, 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) {
mProgressDialog.dismiss();
- Toast.makeText(getApplicationContext(), "Your anon cert was not downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_certificate_message, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
finish();
}
@@ -236,7 +236,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, provider.danger_on);
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -252,7 +252,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
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);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -282,7 +282,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_NEW_PROVIDER_DOTJSON, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -302,7 +302,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
provider_API_command.putExtra(ConfigHelper.UPDATE_PROVIDER_DOTJSON, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java
index e8ea2705..dd8ee335 100644
--- a/src/se/leap/leapclient/Dashboard.java
+++ b/src/se/leap/leapclient/Dashboard.java
@@ -224,7 +224,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
provider_API_command.putExtra(ConfigHelper.SRP_AUTH, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -249,7 +249,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
provider_API_command.putExtra(ConfigHelper.LOG_OUT, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -286,7 +286,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
method_and_parameters.putString(ConfigHelper.SESSION_ID_KEY, session_id.getValue());
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -297,25 +297,25 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
String session_id_cookie_key = resultData.getString(ConfigHelper.SESSION_ID_COOKIE_KEY);
String session_id_string = resultData.getString(ConfigHelper.SESSION_ID_KEY);
setResult(RESULT_OK);
- Toast.makeText(getApplicationContext(), "Authentication succeeded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.succesful_authentication_message, Toast.LENGTH_LONG).show();
Cookie session_id = new BasicClientCookie(session_id_cookie_key, session_id_string);
downloadAuthedUserCertificate(session_id);
} else if(resultCode == ConfigHelper.SRP_AUTHENTICATION_FAILED) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Authentication failed", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.authentication_failed_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.LOGOUT_SUCCESSFUL) {
setResult(RESULT_OK);
- Toast.makeText(getApplicationContext(), "Logged out", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.successful_log_out_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.LOGOUT_FAILED) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Didn't logged out", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.log_out_failed_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_CERTIFICATE) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Your own cert has been correctly downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.successful_authed_cert_downloaded_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Your own cert has incorrectly been downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.authed_cert_download_failed_message, Toast.LENGTH_LONG).show();
}
}
diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java
index 00429d10..dcb92d89 100644
--- a/src/se/leap/leapclient/LogInDialog.java
+++ b/src/se/leap/leapclient/LogInDialog.java
@@ -40,7 +40,7 @@ public class LogInDialog extends DialogFragment {
interface_with_Dashboard.authenticate(username, password);
} else {
password_field.setText("");
- Toast.makeText(getActivity().getApplicationContext(), "Your password is not well-formed: it should have at least 8 characters", Toast.LENGTH_LONG).show();
+ Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_password_message, Toast.LENGTH_LONG).show();
}
}
})
diff --git a/src/se/leap/leapclient/NewProviderDialog.java b/src/se/leap/leapclient/NewProviderDialog.java
index 5b84ec03..678e805f 100644
--- a/src/se/leap/leapclient/NewProviderDialog.java
+++ b/src/se/leap/leapclient/NewProviderDialog.java
@@ -65,10 +65,10 @@ public class NewProviderDialog extends DialogFragment {
boolean danger_on = danger_checkbox.isChecked();
if(validURL(entered_url)) {
interface_with_ConfigurationWizard.saveProvider(entered_url, danger_on);
- Toast.makeText(getActivity().getApplicationContext(), "It seems your URL is well formed", Toast.LENGTH_LONG).show();
+ Toast.makeText(getActivity().getApplicationContext(), R.string.valid_url_entered, Toast.LENGTH_LONG).show();
} else {
url_input_field.setText("");
- Toast.makeText(getActivity().getApplicationContext(), "It seems your URL is not well formed", Toast.LENGTH_LONG).show();
+ Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_password_message, Toast.LENGTH_LONG).show();
}
}
})
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index f8d730e7..4dfe200a 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -219,11 +219,11 @@ public class ProviderAPI extends IntentService {
JSONObject session_idAndM2 = new JSONObject();
if(json_response.length() > 0) {
- byte[] M2_not_trimmed = new BigInteger(json_response.getString("M2"), 16).toByteArray();
+ byte[] M2_not_trimmed = new BigInteger(json_response.getString(ConfigHelper.M2_KEY), 16).toByteArray();
Cookie session_id_cookie = LeapHttpClient.getInstance(getApplicationContext()).getCookieStore().getCookies().get(0);
session_idAndM2.put(ConfigHelper.SESSION_ID_COOKIE_KEY, session_id_cookie.getName());
session_idAndM2.put(ConfigHelper.SESSION_ID_KEY, session_id_cookie.getValue());
- session_idAndM2.put("M2", Util.trim(M2_not_trimmed));
+ session_idAndM2.put(ConfigHelper.M2_KEY, Util.trim(M2_not_trimmed));
}
return session_idAndM2;
}
@@ -245,7 +245,7 @@ public class ProviderAPI extends IntentService {
HttpEntity responseEntity = getResponse.getEntity();
String plain_response = new Scanner(responseEntity.getContent()).useDelimiter("\\A").next();
JSONObject json_response = new JSONObject(plain_response);
- if(!json_response.isNull("errors") || json_response.has("errors")) {
+ if(!json_response.isNull(ConfigHelper.ERRORS_KEY) || json_response.has(ConfigHelper.ERRORS_KEY)) {
return new JSONObject();
}
diff --git a/src/se/leap/leapclient/ProviderListContent.java b/src/se/leap/leapclient/ProviderListContent.java
index 4ae46099..8727b16b 100644
--- a/src/se/leap/leapclient/ProviderListContent.java
+++ b/src/se/leap/leapclient/ProviderListContent.java
@@ -60,10 +60,10 @@ public class ProviderListContent {
JSONObject file_contents = new JSONObject(urls_file_content);
id = name;
this.name = name;
- provider_json_url = file_contents.getString("json_provider");
+ provider_json_url = file_contents.getString(ConfigHelper.PROVIDER_JSON_URL);
provider_json_filename = file_contents.getString("assets_json_provider");
eip_service_json_url = file_contents.getString("json_eip_service");
- cert_json_url = file_contents.getString("cert");
+ cert_json_url = file_contents.getString(ConfigHelper.CERT_KEY);
this.custom = custom;
this.danger_on = danger_on;
} catch (JSONException e) {
@@ -89,7 +89,7 @@ public class ProviderListContent {
this.name = name;
this.provider_json_url = provider_json_url;
this.provider_json = provider_json;
- eip_service_json_url = provider_json.getString("api_uri") + "/" + provider_json.getString("api_version") + "/" + ConfigHelper.EIP_SERVICE_API_PATH;
+ eip_service_json_url = provider_json.getString(ConfigHelper.API_URL_KEY) + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY) + "/" + ConfigHelper.EIP_SERVICE_API_PATH;
cert_json_url = (String) provider_json.get("ca_cert_uri");
this.custom = custom;
this.danger_on = danger_on;