summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2017-12-07 12:52:29 +0100
committerFup Duck <fupduck@sacknagel.com>2017-12-07 12:52:29 +0100
commitf8c2f76971f5a7f26d18e5e669d5e0ce9c560f3f (patch)
treeedd56030c03b259e147eba3af8987461874aedca /app/src/main
parentda7293252f197e9b54c1abd8127b4abe45b95110 (diff)
Rename constants
* renamed last constants * remove unnecessary updates/ConstantUnification
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/VpnProfile.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Constants.java14
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Dashboard.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/StartActivity.java14
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/VpnFragment.java6
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java18
13 files changed, 34 insertions, 58 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
index aa25da48..cc8d987c 100644
--- a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -1017,7 +1017,7 @@ public class VpnProfile implements Serializable, Cloneable {
if (data.contains("Proc-Type: 4,ENCRYPTED"))
return true;
- else if (data.contains("-----BEGIN ENCRYPTED PRIVATE KEY-----"))
+ else if (data.contains("-----BEGIN ENCRYPTED PRIVATE PROVIDER_KEY-----"))
return true;
else
return false;
diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
index 2ff8a088..21520dc4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java
@@ -219,7 +219,7 @@ public abstract class BaseConfigurationWizard extends Activity
e.printStackTrace();
}
- if (preferences.getBoolean(Constants.ALLOWED_ANON, false)) {
+ if (preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false)) {
mConfigState.putExtra(SERVICES_RETRIEVED, true);
downloadVpnCertificate();
@@ -296,7 +296,7 @@ public abstract class BaseConfigurationWizard extends Activity
public void cancelSettingUpProvider() {
mConfigState.setAction(PROVIDER_NOT_SET);
adapter.showAllProviders();
- preferences.edit().remove(Provider.KEY).remove(Constants.ALLOWED_ANON).remove(Constants.KEY).apply();
+ preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply();
}
private void askDashboardToQuitApp() {
diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java
index f330ef68..8723191c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java
@@ -27,14 +27,12 @@ public interface Constants {
//////////////////////////////////////////////
- // ? CONSTANTS
+ // PROVIDER CONSTANTS
/////////////////////////////////////////////
-
- // TODO FIND BETTER NAMES AND DO NOT USE AS PREFERENCES KEY
- String ALLOWED_ANON = "allow_anonymous";
- String ALLOWED_REGISTERED = "allow_registration";
- String VPN_CERTIFICATE = "cert";
- String PRIVATE_KEY = "Constants.PRIVATE_KEY";
- String KEY = "Constants.KEY";
+ String PROVIDER_ALLOW_ANONYMOUS = "allow_anonymous";
+ String PROVIDER_ALLOWED_REGISTERED = "allow_registration";
+ String PROVIDER_VPN_CERTIFICATE = "cert";
+ String PROVIDER_PRIVATE_KEY = "Constants.PROVIDER_PRIVATE_KEY";
+ String PROVIDER_KEY = "Constants.PROVIDER_KEY";
String PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED";
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
index df558e08..1f0477c9 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java
@@ -159,7 +159,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
switch (versionCode) {
case 91: // 0.6.0 without Bug #5999
case 101: // 0.8.0
- if (!preferences.getString(Constants.KEY, "").isEmpty())
+ if (!preferences.getString(Constants.PROVIDER_KEY, "").isEmpty())
eip_fragment.updateEipService();
break;
}
@@ -315,7 +315,7 @@ public class Dashboard extends Activity implements ProviderAPIResultReceiver.Rec
public void downloadVpnCertificate() {
boolean is_authenticated = User.loggedIn();
- boolean allowed_anon = preferences.getBoolean(Constants.ALLOWED_ANON, false);
+ boolean allowed_anon = preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false);
if (allowed_anon || is_authenticated)
ProviderAPICommand.execute(Bundle.EMPTY, ProviderAPI.DOWNLOAD_CERTIFICATE, providerAPI_result_receiver);
else
diff --git a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
new file mode 100644
index 00000000..b2a39c1a
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java
@@ -0,0 +1,5 @@
+package se.leap.bitmaskclient;
+
+public interface FeatureVersionCode {
+ int MULTIPLE_PROFILES = 132;
+}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
index b9063f18..38981289 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java
@@ -807,7 +807,7 @@ public abstract class ProviderApiBase extends IntentService {
String certificateString = null, keyString = null;
String[] certAndKey = cert_string.split("(?<=-\n)");
for (int i = 0; i < certAndKey.length - 1; i++) {
- if (certAndKey[i].contains("KEY")) {
+ if (certAndKey[i].contains("PROVIDER_KEY")) {
keyString = certAndKey[i++] + certAndKey[i];
} else if (certAndKey[i].contains("CERTIFICATE")) {
certificateString = certAndKey[i++] + certAndKey[i];
@@ -816,11 +816,11 @@ public abstract class ProviderApiBase extends IntentService {
RSAPrivateKey key = ConfigHelper.parseRsaKeyFromString(keyString);
keyString = Base64.encodeToString(key.getEncoded(), Base64.DEFAULT);
- preferences.edit().putString(Constants.PRIVATE_KEY, "-----BEGIN RSA PRIVATE KEY-----\n" + keyString + "-----END RSA PRIVATE KEY-----").commit();
+ preferences.edit().putString(Constants.PROVIDER_PRIVATE_KEY, "-----BEGIN RSA PRIVATE PROVIDER_KEY-----\n" + keyString + "-----END RSA PRIVATE PROVIDER_KEY-----").commit();
X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(certificateString);
certificateString = Base64.encodeToString(certificate.getEncoded(), Base64.DEFAULT);
- preferences.edit().putString(Constants.VPN_CERTIFICATE, "-----BEGIN CERTIFICATE-----\n" + certificateString + "-----END CERTIFICATE-----").commit();
+ preferences.edit().putString(Constants.PROVIDER_VPN_CERTIFICATE, "-----BEGIN CERTIFICATE-----\n" + certificateString + "-----END CERTIFICATE-----").commit();
return true;
} catch (CertificateException e) {
// TODO Auto-generated catch block
diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
index ade43701..dd2be212 100644
--- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java
@@ -13,7 +13,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import de.blinkt.openvpn.core.VpnStatus;
-import se.leap.bitmaskclient.updates.ConstantUnification;
import se.leap.bitmaskclient.userstatus.User;
/**
@@ -113,15 +112,12 @@ public class StartActivity extends Activity {
}
/**
- * execute necessary updates for version change
+ * execute necessary upgrades for version change
*/
private void executeUpgrade() {
- if (passedMilestone(VersionMilestone.MULTIPLE_PROFILES)) {
+ if (hasNewFeature(FeatureVersionCode.MULTIPLE_PROFILES)) {
// TODO prepare usage of multiple profiles
}
- if (passedMilestone(VersionMilestone.CONSTANT_UNIFICATION)) {
- ConstantUnification.upgrade(preferences);
- }
// ensure all upgrades have passed before storing new information
preferences.edit().putInt(Constants.PREFERENCES_APP_VERSION, versionCode).apply();
@@ -129,11 +125,11 @@ public class StartActivity extends Activity {
/**
* check if an upgrade passed or moved to given milestone
- * @param milestone Version code of the Milestone VersionMilestone.MILE_STONE
+ * @param featureVersionCode Version code of the Milestone FeatureVersionCode.MILE_STONE
* @return true if milestone is reached - false otherwise
*/
- private boolean passedMilestone(int milestone) {
- return previousVersionCode < milestone && versionCode >= milestone;
+ private boolean hasNewFeature(int featureVersionCode) {
+ return previousVersionCode < featureVersionCode && versionCode >= featureVersionCode;
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java b/app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java
deleted file mode 100644
index eac57d72..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/VersionMilestone.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package se.leap.bitmaskclient;
-
-public interface VersionMilestone {
- int MULTIPLE_PROFILES = 132;
- int CONSTANT_UNIFICATION = 132;
-}
diff --git a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
index 7b01714f..f787a955 100644
--- a/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/VpnFragment.java
@@ -163,13 +163,13 @@ public class VpnFragment extends Fragment implements Observer {
}
private boolean canStartEIP() {
- boolean certificateExists = !Dashboard.preferences.getString(Constants.VPN_CERTIFICATE, "").isEmpty();
- boolean isAllowedAnon = Dashboard.preferences.getBoolean(Constants.ALLOWED_ANON, false);
+ boolean certificateExists = !Dashboard.preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, "").isEmpty();
+ boolean isAllowedAnon = Dashboard.preferences.getBoolean(Constants.PROVIDER_ALLOW_ANONYMOUS, false);
return (isAllowedAnon || certificateExists) && !eip_status.isConnected() && !eip_status.isConnecting();
}
private boolean canLogInToStartEIP() {
- boolean isAllowedRegistered = Dashboard.preferences.getBoolean(Constants.ALLOWED_REGISTERED, false);
+ boolean isAllowedRegistered = Dashboard.preferences.getBoolean(Constants.PROVIDER_ALLOWED_REGISTERED, false);
boolean isLoggedIn = !LeapSRPSession.getToken().isEmpty();
return isAllowedRegistered && !isLoggedIn && !eip_status.isConnecting() && !eip_status.isConnected();
}
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 929a0c70..0b35dc3d 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -154,7 +154,7 @@ public final class EIP extends IntentService {
private JSONObject eipDefinitionFromPreferences() {
JSONObject result = new JSONObject();
try {
- String eip_definition_string = preferences.getString(Constants.KEY, "");
+ String eip_definition_string = preferences.getString(Constants.PROVIDER_KEY, "");
if (!eip_definition_string.isEmpty()) {
result = new JSONObject(eip_definition_string);
}
@@ -184,7 +184,7 @@ public final class EIP extends IntentService {
}
private void checkCertValidity() {
- VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(Constants.VPN_CERTIFICATE, ""));
+ VpnCertificateValidator validator = new VpnCertificateValidator(preferences.getString(Constants.PROVIDER_VPN_CERTIFICATE, ""));
int resultCode = validator.isValid() ?
Activity.RESULT_OK :
Activity.RESULT_CANCELED;
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/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>";
diff --git a/app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java b/app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java
deleted file mode 100644
index ba78fa00..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/updates/ConstantUnification.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package se.leap.bitmaskclient.updates;
-
-import android.content.SharedPreferences;
-
-public class ConstantUnification {
-
- private String OLD_ALLOWED_ANON = "allow_anonymous";
- private String OLD_ALLOWED_REGISTERED = "allow_registration";
- private String OLD_VPN_CERTIFICATE = "cert";
- private String OLD_PRIVATE_KEY = "Constants.PRIVATE_KEY";
- private String OLD_KEY = "Constants.KEY";
- private String OLD_PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED";
-
- public static void upgrade(SharedPreferences preferences) {
- // TODO MOVE SAVED DATA
- }
-
-}