From f1261b67d1af55f32cab123052d089da21515c3f Mon Sep 17 00:00:00 2001 From: ipertov04 <64426646+ipertov04@users.noreply.github.com> Date: Mon, 27 Apr 2020 19:22:56 +0300 Subject: Fix for MDM in case ovpn field is one line Fix for MDM which support appconfig (in case ovpn field is one line base64 encoded string). If config contains only one line without spaces, then: - If not exception is cought, then it is a decoded base64 string - If exception is cought, then assumed it is a normal string --- .../main/java/de/blinkt/openvpn/api/AppRestrictions.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'main') diff --git a/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java b/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java index 69900293..02b54add 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java +++ b/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java @@ -149,7 +149,22 @@ public class AppRestrictions { } + private String prepare(String config) { + String newLine = System.getProperty("line.separator"); + if (!config.contains(newLine)&& !config.contains(" ")) { + try { + byte[] decoded = android.util.Base64.decode(config.getBytes(), android.util.Base64.DEFAULT); + config = new String(decoded); + return config; + } catch(IllegalArgumentException e) { + + } + } + return config; + }; + private void addProfile(Context c, String config, String uuid, String name, VpnProfile vpnProfile) { + config = prepare(config); ConfigParser cp = new ConfigParser(); try { cp.parseConfig(new StringReader(config)); -- cgit v1.2.3