From 3ab74308e7ba1fda02d3427ec795eac397707199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 5 May 2014 15:13:47 +0200 Subject: Sign up methods to be tested. --- .../java/se/leap/bitmaskclient/LeapSRPSession.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java index a317d95e..db091300 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java +++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java @@ -155,12 +155,25 @@ public class LeapSRPSession { return x_digest_bytes; } + public byte[] calculateSaltedPassword() { + try { + BigInteger salt = new BigInteger(128, SecureRandom.getInstance("SHA1PRNG")); + MessageDigest salted_password = newDigest(); + salted_password.update(salt.toByteArray()); + salted_password.update(password.getBytes()); + return salted_password.digest(); + } catch (NoSuchAlgorithmException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } /** * Calculates the parameter V of the SRP-6a algorithm. - * @param k_string constant k predefined by the SRP server implementation. * @return the value of V */ - private BigInteger calculateV(String k_string) { + public BigInteger calculateV() { + String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; BigInteger k = new BigInteger(k_string, 16); BigInteger v = k.multiply(g.modPow(x, N)); // g^x % N return v; @@ -217,8 +230,7 @@ public class LeapSRPSession { this.x = new BigInteger(1, xb); // Calculate v = kg^x mod N - String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; - this.v = calculateV(k_string); + this.v = calculateV(); // H(N) byte[] digest_of_n = newDigest().digest(N_bytes); -- cgit v1.2.3 From 230ae10fb3a0c08cbd16e91fce041133bdf5ae8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 5 May 2014 16:06:53 +0200 Subject: New menu option: signup. There is some problem in the maths, because the server says it's ok but login doesn't work from Android app nor from webapp. --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 59 +++++++- .../java/se/leap/bitmaskclient/LeapSRPSession.java | 9 +- .../java/se/leap/bitmaskclient/SignUpDialog.java | 150 +++++++++++++++++++++ app/src/main/res/menu/client_dashboard.xml | 13 +- app/src/main/res/values/strings.xml | 1 + 5 files changed, 221 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 3c17ebb8..241286bb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -21,6 +21,7 @@ import org.json.JSONObject; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.ProviderAPIResultReceiver.Receiver; +import se.leap.bitmaskclient.SignUpDialog; import android.app.Activity; import android.app.AlertDialog; import android.app.DialogFragment; @@ -50,7 +51,7 @@ import android.widget.Toast; * @author Sean Leonard * @author parmegv */ -public class Dashboard extends Activity implements LogInDialog.LogInDialogInterface,Receiver { +public class Dashboard extends Activity implements LogInDialog.LogInDialogInterface, SignUpDialog.SignUpDialogInterface, Receiver { protected static final int CONFIGURE_LEAP = 0; protected static final int SWITCH_PROVIDER = 1; @@ -204,6 +205,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf menu.findItem(R.id.login_button).setVisible(true); menu.findItem(R.id.logout_button).setVisible(false); } + menu.findItem(R.id.signup_button).setVisible(true); } } catch (JSONException e) { // TODO Auto-generated catch block @@ -243,6 +245,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf case R.id.logout_button: logOut(); return true; + case R.id.signup_button: + signUpDialog(((ViewGroup)findViewById(android.R.id.content)).getChildAt(0), Bundle.EMPTY); + return true; default: return super.onOptionsItemSelected(item); } @@ -340,6 +345,58 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf newFragment.show(fragment_transaction, LogInDialog.TAG); } + @Override + public void signUp(String username, String password) { + mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); + eipStatus = (TextView) findViewById(R.id.eipStatus); + + providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler()); + providerAPI_result_receiver.setReceiver(this); + + Intent provider_API_command = new Intent(this, ProviderAPI.class); + + Bundle parameters = new Bundle(); + parameters.putString(SignUpDialog.USERNAME, username); + parameters.putString(SignUpDialog.PASSWORD, password); + + JSONObject provider_json; + try { + provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); + parameters.putString(Provider.API_URL, provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION)); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + provider_API_command.setAction(ProviderAPI.SRP_REGISTER); + provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); + provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); + + mProgressBar.setVisibility(ProgressBar.VISIBLE); + eipStatus.setText(R.string.authenticating_message); + //mProgressBar.setMax(4); + startService(provider_API_command); + } + + /** + * Shows the sign up dialog. + * @param view from which the dialog is created. + */ + public void signUpDialog(View view, Bundle resultData) { + FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction(); + Fragment previous_sign_up_dialog = getFragmentManager().findFragmentByTag(SignUpDialog.TAG); + if (previous_sign_up_dialog != null) { + fragment_transaction.remove(previous_sign_up_dialog); + } + fragment_transaction.addToBackStack(null); + + DialogFragment newFragment = SignUpDialog.newInstance(); + if(resultData != null && !resultData.isEmpty()) { + newFragment.setArguments(resultData); + } + newFragment.show(fragment_transaction, SignUpDialog.TAG); + } + /** * Asks ProviderAPI to download an authenticated OpenVPN certificate. * @param session_id cookie for the server to allow us to download the certificate. diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java index db091300..8d95cdb8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java +++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java @@ -172,9 +172,11 @@ public class LeapSRPSession { * Calculates the parameter V of the SRP-6a algorithm. * @return the value of V */ - public BigInteger calculateV() { + public BigInteger calculateV(String username, String password, byte[] salt) { String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; BigInteger k = new BigInteger(k_string, 16); + byte[] x_bytes = calculatePasswordHash(username, password, ConfigHelper.trim(salt)); + x = new BigInteger(1, x_bytes); BigInteger v = k.multiply(g.modPow(x, N)); // g^x % N return v; } @@ -226,11 +228,8 @@ public class LeapSRPSession { // Calculate x = H(s | H(U | ':' | password)) byte[] M1 = null; if(new BigInteger(1, Bbytes).mod(new BigInteger(1, N_bytes)) != BigInteger.ZERO) { - byte[] xb = calculatePasswordHash(username, password, ConfigHelper.trim(salt_bytes)); - this.x = new BigInteger(1, xb); - // Calculate v = kg^x mod N - this.v = calculateV(); + this.v = calculateV(username, password, salt_bytes); // H(N) byte[] digest_of_n = newDigest().digest(N_bytes); diff --git a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java new file mode 100644 index 00000000..601df843 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java @@ -0,0 +1,150 @@ +/** + * Copyright (c) 2013 LEAP Encryption Access Project and contributers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package se.leap.bitmaskclient; + +import se.leap.bitmaskclient.R; +import android.R.color; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.content.res.ColorStateList; +import android.os.Bundle; +import android.provider.CalendarContract.Colors; +import android.view.LayoutInflater; +import android.view.View; +import android.view.animation.AlphaAnimation; +import android.view.animation.BounceInterpolator; +import android.widget.EditText; +import android.widget.TextView; + +/** + * Implements the sign up dialog, currently without progress dialog. + * + * It returns to the previous fragment when finished, and sends username and password to the registration method. + * + * It also notifies the user if the password is not valid. + * + * @author parmegv + * + */ +public class SignUpDialog extends DialogFragment { + + final public static String TAG = "signUpDialog"; + final public static String VERB = "log in"; + final public static String USERNAME = "username"; + final public static String PASSWORD = "password"; + final public static String USERNAME_MISSING = "username missing"; + final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length"; + + private static boolean is_eip_pending = false; + + public AlertDialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + LayoutInflater inflater = getActivity().getLayoutInflater(); + View log_in_dialog_view = inflater.inflate(R.layout.log_in_dialog, null); + + final TextView user_message = (TextView)log_in_dialog_view.findViewById(R.id.user_message); + if(getArguments() != null && getArguments().containsKey(getResources().getString(R.string.user_message))) { + user_message.setText(getArguments().getString(getResources().getString(R.string.user_message))); + } else { + user_message.setVisibility(View.GONE); + } + + final EditText username_field = (EditText)log_in_dialog_view.findViewById(R.id.username_entered); + if(getArguments() != null && getArguments().containsKey(USERNAME)) { + String username = getArguments().getString(USERNAME); + username_field.setText(username); + } + if (getArguments() != null && getArguments().containsKey(USERNAME_MISSING)) { + username_field.setError(getResources().getString(R.string.username_ask)); + } + + final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered); + if(!username_field.getText().toString().isEmpty() && password_field.isFocusable()) { + password_field.requestFocus(); + } + if (getArguments() != null && getArguments().containsKey(PASSWORD_INVALID_LENGTH)) { + password_field.setError(getResources().getString(R.string.error_not_valid_password_user_message)); + } + if(getArguments() != null && getArguments().getBoolean(EipServiceFragment.IS_EIP_PENDING, false)) { + is_eip_pending = true; + } + + + builder.setView(log_in_dialog_view) + .setPositiveButton(R.string.signup_button, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + String username = username_field.getText().toString(); + String password = password_field.getText().toString(); + dialog.dismiss(); + interface_with_Dashboard.signUp(username, password); + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); + + return builder.create(); + } + + /** + * Interface used to communicate SignUpDialog with Dashboard. + * + * @author parmegv + * + */ + public interface SignUpDialogInterface { + /** + * Starts authentication process. + * @param username + * @param password + */ + public void signUp(String username, String password); + public void cancelAuthedEipOn(); + } + + SignUpDialogInterface interface_with_Dashboard; + + /** + * @return a new instance of this DialogFragment. + */ + public static DialogFragment newInstance() { + SignUpDialog dialog_fragment = new SignUpDialog(); + return dialog_fragment; + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + interface_with_Dashboard = (SignUpDialogInterface) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement SignUpDialogListener"); + } + } + + @Override + public void onCancel(DialogInterface dialog) { + if(is_eip_pending) + interface_with_Dashboard.cancelAuthedEipOn(); + super.onCancel(dialog); + } +} diff --git a/app/src/main/res/menu/client_dashboard.xml b/app/src/main/res/menu/client_dashboard.xml index 676c07c7..d4e9c879 100644 --- a/app/src/main/res/menu/client_dashboard.xml +++ b/app/src/main/res/menu/client_dashboard.xml @@ -6,18 +6,21 @@ + android:title="@string/switch_provider_menu_option"/> + - + android:visible="false"/> - + android:visible="false"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 492c48c7..5f0e2120 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -116,6 +116,7 @@ Update the app Log In Log Out + Sign Up Configuration Error Configure Exit -- cgit v1.2.3 From 69c299b9c891d92ff7e5bc87e32b9acb10901b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 7 May 2014 13:55:46 +0200 Subject: Signup protocol coded. UI next. --- .../java/se/leap/bitmaskclient/LeapSRPSession.java | 34 ++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java index 8d95cdb8..f8279b64 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java +++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java @@ -16,13 +16,13 @@ */ package se.leap.bitmaskclient; + import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Arrays; - import org.jboss.security.srp.SRPParameters; /** @@ -42,6 +42,7 @@ public class LeapSRPSession { final public static String M2 = "M2"; final public static String TOKEN = "token"; final public static String AUTHORIZATION_HEADER= "Authorization"; + final public static String TAG= "Leap SRP session class tag"; private SRPParameters params; private String username; @@ -155,15 +156,11 @@ public class LeapSRPSession { return x_digest_bytes; } - public byte[] calculateSaltedPassword() { + public byte[] calculateNewSalt() { try { - BigInteger salt = new BigInteger(128, SecureRandom.getInstance("SHA1PRNG")); - MessageDigest salted_password = newDigest(); - salted_password.update(salt.toByteArray()); - salted_password.update(password.getBytes()); - return salted_password.digest(); - } catch (NoSuchAlgorithmException e) { - // TODO Auto-generated catch block + BigInteger salt = new BigInteger(64, SecureRandom.getInstance("SHA1PRNG")); + return salt.toByteArray(); + } catch(NoSuchAlgorithmException e) { e.printStackTrace(); } return null; @@ -173,11 +170,9 @@ public class LeapSRPSession { * @return the value of V */ public BigInteger calculateV(String username, String password, byte[] salt) { - String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; - BigInteger k = new BigInteger(k_string, 16); byte[] x_bytes = calculatePasswordHash(username, password, ConfigHelper.trim(salt)); x = new BigInteger(1, x_bytes); - BigInteger v = k.multiply(g.modPow(x, N)); // g^x % N + BigInteger v = g.modPow(x, N); // g^x % N return v; } @@ -224,13 +219,11 @@ public class LeapSRPSession { * @return the parameter M1 * @throws NoSuchAlgorithmException */ - public byte[] response(byte[] salt_bytes, byte[] Bbytes) throws NoSuchAlgorithmException { + public byte[] response(byte[] salt_bytes, byte[] Bbytes) throws NoSuchAlgorithmException { // Calculate x = H(s | H(U | ':' | password)) byte[] M1 = null; if(new BigInteger(1, Bbytes).mod(new BigInteger(1, N_bytes)) != BigInteger.ZERO) { - // Calculate v = kg^x mod N - this.v = calculateV(username, password, salt_bytes); - + this.v = calculateV(username, password, salt_bytes); // H(N) byte[] digest_of_n = newDigest().digest(N_bytes); @@ -294,8 +287,9 @@ public class LeapSRPSession { BigInteger B = new BigInteger(1, Bbytes); BigInteger u = new BigInteger(1, u_bytes); - - BigInteger B_minus_v = B.subtract(v); + String k_string = "bf66c44a428916cad64aa7c679f3fd897ad4c375e9bbb4cbf2f5de241d618ef0"; + BigInteger k = new BigInteger(k_string, 16); + BigInteger B_minus_v = B.subtract(k.multiply(v)); BigInteger a_ux = a.add(u.multiply(x)); BigInteger S = B_minus_v.modPow(a_ux, N); return S; @@ -349,4 +343,8 @@ public class LeapSRPSession { } return md; } + + public byte[] getK() { + return K; + } } -- cgit v1.2.3 From 6d9770518b0d94931e9521b72131516a841b193f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 8 May 2014 09:51:53 +0200 Subject: Raw json error messages shown. A bit of refactoring too, sendM1 much simpler. --- app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java index f8279b64..29b429d1 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java +++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java @@ -219,7 +219,7 @@ public class LeapSRPSession { * @return the parameter M1 * @throws NoSuchAlgorithmException */ - public byte[] response(byte[] salt_bytes, byte[] Bbytes) throws NoSuchAlgorithmException { + public byte[] response(byte[] salt_bytes, byte[] Bbytes) { // Calculate x = H(s | H(U | ':' | password)) byte[] M1 = null; if(new BigInteger(1, Bbytes).mod(new BigInteger(1, N_bytes)) != BigInteger.ZERO) { @@ -257,8 +257,7 @@ public class LeapSRPSession { byte[] S_bytes = ConfigHelper.trim(S.toByteArray()); // K = SessionHash(S) - String hash_algorithm = params.hashAlgorithm; - MessageDigest sessionDigest = MessageDigest.getInstance(hash_algorithm); + MessageDigest sessionDigest = newDigest(); K = ConfigHelper.trim(sessionDigest.digest(S_bytes)); // clientHash = H(N) xor H(g) | H(U) | A | B | K -- cgit v1.2.3 From daff611c70bb5e8b3bdc5f5c42bc776acb6e8e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 8 May 2014 11:33:34 +0200 Subject: Automatically log in. Functionality copied to the Release build. --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 10 +++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 241286bb..f8db33f3 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -373,7 +373,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); mProgressBar.setVisibility(ProgressBar.VISIBLE); - eipStatus.setText(R.string.authenticating_message); + eipStatus.setText(R.string.signingup_message); //mProgressBar.setMax(4); startService(provider_API_command); } @@ -421,7 +421,11 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf @Override public void onReceiveResult(int resultCode, Bundle resultData) { - if(resultCode == ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL){ + if(resultCode == ProviderAPI.SRP_REGISTRATION_SUCCESSFUL){ + authenticate(resultData.getString(LogInDialog.USERNAME), resultData.getString(LogInDialog.PASSWORD)); + } else if(resultCode == ProviderAPI.SRP_REGISTRATION_FAILED){ + signUpDialog(((ViewGroup)findViewById(android.R.id.content)).getChildAt(0), resultData); + } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_SUCCESSFUL){ String session_id_cookie_key = resultData.getString(ProviderAPI.SESSION_ID_COOKIE_KEY); String session_id_string = resultData.getString(ProviderAPI.SESSION_ID_KEY); setResult(RESULT_OK); @@ -436,7 +440,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf //Cookie session_id = new BasicClientCookie(session_id_cookie_key, session_id_string); downloadAuthedUserCertificate(/*session_id*/); } else if(resultCode == ProviderAPI.SRP_AUTHENTICATION_FAILED) { - logInDialog(getCurrentFocus(), resultData); + logInDialog(getCurrentFocus(), resultData); } else if(resultCode == ProviderAPI.LOGOUT_SUCCESSFUL) { authed_eip = false; getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5f0e2120..ac692a69 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -127,6 +127,7 @@ Configuring provider Your anon cert was not downloaded Logging in + Signing up Logging out from this session. Didn\'t logged out. Authentication succeeded. -- cgit v1.2.3 From 00c185a7b6bfc727ff53b9a87620766e5adbb7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 8 May 2014 11:46:11 +0200 Subject: Cancelling a failed signup/login stops progressbar --- app/src/main/java/se/leap/bitmaskclient/Dashboard.java | 9 +++++++++ app/src/main/java/se/leap/bitmaskclient/LogInDialog.java | 2 ++ app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java | 2 ++ 3 files changed, 13 insertions(+) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index f8db33f3..6f18b79a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -291,6 +291,15 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf EipServiceFragment eipFragment = (EipServiceFragment) getFragmentManager().findFragmentByTag(EipServiceFragment.TAG); eipFragment.checkEipSwitch(false); } + + public void cancelLoginOrSignup() { + if(mProgressBar == null) mProgressBar = (ProgressBar) findViewById(R.id.eipProgress); + if(mProgressBar != null) { + mProgressBar.setVisibility(ProgressBar.GONE); + if(eipStatus == null) eipStatus = (TextView) findViewById(R.id.eipStatus); + if(eipStatus != null) eipStatus.setText(""); + } + } /** * Asks ProviderAPI to log out. diff --git a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java index a28c9049..da74958d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java @@ -99,6 +99,7 @@ public class LogInDialog extends DialogFragment { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); + interface_with_Dashboard.cancelLoginOrSignup(); } }); @@ -119,6 +120,7 @@ public class LogInDialog extends DialogFragment { */ public void authenticate(String username, String password); public void cancelAuthedEipOn(); + public void cancelLoginOrSignup(); } LogInDialogInterface interface_with_Dashboard; diff --git a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java index 601df843..2ba65c5d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java @@ -98,6 +98,7 @@ public class SignUpDialog extends DialogFragment { .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); + interface_with_Dashboard.cancelLoginOrSignup(); } }); @@ -118,6 +119,7 @@ public class SignUpDialog extends DialogFragment { */ public void signUp(String username, String password); public void cancelAuthedEipOn(); + public void cancelLoginOrSignup(); } SignUpDialogInterface interface_with_Dashboard; -- cgit v1.2.3 From de649fdd31f2d673de8eca9684ff5c66fbd53ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 8 May 2014 12:08:47 +0200 Subject: Signup option in login dialog. --- app/src/main/java/se/leap/bitmaskclient/LogInDialog.java | 13 ++++++++----- app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java | 5 ----- app/src/main/res/menu/client_dashboard.xml | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java index da74958d..45d3a373 100644 --- a/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/LogInDialog.java @@ -101,6 +101,13 @@ public class LogInDialog extends DialogFragment { dialog.cancel(); interface_with_Dashboard.cancelLoginOrSignup(); } + }) + .setNeutralButton(R.string.signup_button, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + String username = username_field.getText().toString(); + String password = password_field.getText().toString(); + interface_with_Dashboard.signUp(username, password); + } }); return builder.create(); @@ -113,13 +120,9 @@ public class LogInDialog extends DialogFragment { * */ public interface LogInDialogInterface { - /** - * Starts authentication process. - * @param username - * @param password - */ public void authenticate(String username, String password); public void cancelAuthedEipOn(); + public void signUp(String username, String password); public void cancelLoginOrSignup(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java index 2ba65c5d..120d4eec 100644 --- a/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/SignUpDialog.java @@ -112,11 +112,6 @@ public class SignUpDialog extends DialogFragment { * */ public interface SignUpDialogInterface { - /** - * Starts authentication process. - * @param username - * @param password - */ public void signUp(String username, String password); public void cancelAuthedEipOn(); public void cancelLoginOrSignup(); diff --git a/app/src/main/res/menu/client_dashboard.xml b/app/src/main/res/menu/client_dashboard.xml index d4e9c879..663231cd 100644 --- a/app/src/main/res/menu/client_dashboard.xml +++ b/app/src/main/res/menu/client_dashboard.xml @@ -9,7 +9,6 @@ android:title="@string/switch_provider_menu_option"/>