From 3267b7f53d0912f04a8d456635a98e89a7ad1906 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 15 Aug 2016 18:36:01 +0200 Subject: [PATCH] Missing credential storage added --- lib/TTLS_UI/include/TTLS_UI.h | 6 ++++-- lib/TTLS_UI/src/Module.cpp | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/TTLS_UI/include/TTLS_UI.h b/lib/TTLS_UI/include/TTLS_UI.h index bf2ddf3..54e58e2 100644 --- a/lib/TTLS_UI/include/TTLS_UI.h +++ b/lib/TTLS_UI/include/TTLS_UI.h @@ -137,11 +137,13 @@ protected: virtual void OnInitDialog(wxInitDialogEvent& event); /// \endcond +public: + wxTLSCredentialsPanel *m_outer_cred; ///< Outer credentials panel + wxPanel *m_inner_cred; ///< Inner credentials panel + protected: const eap::config_provider &m_prov; ///< EAP provider const eap::config_method_ttls &m_cfg; ///< TTLS configuration wxStaticText *m_outer_title; ///< Outer authentication title - wxTLSCredentialsPanel *m_outer_cred; ///< Outer credentials panel wxStaticText *m_inner_title; ///< Inner authentication title - wxPanel *m_inner_cred; ///< Inner credentials panel }; diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index 47bc81d..2f4efbf 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -196,6 +196,29 @@ void eap::peer_ttls_ui::invoke_identity_ui( dlg.AddContents((wxPanel**)&panel, 1); dlg.Centre(wxBOTH); result = dlg.ShowModal(); + if (result == wxID_OK) { + // Write credentials to credential manager. + if (panel->m_outer_cred->GetRememberValue()) { + try { + cred_out.credentials_tls::store(cfg_prov.m_id.c_str()); + } catch (winstd::win_runtime_error &err) { + wxLogError(winstd::tstring_printf(_("Error writing credentials to Credential Manager: %hs (error %u)"), err.what(), err.number()).c_str()); + } catch (...) { + wxLogError(_("Writing credentials failed.")); + } + } + + wxPAPCredentialsPanel *panel_inner_cred_pap = dynamic_cast(panel->m_inner_cred); + if (panel_inner_cred_pap && panel_inner_cred_pap->GetRememberValue()) { + try { + cred_out.m_inner->store(cfg_prov.m_id.c_str()); + } catch (winstd::win_runtime_error &err) { + wxLogError(winstd::tstring_printf(_("Error writing credentials to Credential Manager: %hs (error %u)"), err.what(), err.number()).c_str()); + } catch (...) { + wxLogError(_("Writing credentials failed.")); + } + } + } wxTopLevelWindows.DeleteObject(&parent); parent.SetHWND((WXHWND)NULL);