MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3 / Client

Method Client

javacli/Client.java:43–69  ·  view source on GitHub ↗
(String config_text, String username, String password)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

eval_configMethod · 0.80
provide_credsMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected