(String config_text, String username, String password)
| 41 | } |
| 42 | |
| 43 | public Client(String config_text, String username, String password) throws ConfigError, CredsUnspecifiedError { |
| 44 | // init client implementation object |
| 45 | client_thread = new OpenVPNClientThread(); |
| 46 | |
| 47 | // load/eval config |
| 48 | ClientAPI_Config config = new ClientAPI_Config(); |
| 49 | config.setContent(config_text); |
| 50 | config.setCompressionMode("yes"); |
| 51 | ClientAPI_EvalConfig ec = client_thread.eval_config(config); |
| 52 | if (ec.getError()) |
| 53 | throw new ConfigError("OpenVPN config file parse error: " + ec.getMessage()); |
| 54 | |
| 55 | // handle creds |
| 56 | ClientAPI_ProvideCreds creds = new ClientAPI_ProvideCreds(); |
| 57 | if (!ec.getAutologin()) |
| 58 | { |
| 59 | if (username.length() > 0) |
| 60 | { |
| 61 | creds.setUsername(username); |
| 62 | creds.setPassword(password); |
| 63 | creds.setReplacePasswordWithSessionID(true); |
| 64 | } |
| 65 | else |
| 66 | throw new CredsUnspecifiedError("OpenVPN config file requires username/password but none provided"); |
| 67 | } |
| 68 | client_thread.provide_creds(creds); |
| 69 | } |
| 70 | |
| 71 | public void connect() { |
| 72 | // connect |
nothing calls this directly
no test coverage detected