diff options
author | ipertov04 <64426646+ipertov04@users.noreply.github.com> | 2020-04-27 19:22:56 +0300 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2020-04-28 12:53:19 +0200 |
commit | f1261b67d1af55f32cab123052d089da21515c3f (patch) | |
tree | 4825d437ba3f43ad33374e988c97e1115fc30dc3 /main | |
parent | 8007c80750f53d11a5d0c5f098c2e713b6ee5159 (diff) |
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
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java | 15 |
1 files changed, 15 insertions, 0 deletions
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)); |