summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient
diff options
context:
space:
mode:
authorcyBerta <richy@cyborgsociety.org>2013-12-20 20:25:48 +0100
committercyBerta <richy@cyborgsociety.org>2013-12-20 20:25:48 +0100
commit31e0ee7819ff6e852bc40f66858f0ac02659bf04 (patch)
tree85969d750a2473a95603e07f256681ca46c746cd /src/se/leap/bitmaskclient
parent8bc035e5785b8a14c26cdb6ab409242b66554992 (diff)
parentc500f60c9188c938b550b8741ca9a4f4939429e4 (diff)
Merge branch 'feature/token-based-auth' into develop
Conflicts: src/se/leap/bitmaskclient/ConfigurationWizard.java src/se/leap/bitmaskclient/Dashboard.java src/se/leap/bitmaskclient/ProviderAPI.java src/se/leap/bitmaskclient/ProviderListFragment.java
Diffstat (limited to 'src/se/leap/bitmaskclient')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java6
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java2
-rw-r--r--src/se/leap/bitmaskclient/LeapSRPSession.java11
-rw-r--r--src/se/leap/bitmaskclient/ProviderAPI.java18
-rw-r--r--src/se/leap/bitmaskclient/ProviderListFragment.java16
5 files changed, 47 insertions, 6 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index a4d8599f..694dbf7c 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -189,9 +189,9 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
// resetOldConnection();
ProviderItem selected_provider = getProvider(id);
int provider_index = getProviderIndex(id);
- startProgressBar(provider_index);
- provider_list_fragment.hideAllBut(provider_index);
- setUpProvider(selected_provider.providerMainUrl(), true);
+ startProgressBar(provider_index);
+ provider_list_fragment.hideAllBut(provider_index);
+ setUpProvider(selected_provider.providerMainUrl(), true);
}
@Override
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index 7f898a67..01a9c20a 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -88,6 +88,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
// mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
// eipStatus = (TextView) findViewById(R.id.eipStatus);
+
mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
ConfigHelper.setSharedPreferences(getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE));
@@ -465,4 +466,5 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
startService(eip_intent);
}
+
}
diff --git a/src/se/leap/bitmaskclient/LeapSRPSession.java b/src/se/leap/bitmaskclient/LeapSRPSession.java
index 14a8bff2..0849f777 100644
--- a/src/se/leap/bitmaskclient/LeapSRPSession.java
+++ b/src/se/leap/bitmaskclient/LeapSRPSession.java
@@ -35,9 +35,12 @@ import org.jboss.security.srp.SRPParameters;
*/
public class LeapSRPSession {
+ private static String token = "";
+
final public static String SALT = "salt";
final public static String M1 = "M1";
final public static String M2 = "M2";
+ final public static String TOKEN = "token";
private SRPParameters params;
private String username;
@@ -312,6 +315,14 @@ public class LeapSRPSession {
boolean valid = Arrays.equals(M2, myM2);
return valid;
}
+
+ protected static void setToken(String token) {
+ LeapSRPSession.token = token;
+ }
+
+ protected static String getToken() {
+ return token;
+ }
/**
* @return a new SHA-256 digest.
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java
index 2a1cd29b..cc94edff 100644
--- a/src/se/leap/bitmaskclient/ProviderAPI.java
+++ b/src/se/leap/bitmaskclient/ProviderAPI.java
@@ -27,6 +27,7 @@ import java.net.CookieManager;
import java.net.CookiePolicy;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
@@ -343,6 +344,9 @@ public class ProviderAPI extends IntentService {
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(LeapSRPSession.M2, ConfigHelper.trim(M2_not_trimmed));
+ CookieHandler.setDefault(null); // we don't need cookies anymore
+ String token = json_response.getString(LeapSRPSession.TOKEN);
+ LeapSRPSession.setToken(token);
}
return session_idAndM2;
}
@@ -516,6 +520,8 @@ public class ProviderAPI extends IntentService {
provider_url = new URL(string_url);
URLConnection url_connection = provider_url.openConnection();
url_connection.setConnectTimeout(seconds_of_timeout*1000);
+ if(!LeapSRPSession.getToken().isEmpty())
+ url_connection.addRequestProperty(LeapSRPSession.TOKEN, LeapSRPSession.getToken());
json_file_content = new Scanner(url_connection.getInputStream()).useDelimiter("\\A").next();
} catch (MalformedURLException e) {
json_file_content = formatErrorMessage(R.string.malformed_url);
@@ -551,6 +557,8 @@ public class ProviderAPI extends IntentService {
HttpsURLConnection urlConnection =
(HttpsURLConnection)url.openConnection();
urlConnection.setSSLSocketFactory(getProviderSSLSocketFactory());
+ if(!LeapSRPSession.getToken().isEmpty())
+ urlConnection.addRequestProperty(LeapSRPSession.TOKEN, LeapSRPSession.getToken());
json_file_content = new Scanner(urlConnection.getInputStream()).useDelimiter("\\A").next();
} catch (CertificateException e) {
// TODO Auto-generated catch block
@@ -670,6 +678,7 @@ public class ProviderAPI extends IntentService {
int responseCode = urlConnection.getResponseCode();
broadcast_progress(progress++);
+ LeapSRPSession.setToken("");
Log.d("logout", Integer.toString(responseCode));
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
@@ -710,11 +719,14 @@ public class ProviderAPI extends IntentService {
try {
String type_of_certificate = task.getString(ConfigurationWizard.TYPE_OF_CERTIFICATE);
JSONObject provider_json = ConfigHelper.getJsonFromSharedPref(Provider.KEY);
- URL provider_main_url = new URL(provider_json.getString(Provider.API_URL));
- String new_cert_string_url = provider_main_url.toString() + "/" + provider_json.getString(Provider.API_VERSION) + "/" + EIP.CERTIFICATE;
+ String provider_main_url = provider_json.getString(Provider.API_URL);
+ URL new_cert_string_url = new URL(provider_main_url + "/" + provider_json.getString(Provider.API_VERSION) + "/" + EIP.CERTIFICATE);
boolean danger_on = ConfigHelper.getBoolFromSharedPref(ProviderItem.DANGER_ON);
- String cert_string = downloadWithProviderCA(new_cert_string_url, true);
+//<<<<<<< HEAD
+// String cert_string = downloadWithProviderCA(new_cert_string_url, true);
+//=======
+ String cert_string = downloadWithProviderCA(new_cert_string_url.toString(), danger_on);
if(!cert_string.isEmpty()) {
if(ConfigHelper.checkErroneousDownload(cert_string)) {
String reason_to_fail = provider_json.getString(ERRORS);
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java
index 501da609..f074e665 100644
--- a/src/se/leap/bitmaskclient/ProviderListFragment.java
+++ b/src/se/leap/bitmaskclient/ProviderListFragment.java
@@ -156,6 +156,14 @@ public class ProviderListFragment extends ListFragment {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mCallbacks.onItemSelected(ProviderListContent.ITEMS.get(position).name());
+//<<<<<<< HEAD
+//=======
+
+ for(int item_position = 0; item_position < listView.getCount(); item_position++) {
+ if(item_position != position)
+ content_adapter.hide(item_position);
+ }
+//>>>>>>> feature/token-based-auth
}
@Override
@@ -198,6 +206,7 @@ public class ProviderListFragment extends ListFragment {
}
public void hideAllBut(int position) {
+//<<<<<<< HEAD
int real_count = content_adapter.getCount();
for(int i = 0; i < real_count;)
if(i != position) {
@@ -207,6 +216,13 @@ public class ProviderListFragment extends ListFragment {
} else {
i++;
}
+//=======
+/* for(int i = 0; i < content_adapter.getCount(); i++)
+ if(i != position)
+ content_adapter.hide(i);
+ else
+ content_adapter.unHide(i);
+*///>>>>>>> feature/token-based-auth
}
public void unhideAll() {