summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-03-10 10:08:46 +0100
committerParménides GV <parmegv@sdf.org>2015-03-10 10:08:46 +0100
commit49f906005c2d80dab2751d4e6beff100e99586c1 (patch)
tree311c7c4c1a19f726b33dd1ce07c8d10c4112bda3
parent6e245043236476b0d440732a729a47304dddce96 (diff)
Logged in == leapsrpsession has a token
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java15
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Constants.java1
3 files changed, 8 insertions, 14 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index a4197eaf..4fe51939 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -63,7 +63,6 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
EipFragment eip_fragment;
private Provider provider;
- private static boolean authed_eip;
public ProviderAPIResultReceiver providerAPI_result_receiver;
private boolean switching_provider;
@@ -148,7 +147,6 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
sessionDialog(Bundle.EMPTY);
}
- preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
} else if (resultCode == RESULT_CANCELED && data.hasExtra(ACTION_QUIT)) {
finish();
} else
@@ -222,12 +220,11 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
if(!provider_json_string.isEmpty()) {
provider_json = new JSONObject(provider_json_string);
JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE);
- boolean authed_eip = !LeapSRPSession.getToken().isEmpty();
boolean allow_registered_eip = service_description.getBoolean(Provider.ALLOW_REGISTRATION);
preferences.edit().putBoolean(Constants.ALLOWED_REGISTERED, allow_registered_eip).apply();
if(allow_registered_eip) {
- if(authed_eip) {
+ if(LeapSRPSession.loggedIn()) {
menu.findItem(R.id.login_button).setVisible(false);
menu.findItem(R.id.logout_button).setVisible(true);
} else {
@@ -265,7 +262,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
return true;
case R.id.switch_provider:
switching_provider = true;
- if (preferences.getBoolean(Constants.AUTHED_EIP, false)) logOut();
+ if (LeapSRPSession.loggedIn()) logOut();
else switchProvider();
return true;
case R.id.login_button:
@@ -299,7 +296,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
}
protected void downloadVpnCertificate() {
- boolean is_authenticated = !LeapSRPSession.getToken().isEmpty();
+ boolean is_authenticated = LeapSRPSession.loggedIn();
boolean allowed_anon = preferences.getBoolean(Constants.ALLOWED_ANON, false);
if(allowed_anon || is_authenticated)
providerApiCommand(Bundle.EMPTY, R.string.downloading_certificate_message, ProviderAPI.DOWNLOAD_CERTIFICATE);
@@ -373,18 +370,12 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn
updateViewHidingProgressBar(resultCode);
sessionDialog(resultData);
} else if(resultCode == ProviderAPI.SUCCESSFUL_LOGIN) {
- authed_eip = true;
- preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
-
updateViewHidingProgressBar(resultCode);
downloadVpnCertificate();
} else if(resultCode == ProviderAPI.FAILED_LOGIN) {
updateViewHidingProgressBar(resultCode);
sessionDialog(resultData);
} else if(resultCode == ProviderAPI.SUCCESSFUL_LOGOUT) {
- authed_eip = false;
- preferences.edit().putBoolean(Constants.AUTHED_EIP, authed_eip).apply();
-
updateViewHidingProgressBar(resultCode);
if(switching_provider) switchProvider();
} else if(resultCode == ProviderAPI.LOGOUT_FAILED) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
index 989dc395..09855baf 100644
--- a/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
+++ b/app/src/main/java/se/leap/bitmaskclient/LeapSRPSession.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
- package se.leap.bitmaskclient;
+package se.leap.bitmaskclient;
import org.jboss.security.srp.SRPParameters;
@@ -331,6 +331,10 @@ public class LeapSRPSession {
return token;
}
+ protected static boolean loggedIn() {
+ return !token.isEmpty();
+ }
+
/**
* @return a new SHA-256 digest.
*/
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
index 12c2e015..f7206927 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
@@ -27,7 +27,6 @@ public interface Constants {
public final static String TAG = Constants.class.getSimpleName();
- public final static String AUTHED_EIP = TAG + ".AUTHED_EIP";
public final static String ACTION_CHECK_CERT_VALIDITY = TAG + ".CHECK_CERT_VALIDITY";
public final static String ACTION_START_EIP = TAG + ".START_EIP";
public final static String ACTION_STOP_EIP = TAG + ".STOP_EIP";