summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java9
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java1
-rw-r--r--src/se/leap/bitmaskclient/EIP.java14
-rw-r--r--src/se/leap/bitmaskclient/EipServiceFragment.java5
-rw-r--r--src/se/leap/bitmaskclient/LeapSRPSession.java11
-rw-r--r--src/se/leap/bitmaskclient/ProviderAPI.java43
-rw-r--r--src/se/leap/bitmaskclient/ProviderListFragment.java24
-rw-r--r--src/se/leap/openvpn/OpenVpnService.java4
8 files changed, 91 insertions, 20 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index f6b93db4..2467c52f 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -84,6 +84,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
public ProviderAPIResultReceiver providerAPI_result_receiver;
private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -195,6 +196,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
ProviderItem selected_provider = getProvider(id);
int provider_index = getProviderIndex(id);
+
startProgressBar(provider_index+1);
provider_list_fragment.hideAllBut(provider_index);
@@ -245,6 +247,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
return "";
}
+
private void startProgressBar() {
mProgressBar.setVisibility(ProgressBar.VISIBLE);
@@ -269,7 +272,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
ProviderItem provider = providers_iterator.next();
if(provider.name().equalsIgnoreCase(id)) {
break;
+//<<<<<<< HEAD
+// }
+// index++;
+//=======
} else index++;
+//>>>>>>> bug/more-detailed-response-to-CW-errors
}
return index;
}
@@ -421,6 +429,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
private void autoSelectProvider(String provider_main_url, boolean danger_on) {
+
ConfigHelper.saveSharedPref(ProviderItem.DANGER_ON, danger_on);
onItemSelected(getId(provider_main_url));
}
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index 7880880c..d37479a2 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -227,7 +227,6 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
eipStop();
}
- //unregisterReceiver(providerAPI_broadcast_receiver_update);
ConfigHelper.removeFromSharedPref(Provider.KEY);
startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER);
return true;
diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java
index 561f71af..2b7fd39f 100644
--- a/src/se/leap/bitmaskclient/EIP.java
+++ b/src/se/leap/bitmaskclient/EIP.java
@@ -439,7 +439,8 @@ public final class EIP extends IntentService {
String ports = "ports";
String protos = "protocols";
String capabilities = "capabilities";
- String location = "location";
+ String location_key = "location";
+ String locations = "locations";
Vector<String> arg = new Vector<String>();
Vector<Vector<String>> args = new Vector<Vector<String>>();
@@ -456,7 +457,6 @@ public final class EIP extends IntentService {
arg.add(word);
value.add( (Vector<String>) arg.clone() );
options.put(key, (Vector<Vector<String>>) value.clone());
-
value.clear();
arg.clear();
}
@@ -477,16 +477,22 @@ public final class EIP extends IntentService {
arg.clear();
args.clear();
+
try {
- arg.add(location);
- arg.add(mGateway.getString(location));
+
+ arg.add(location_key);
+ String locationText = "";
+ locationText = eipDefinition.getJSONObject(locations).getJSONObject(mGateway.getString(location_key)).getString("name");
+ arg.add(locationText);
+
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
args.add((Vector<String>) arg.clone());
options.put("location", (Vector<Vector<String>>) args.clone() );
+
arg.clear();
args.clear();
JSONArray protocolsJSON = null;
diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java
index e182b3fd..b409394b 100644
--- a/src/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/src/se/leap/bitmaskclient/EipServiceFragment.java
@@ -202,7 +202,10 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli
switchState = false;
} else if (state.equals("NOPROCESS")){
statusMessage = logmessage;
- } else {
+ } else if (state.equals("ASSIGN_IP")){ //don't show assigning message in eipStatus
+ statusMessage = (String) eipStatus.getText();
+ }
+ else {
statusMessage = prefix + " " + logmessage;
}
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 62a51c32..ff6dd852 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;
@@ -69,6 +70,7 @@ import android.os.ResultReceiver;
import android.util.Base64;
import android.util.Log;
+
/**
* Implements HTTP api methods used to manage communications with the provider server.
*
@@ -358,6 +360,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;
}
@@ -429,12 +434,35 @@ public class ProviderAPI extends IntentService {
return result.toString();
}
+
+
+
+
/**
* Downloads a provider.json from a given URL, adding a new provider using the given name.
* @param task containing a boolean meaning if the provider is custom or not, another boolean meaning if the user completely trusts this provider, the provider name and its provider.json url.
* @return a bundle with a boolean value mapped to a key named RESULT_KEY, and which is true if the update was successful.
*/
private Bundle setUpProvider(Bundle task) {
+//<<<<<<< HEAD
+// Bundle result = new Bundle();
+// int progress = 0;
+// boolean danger_on = task.getBoolean(ProviderItem.DANGER_ON);
+// String provider_main_url = task.getString(Provider.MAIN_URL);
+// if(downloadCACert(provider_main_url, danger_on)) {
+// broadcast_progress(progress++);
+// result.putBoolean(RESULT_KEY, true);
+// if(getAndSetProviderJson(provider_main_url)) {
+// broadcast_progress(progress++);
+// if(getAndSetEipServiceJson())
+// broadcast_progress(progress++);
+// }
+// }
+// return result;
+// }
+//
+//
+//=======
int progress = 0;
Bundle current_download = new Bundle();
@@ -480,6 +508,7 @@ public class ProviderAPI extends IntentService {
return result;
}
+
public static boolean caCertDownloaded() {
return CA_CERT_DOWNLOADED;
}
@@ -522,6 +551,7 @@ public class ProviderAPI extends IntentService {
return result;
}
+
public static boolean providerJsonDownloaded() {
return PROVIDER_JSON_DOWNLOADED;
@@ -589,6 +619,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);
@@ -624,6 +656,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
@@ -743,6 +777,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
@@ -783,11 +818,13 @@ 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);
+
+ 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 53b6cb6d..45047982 100644
--- a/src/se/leap/bitmaskclient/ProviderListFragment.java
+++ b/src/se/leap/bitmaskclient/ProviderListFragment.java
@@ -155,7 +155,7 @@ 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());
-
+
for(int item_position = 0; item_position < listView.getCount(); item_position++) {
if(item_position != position)
content_adapter.hide(item_position);
@@ -196,23 +196,27 @@ public class ProviderListFragment extends ListFragment {
mActivatedPosition = position;
}
- public void addItem(ProviderItem provider) {
- content_adapter.add(provider);
- content_adapter.notifyDataSetChanged();
- }
-
public void removeLastItem() {
unhideAll();
content_adapter.remove(content_adapter.getItem(content_adapter.getCount()-1));
content_adapter.notifyDataSetChanged();
}
+ public void addItem(ProviderItem provider) {
+ content_adapter.add(provider);
+ content_adapter.notifyDataSetChanged();
+ }
+
public void hideAllBut(int position) {
- for(int i = 0; i < content_adapter.getCount(); i++)
- if(i != position)
+ int real_count = content_adapter.getCount();
+ for(int i = 0; i < real_count;)
+ if(i != position) {
content_adapter.hide(i);
- else
- content_adapter.unHide(i);
+ position--;
+ real_count--;
+ } else {
+ i++;
+ }
}
public void unhideAll() {
diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java
index 69dd56f4..b5c9c798 100644
--- a/src/se/leap/openvpn/OpenVpnService.java
+++ b/src/se/leap/openvpn/OpenVpnService.java
@@ -114,7 +114,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
android.app.Notification.Builder nbuilder = new Notification.Builder(this);
- nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
+ nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mLocation));
nbuilder.setContentText(msg);
nbuilder.setOnlyAlertOnce(true);
nbuilder.setOngoing(persistant);
@@ -482,6 +482,8 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
if (("NOPROCESS".equals(state) ) || ("EXITING").equals(state)){
showNotification(state, getString(R.string.eip_state_not_connected), ticker, false, 0, persist);
}
+ else if (state.equals("GET_CONFIG") || state.equals("ASSIGN_IP")){ //don't show them in the notification message
+ }
else{
persist = true;
showNotification(state, getString(resid) +" " + logmessage,ticker,false,0,persist);