summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-07-05 17:18:30 +0200
committercyBerta <cyberta@riseup.net>2019-07-12 16:59:26 +0200
commitf5b8dae753448ed698486af8b49b977a58d4fcdc (patch)
tree06358a7d4e70903b6ce235f16c7e22a4800b8f99 /app/src/main/java/de/blinkt/openvpn/VpnProfile.java
parent962e6261e4024cd8191cf2b0c64fc8a34ea3b425 (diff)
better support for android 8.X always-on killswitch (#8945 & #8928)
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn/VpnProfile.java')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/VpnProfile.java52
1 files changed, 42 insertions, 10 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
index bd28ae16..7028bf62 100644
--- a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -5,9 +5,6 @@
package de.blinkt.openvpn;
-import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.BuildConfig;
-
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
@@ -15,7 +12,6 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
-import android.os.RemoteException;
import android.preference.PreferenceManager;
import android.security.KeyChain;
import android.security.KeyChainException;
@@ -24,7 +20,8 @@ import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Base64;
-import de.blinkt.openvpn.core.*;
+import com.google.gson.Gson;
+
import org.spongycastle.util.io.pem.PemObject;
import org.spongycastle.util.io.pem.PemWriter;
@@ -37,7 +34,11 @@ import java.io.Serializable;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.security.*;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.security.SignatureException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
@@ -52,6 +53,21 @@ import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
+import de.blinkt.openvpn.core.Connection;
+import de.blinkt.openvpn.core.ExtAuthHelper;
+import de.blinkt.openvpn.core.NativeUtils;
+import de.blinkt.openvpn.core.OpenVPNService;
+import de.blinkt.openvpn.core.OrbotHelper;
+import de.blinkt.openvpn.core.PasswordCache;
+import de.blinkt.openvpn.core.Preferences;
+import de.blinkt.openvpn.core.VPNLaunchHelper;
+import de.blinkt.openvpn.core.VpnStatus;
+import de.blinkt.openvpn.core.X509Utils;
+import se.leap.bitmaskclient.BuildConfig;
+import se.leap.bitmaskclient.R;
+
+import static se.leap.bitmaskclient.Constants.PROVIDER_PROFILE;
+
public class VpnProfile implements Serializable, Cloneable {
// Note that this class cannot be moved to core where it belongs since
// the profile loading depends on it being here
@@ -755,11 +771,8 @@ public class VpnProfile implements Serializable, Cloneable {
}
public Intent getStartServiceIntent(Context context) {
- String prefix = context.getPackageName();
-
Intent intent = new Intent(context, OpenVPNService.class);
- intent.putExtra(prefix + ".profileUUID", mUuid.toString());
- intent.putExtra(prefix + ".profileVersion", mVersion);
+ intent.putExtra(PROVIDER_PROFILE, this);
return intent;
}
@@ -1113,6 +1126,25 @@ public class VpnProfile implements Serializable, Cloneable {
return mName;
}
+ public String toJson() {
+ Gson gson = new Gson();
+ try {
+ return gson.toJson(this);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static VpnProfile fromJson(String json) {
+ try {
+ Gson gson = new Gson();
+ return gson.fromJson(json, VpnProfile.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
public String getUUIDString() {
return mUuid.toString().toLowerCase(Locale.ENGLISH);
}