From bbbefe26e6c160bca867dce3188b3679f0fcf2fc Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 27 Dec 2012 19:47:35 +0100 Subject: Make changes needed to provide an external API --- src/de/blinkt/openvpn/ConfigParser.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/de/blinkt/openvpn/ConfigParser.java') diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java index cdec964e..faf0dbd9 100644 --- a/src/de/blinkt/openvpn/ConfigParser.java +++ b/src/de/blinkt/openvpn/ConfigParser.java @@ -242,7 +242,7 @@ public class ConfigParser { // This method is far too long - VpnProfile convertProfile() throws ConfigParseError{ + public VpnProfile convertProfile() throws ConfigParseError{ boolean noauthtypeset=true; VpnProfile np = new VpnProfile("converted Profile"); // Pull, client, tls-client @@ -461,7 +461,6 @@ public class ConfigParser { Vector authuser = getOption("auth-user-pass",0,1); if(authuser !=null){ - if(noauthtypeset) { np.mAuthenticationType=VpnProfile.TYPE_USERPASS; } else if(np.mAuthenticationType==VpnProfile.TYPE_CERTIFICATES) { @@ -470,7 +469,10 @@ public class ConfigParser { np.mAuthenticationType=VpnProfile.TYPE_USERPASS_KEYSTORE; } if(authuser.size()>1) { - np.mUsername=authuser.get(1); + // Set option value to password get to get canche to embed later. + np.mUsername=null; + np.mPassword=authuser.get(1); + useEmbbedUserAuth(np,authuser.get(1)); } } @@ -483,6 +485,16 @@ public class ConfigParser { return np; } + + static public void useEmbbedUserAuth(VpnProfile np,String inlinedata) + { + String data = inlinedata.replace(VpnProfile.INLINE_TAG, ""); + String[] parts = data.split("\n"); + if(parts.length >= 2) { + np.mUsername=parts[0]; + np.mPassword=parts[1]; + } + } private void checkIgnoreAndInvalidOptions(VpnProfile np) throws ConfigParseError { for(String option:unsupportedOptions) -- cgit v1.2.3