summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ProviderAPI.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-08-14 12:15:42 +0200
committerSean Leonard <meanderingcode@aetherislands.net>2013-10-03 16:50:04 -0700
commit37bb23c5549ffe690f65b1c04cf432bd3153bf04 (patch)
treecb221b9304905e25695c59be60f0eeb62fe25a36 /src/se/leap/leapclient/ProviderAPI.java
parent697e7da6e1379ac23cd8dbb47a1246547abafda6 (diff)
Login dialog requires username.
I've also changed the way we notify that the password should have 8 characters at least, to make it consistent to the way we notify username is required.
Diffstat (limited to 'src/se/leap/leapclient/ProviderAPI.java')
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index e7d329f8..2170478b 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -225,7 +225,7 @@ public class ProviderAPI extends IntentService {
String username = (String) task.get(LogInDialog.USERNAME);
String password = (String) task.get(LogInDialog.PASSWORD);
- if(wellFormedPassword(password)) {
+ if(validUserLoginData(username, password)) {
String authentication_server = (String) task.get(Provider.API_URL);
SRPParameters params = new SRPParameters(new BigInteger(ConfigHelper.NG_1024, 16).toByteArray(), ConfigHelper.G.toByteArray(), BigInteger.ZERO.toByteArray(), "SHA-256");
@@ -277,15 +277,31 @@ public class ProviderAPI extends IntentService {
e.printStackTrace();
}
} else {
- session_id_bundle.putBoolean(RESULT_KEY, false);
- session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_not_valid_password_user_message));
- session_id_bundle.putString(LogInDialog.USERNAME, username);
+ if(!wellFormedPassword(password)) {
+ session_id_bundle.putBoolean(RESULT_KEY, false);
+ session_id_bundle.putString(LogInDialog.USERNAME, username);
+ session_id_bundle.putBoolean(LogInDialog.PASSWORD_INVALID_LENGTH, true);
+ }
+ if(username.isEmpty()) {
+ session_id_bundle.putBoolean(RESULT_KEY, false);
+ session_id_bundle.putBoolean(LogInDialog.USERNAME_MISSING, true);
+ }
}
return session_id_bundle;
}
/**
+ * Validates parameters entered by the user to log in
+ * @param entered_username
+ * @param entered_password
+ * @return true if both parameters are present and the entered password length is greater or equal to eight (8).
+ */
+ private boolean validUserLoginData(String entered_username, String entered_password) {
+ return !(entered_username.isEmpty()) && wellFormedPassword(entered_password);
+ }
+
+ /**
* Validates a password
* @param entered_password
* @return true if the entered password length is greater or equal to eight (8).