summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Constants.java44
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java34
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java4
6 files changed, 27 insertions, 68 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java b/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
deleted file mode 100644
index db1cb4a1..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Constants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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 <http://www.gnu.org/licenses/>.
- */
-package se.leap.bitmaskclient.eip;
-
-/**
- * Constants for intent passing, shared preferences
- *
- * @author Parménides GV <parmegv@sdf.org>
- */
-public interface Constants {
-
- public final static String TAG = Constants.class.getSimpleName();
-
- 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";
- public final static String ACTION_UPDATE_EIP_SERVICE = TAG + ".UPDATE_EIP_SERVICE";
- public final static String ACTION_IS_EIP_RUNNING = TAG + ".IS_RUNNING";
- public final static String EIP_NOTIFICATION = TAG + ".EIP_NOTIFICATION";
- public final static String ALLOWED_ANON = "allow_anonymous";
- public final static String ALLOWED_REGISTERED = "allow_registration";
- public final static String VPN_CERTIFICATE = "cert";
- public final static String PRIVATE_KEY = TAG + ".PRIVATE_KEY";
- public final static String KEY = TAG + ".KEY";
- public final static String RECEIVER_TAG = TAG + ".RECEIVER_TAG";
- public final static String REQUEST_TAG = TAG + ".REQUEST_TAG";
- public final static String START_BLOCKING_VPN_PROFILE = TAG + ".START_BLOCKING_VPN_PROFILE";
- public final static String PROVIDER_CONFIGURED = TAG + ".PROVIDER_CONFIGURED";
-
-}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
index 28a9bb50..0b35dc3d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -25,8 +25,6 @@ import org.json.*;
import de.blinkt.openvpn.*;
import se.leap.bitmaskclient.*;
-import static se.leap.bitmaskclient.eip.Constants.*;
-
/**
* EIP is the abstract base class for interacting with and managing the Encrypted
* Internet Proxy connection. Connections are started, stopped, and queried through
@@ -59,7 +57,7 @@ public final class EIP extends IntentService {
super.onCreate();
context = getApplicationContext();
- preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE);
+ preferences = getSharedPreferences(Constants.SHARED_PREFERENCES, MODE_PRIVATE);
eip_definition = eipDefinitionFromPreferences();
if (gateways_manager.isEmpty())
gatewaysFromPreferences();
@@ -68,17 +66,17 @@ public final class EIP extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
String action = intent.getAction();
- mReceiver = intent.getParcelableExtra(RECEIVER_TAG);
+ mReceiver = intent.getParcelableExtra(Constants.EIP_RECEIVER);
- if (action.equals(ACTION_START_EIP))
+ if (action.equals(Constants.EIP_ACTION_START))
startEIP();
- else if (action.equals(ACTION_STOP_EIP))
+ else if (action.equals(Constants.EIP_ACTION_STOP))
stopEIP();
- else if (action.equals(ACTION_IS_EIP_RUNNING))
+ else if (action.equals(Constants.EIP_ACTION_IS_RUNNING))
isRunning();
- else if (action.equals(ACTION_UPDATE_EIP_SERVICE))
+ else if (action.equals(Constants.EIP_ACTION_UPDATE))
updateEIPService();
- else if (action.equals(ACTION_CHECK_CERT_VALIDITY))
+ else if (action.equals(Constants.EIP_ACTION_CHECK_CERT_VALIDITY))
checkCertValidity();
}
@@ -96,9 +94,9 @@ public final class EIP extends IntentService {
if (gateway != null && gateway.getProfile() != null) {
mReceiver = VpnFragment.getReceiver();
launchActiveGateway();
- tellToReceiver(ACTION_START_EIP, Activity.RESULT_OK);
+ tellToReceiver(Constants.EIP_ACTION_START, Activity.RESULT_OK);
} else
- tellToReceiver(ACTION_START_EIP, Activity.RESULT_CANCELED);
+ tellToReceiver(Constants.EIP_ACTION_START, Activity.RESULT_CANCELED);
}
/**
@@ -126,7 +124,7 @@ public final class EIP extends IntentService {
if (eip_status.isConnected() || eip_status.isConnecting())
result_code = Activity.RESULT_OK;
- tellToReceiver(ACTION_STOP_EIP, result_code);
+ tellToReceiver(Constants.EIP_ACTION_STOP, result_code);
}
/**
@@ -139,7 +137,7 @@ public final class EIP extends IntentService {
int resultCode = (eip_status.isConnected()) ?
Activity.RESULT_OK :
Activity.RESULT_CANCELED;
- tellToReceiver(ACTION_IS_EIP_RUNNING, resultCode);
+ tellToReceiver(Constants.EIP_ACTION_IS_RUNNING, resultCode);
}
/**
@@ -150,13 +148,13 @@ public final class EIP extends IntentService {
eip_definition = eipDefinitionFromPreferences();
if (eip_definition.length() > 0)
updateGateways();
- tellToReceiver(ACTION_UPDATE_EIP_SERVICE, Activity.RESULT_OK);
+ tellToReceiver(Constants.EIP_ACTION_UPDATE, Activity.RESULT_OK);
}
private JSONObject eipDefinitionFromPreferences() {
JSONObject result = new JSONObject();
try {
- String eip_definition_string = preferences.getString(KEY, "");
+ String eip_definition_string = preferences.getString(Constants.PROVIDER_KEY, "");
if (!eip_definition_string.isEmpty()) {
result = new JSONObject(eip_definition_string);
}
@@ -186,17 +184,17 @@ public final class EIP extends IntentService {
}
private void checkCertValidity() {
- VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(VPN_CERTIFICATE, ""));
+ VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, ""));
int resultCode = validator.isValid() ?
Activity.RESULT_OK :
Activity.RESULT_CANCELED;
- tellToReceiver(ACTION_CHECK_CERT_VALIDITY, resultCode);
+ tellToReceiver(Constants.EIP_ACTION_CHECK_CERT_VALIDITY, resultCode);
}
private void tellToReceiver(String action, int resultCode) {
if (mReceiver != null) {
Bundle resultData = new Bundle();
- resultData.putString(REQUEST_TAG, action);
+ resultData.putString(Constants.EIP_REQUEST, action);
mReceiver.send(resultCode, resultData);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
index 177f553e..43c16d00 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -36,6 +36,7 @@ import java.util.List;
import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.Connection;
import de.blinkt.openvpn.core.ProfileManager;
+import se.leap.bitmaskclient.Constants;
import se.leap.bitmaskclient.Provider;
/**
@@ -123,8 +124,8 @@ public class GatewaysManager {
JSONObject result = new JSONObject();
try {
result.put(Provider.CA_CERT, preferences.getString(Provider.CA_CERT, ""));
- result.put(Constants.PRIVATE_KEY, preferences.getString(Constants.PRIVATE_KEY, ""));
- result.put(Constants.VPN_CERTIFICATE, preferences.getString(Constants.VPN_CERTIFICATE, ""));
+ result.put(Constants.PROVIDER_PRIVATE_KEY, preferences.getString(Constants.PROVIDER_PRIVATE_KEY, ""));
+ result.put(Constants.PROVIDER_VPN_CERTIFICATE, preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, ""));
} catch (JSONException e) {
e.printStackTrace();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
index 5c9263b3..b1aab79c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnLauncher.java
@@ -5,6 +5,8 @@ import android.content.*;
import android.net.*;
import android.os.*;
+import se.leap.bitmaskclient.Constants;
+
public class VoidVpnLauncher extends Activity {
private static final int VPN_USER_PERMISSION = 71;
@@ -28,7 +30,7 @@ public class VoidVpnLauncher extends Activity {
if (requestCode == VPN_USER_PERMISSION) {
if (resultCode == RESULT_OK) {
Intent void_vpn_service = new Intent(getApplicationContext(), VoidVpnService.class);
- void_vpn_service.setAction(Constants.START_BLOCKING_VPN_PROFILE);
+ void_vpn_service.setAction(Constants.EIP_ACTION_BLOCK_VPN_PROFILE);
startService(void_vpn_service);
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
index cbf0fed2..ff375553 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
@@ -6,6 +6,8 @@ import android.os.*;
import java.io.*;
+import se.leap.bitmaskclient.Constants;
+
public class VoidVpnService extends VpnService {
static final String TAG = VoidVpnService.class.getSimpleName();
@@ -16,7 +18,7 @@ public class VoidVpnService extends VpnService {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String action = intent != null ? intent.getAction() : "";
- if (action == Constants.START_BLOCKING_VPN_PROFILE) {
+ if (action == Constants.EIP_ACTION_BLOCK_VPN_PROFILE) {
thread = new Thread(new Runnable() {
public void run() {
Builder builder = new Builder();
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
index f428099e..54563ec4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java
@@ -118,14 +118,14 @@ public class VpnConfigGenerator {
String key =
"<key>"
+ new_line
- + secrets.getString(Constants.PRIVATE_KEY)
+ + secrets.getString(Constants.PROVIDER_PRIVATE_KEY)
+ new_line
+ "</key>";
String openvpn_cert =
"<cert>"
+ new_line
- + secrets.getString(Constants.VPN_CERTIFICATE)
+ + secrets.getString(Constants.PROVIDER_VPN_CERTIFICATE)
+ new_line
+ "</cert>";