private void ProcessAsyncEventPassword(AsyncEventDetail aeDetail) { string pwType = aeDetail.getInfos()[0]; // "Auth" or "Private Key", or ... string pwInfo = aeDetail.getInfos()[1]; // "password" or "username/password" string pwMsg = aeDetail.getInfos()[2]; // "Need" or "Verification Failed" if (pwMsg.Equals("Need",System.StringComparison.OrdinalIgnoreCase)) { if (pwType.Equals("Auth", System.StringComparison.OrdinalIgnoreCase) && pwInfo.Equals("username/password", System.StringComparison.OrdinalIgnoreCase)) { // Ask for username/password string[] loginInfo = m_ovpn.getLoginPass(pwType); bool sendUserPass = false; if (loginInfo != null) { string username = loginInfo[0]; string password = loginInfo[1]; if (username != null && pwType.Length > 0 && password != null && password.Length > 0) { m_ovpnComm.send("username '" + pwType + "' " + ManagementParser.encodeMsg(username)); //wait for processing by OpenVPN or it might not always process the password correctly. m_ovpnComm.processManagementConnectionLine(); m_ovpnComm.send("password '" + pwType + "' " + ManagementParser.encodeMsg(password)); sendUserPass = true; } } if (!sendUserPass) { // Send 'bogus' user and pass to keep OpenVPN from quiting on disconnect.. (WORKAROUND) m_ovpnComm.send("username '" + pwType + "' -"); m_ovpnComm.send("password '" + pwType + "' -"); } } else { string pw = m_ovpn.getPW(pwType); if (pw != null) { if (pw.Length > 0) { m_ovpnComm.send("password '" + pwType + "' " + ManagementParser.encodeMsg(pw)); } } } } else if (pwMsg.Equals("Verification Failed", System.StringComparison.OrdinalIgnoreCase)) { } else { } }
private void ProcessAsyncEventState(AsyncEventDetail aeDetail) { string[] details = aeDetail.getInfos(); // otherwise, we automatically reconnect m_ovpn.State.ChangeVPNState(details); m_logs.logLine(LogType.State, aeDetail.getInfos()[1]); }
private void ProcessAsyncEventNeedStr(AsyncEventDetail aeDetail) { switch (aeDetail.getInfos()[0]) { // A SmartCard ID is requested case "pkcs11-id-request": setLock(WaitState.PKCS11_GET_COUNT); m_ovpnComm.send("pkcs11-id-count"); break; } }
private void ProcessAsyncEventPassword(AsyncEventDetail aeDetail) { string pwType = aeDetail.getInfos()[0]; // "Auth" or "Private Key", or ... string pwInfo = aeDetail.getInfos()[1]; // "password" or "username/password" string pwMsg = aeDetail.getInfos()[2]; // "Need" or "Verification Failed" if (pwMsg.Equals("Need", System.StringComparison.OrdinalIgnoreCase)) { if (pwType.Equals("Auth", System.StringComparison.OrdinalIgnoreCase) && pwInfo.Equals("username/password", System.StringComparison.OrdinalIgnoreCase)) { // Ask for username/password string[] loginInfo = m_ovpn.getLoginPass(pwType); bool sendUserPass = false; if (loginInfo != null) { string username = loginInfo[0]; string password = loginInfo[1]; if (username != null && pwType.Length > 0 && password != null && password.Length > 0) { m_ovpnComm.send("username '" + pwType + "' " + ManagementParser.encodeMsg(username)); //wait for processing by OpenVPN or it might not always process the password correctly. m_ovpnComm.processManagementConnectionLine(); m_ovpnComm.send("password '" + pwType + "' " + ManagementParser.encodeMsg(password)); sendUserPass = true; } } if (!sendUserPass) { // Send 'bogus' user and pass to keep OpenVPN from quiting on disconnect.. (WORKAROUND) m_ovpnComm.send("username '" + pwType + "' -"); m_ovpnComm.send("password '" + pwType + "' -"); } } else { string pw = m_ovpn.getPW(pwType); if (pw != null) { if (pw.Length > 0) { m_ovpnComm.send("password '" + pwType + "' " + ManagementParser.encodeMsg(pw)); } } } } else if (pwMsg.Equals("Verification Failed", System.StringComparison.OrdinalIgnoreCase)) { m_logs.logDebugLine(1, "Authentication Failed said remote server"); } else { m_logs.logDebugLine(1, "Unknown 'PASSWORD' reply from remote server: " + pwMsg); } }
private void ProcessAsyncEventNeedStr(AsyncEventDetail aeDetail) { switch (aeDetail.getInfos()[0]) { // A SmartCard ID is requested case "pkcs11-id-request": m_logs.logDebugLine(3, "Got Request for pkcs11-id"); setLock(WaitState.PKCS11_GET_COUNT); m_ovpnComm.send("pkcs11-id-count"); break; } }