dePAPization continues to pave the road for seamless MSCHAPv2 integration

This commit is contained in:
Simon Rozman 2016-08-28 20:04:45 +02:00
parent 6c66862eed
commit e66a7eb9ba
14 changed files with 97 additions and 68 deletions

View File

@ -81,6 +81,7 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="..\include\EAP_UI.h" /> <ClInclude Include="..\include\EAP_UI.h" />
<ClInclude Include="..\include\Module.h" /> <ClInclude Include="..\include\Module.h" />
<ClInclude Include="..\include\wxEAP_UIBase.h" />
<ClInclude Include="..\res\wxEAP_UI.h" /> <ClInclude Include="..\res\wxEAP_UI.h" />
<ClInclude Include="..\src\StdAfx.h" /> <ClInclude Include="..\src\StdAfx.h" />
</ItemGroup> </ItemGroup>

View File

@ -27,6 +27,9 @@
<ClInclude Include="..\include\Module.h"> <ClInclude Include="..\include\Module.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\include\wxEAP_UIBase.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\src\StdAfx.cpp"> <ClCompile Include="..\src\StdAfx.cpp">

View File

@ -81,9 +81,9 @@ class wxEAPConfigProvider;
template <class _Tcred, class _wxT> class wxEAPCredentialsConfigPanel; template <class _Tcred, class _wxT> class wxEAPCredentialsConfigPanel;
/// ///
/// Base template for all credential entry panels /// Helper template for all credential entry panels
/// ///
template <class _Tcred, class _Tbase> class wxEAPCredentialsPanelBase; template <class _Tcred, class _Tbase> class wxEAPCredentialsPanel;
/// ///
/// Generic password credential entry panel /// Generic password credential entry panel
@ -637,11 +637,11 @@ private:
template <class _Tcred, class _Tbase> template <class _Tcred, class _Tbase>
class wxEAPCredentialsPanelBase : public _Tbase class wxEAPCredentialsPanel : public _Tbase
{ {
private: private:
/// \cond internal /// \cond internal
typedef wxEAPCredentialsPanelBase<_Tcred, _Tbase> _Tthis; typedef wxEAPCredentialsPanel<_Tcred, _Tbase> _Tthis;
/// \endcond /// \endcond
public: public:
@ -655,7 +655,7 @@ public:
/// \param[in] parent Parent window /// \param[in] parent Parent window
/// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled. /// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled.
/// ///
wxEAPCredentialsPanelBase(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) : wxEAPCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) :
m_prov(prov), m_prov(prov),
m_cfg(cfg), m_cfg(cfg),
m_cred(cred), m_cred(cred),
@ -666,17 +666,17 @@ public:
this->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(_Tthis::OnUpdateUI)); this->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(_Tthis::OnUpdateUI));
} }
virtual ~wxEAPCredentialsPanelBase() virtual ~wxEAPCredentialsPanel()
{ {
this->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(_Tthis::OnUpdateUI)); this->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(_Tthis::OnUpdateUI));
} }
inline void SetRememberValue(bool val) virtual void SetRemember(bool val)
{ {
return m_remember->SetValue(val); return m_remember->SetValue(val);
} }
inline bool GetRememberValue() const virtual bool GetRemember() const
{ {
return m_remember->GetValue(); return m_remember->GetValue();
} }
@ -716,7 +716,7 @@ protected:
template <class _Tcred, class _Tbase> template <class _Tcred, class _Tbase>
class wxPasswordCredentialsPanel : public wxEAPCredentialsPanelBase<_Tcred, _Tbase> class wxPasswordCredentialsPanel : public wxEAPCredentialsPanel<_Tcred, _Tbase>
{ {
public: public:
/// ///
@ -730,7 +730,7 @@ public:
/// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled. /// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled.
/// ///
wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) : wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) :
wxEAPCredentialsPanelBase<_Tcred, _Tbase>(prov, cfg, cred, pszCredTarget, parent, is_config) wxEAPCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, pszCredTarget, parent, is_config)
{ {
// Load and set icon. // Load and set icon.
winstd::library lib_shell32; winstd::library lib_shell32;
@ -767,12 +767,12 @@ protected:
m_identity->SetSelection(0, -1); m_identity->SetSelection(0, -1);
m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password); m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password);
return wxEAPCredentialsPanelBase<_Tcred, wxEAPCredentialsPassPanelBase>::TransferDataToWindow(); return wxEAPCredentialsPanel<_Tcred, wxEAPCredentialsPassPanelBase>::TransferDataToWindow();
} }
virtual bool TransferDataFromWindow() virtual bool TransferDataFromWindow()
{ {
if (!wxEAPCredentialsPanelBase<_Tcred, wxEAPCredentialsPassPanelBase>::TransferDataFromWindow()) if (!wxEAPCredentialsPanel<_Tcred, wxEAPCredentialsPassPanelBase>::TransferDataFromWindow())
return false; return false;
m_cred.m_identity = m_identity->GetValue(); m_cred.m_identity = m_identity->GetValue();
@ -795,7 +795,7 @@ protected:
m_password ->Enable(false); m_password ->Enable(false);
} }
wxEAPCredentialsPanelBase<_Tcred, wxEAPCredentialsPassPanelBase>::OnUpdateUI(event); wxEAPCredentialsPanel<_Tcred, wxEAPCredentialsPassPanelBase>::OnUpdateUI(event);
} }
/// \endcond /// \endcond

View File

@ -0,0 +1,48 @@
/*
Copyright 2015-2016 Amebis
Copyright 2016 GÉANT
This file is part of GÉANTLink.
GÉANTLink is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GÉANTLink is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
*/
///
/// Base class for all credential entry panel that must provide "Remember" credentials checkbox
///
class wxEAPCredentialsPanelBase;
#pragma once
#include <wx/panel.h>
class wxEAPCredentialsPanelBase : public wxPanel
{
public:
///
/// Constructs a wxPanel with "Remember" credentials checkbox
///
wxEAPCredentialsPanelBase(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr) : wxPanel(parent, winid, pos, size, style, name)
{
}
virtual void SetRemember(bool val) = 0;
virtual bool GetRemember() const = 0;
};

View File

@ -290,7 +290,7 @@ wxEAPCredentialsConfigPanelBase::~wxEAPCredentialsConfigPanelBase()
} }
wxEAPCredentialsPassPanelBase::wxEAPCredentialsPassPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) wxEAPCredentialsPassPanelBase::wxEAPCredentialsPassPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxEAPCredentialsPanelBase( parent, id, pos, size, style )
{ {
wxStaticBoxSizer* sb_credentials; wxStaticBoxSizer* sb_credentials;
sb_credentials = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Client Credentials") ), wxVERTICAL ); sb_credentials = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Client Credentials") ), wxVERTICAL );

View File

@ -1931,7 +1931,7 @@
<property name="name">wxEAPCredentialsPassPanelBase</property> <property name="name">wxEAPCredentialsPassPanelBase</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">500,-1</property> <property name="size">500,-1</property>
<property name="subclass"></property> <property name="subclass">wxEAPCredentialsPanelBase; ../include/wxEAP_UIBase.h</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>

View File

@ -11,6 +11,9 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class wxEAPCredentialsPanelBase;
#include "../include/wxEAP_UIBase.h"
class wxEAPBannerPanel; class wxEAPBannerPanel;
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
@ -158,7 +161,7 @@ class wxEAPCredentialsConfigPanelBase : public wxPanel
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class wxEAPCredentialsPassPanelBase /// Class wxEAPCredentialsPassPanelBase
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class wxEAPCredentialsPassPanelBase : public wxPanel class wxEAPCredentialsPassPanelBase : public wxEAPCredentialsPanelBase
{ {
private: private:

View File

@ -248,7 +248,7 @@ protected:
}; };
class wxTLSCredentialsPanel : public wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase> class wxTLSCredentialsPanel : public wxEAPCredentialsPanel<eap::credentials_tls, wxTLSCredentialsPanelBase>
{ {
public: public:
/// ///

View File

@ -312,7 +312,7 @@ bool wxFQDNListValidator::Parse(const wxString &val_in, size_t i_start, size_t i
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
wxTLSCredentialsPanel::wxTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, eap::credentials_tls &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) : wxTLSCredentialsPanel::wxTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, eap::credentials_tls &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase>(prov, cfg, cred, pszCredTarget, parent, is_config) wxEAPCredentialsPanel<eap::credentials_tls, wxTLSCredentialsPanelBase>(prov, cfg, cred, pszCredTarget, parent, is_config)
{ {
// Load and set icon. // Load and set icon.
winstd::library lib_shell32; winstd::library lib_shell32;
@ -361,7 +361,7 @@ bool wxTLSCredentialsPanel::TransferDataToWindow()
m_identity->SetValue(m_cred.m_identity); m_identity->SetValue(m_cred.m_identity);
return wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase>::TransferDataToWindow(); return wxEAPCredentialsPanel<eap::credentials_tls, wxTLSCredentialsPanelBase>::TransferDataToWindow();
} }
@ -381,7 +381,7 @@ bool wxTLSCredentialsPanel::TransferDataFromWindow()
// Inherited TransferDataFromWindow() calls m_cred.store(). // Inherited TransferDataFromWindow() calls m_cred.store().
// Therefore, call it only now, that m_cred is set. // Therefore, call it only now, that m_cred is set.
return wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase>::TransferDataFromWindow(); return wxEAPCredentialsPanel<eap::credentials_tls, wxTLSCredentialsPanelBase>::TransferDataFromWindow();
} }
@ -405,7 +405,7 @@ void wxTLSCredentialsPanel::OnUpdateUI(wxUpdateUIEvent& event)
m_identity->Enable(true); m_identity->Enable(true);
} }
wxEAPCredentialsPanelBase<eap::credentials_tls, wxTLSCredentialsPanelBase>::OnUpdateUI(event); wxEAPCredentialsPanel<eap::credentials_tls, wxTLSCredentialsPanelBase>::OnUpdateUI(event);
} }

View File

@ -159,11 +159,6 @@ namespace eap
/// ///
virtual void retrieve(_In_z_ LPCTSTR pszTargetName); virtual void retrieve(_In_z_ LPCTSTR pszTargetName);
///
/// Return target suffix for Windows Credential Manager credential name
///
virtual LPCTSTR target_suffix() const;
/// ///
/// Returns credential identity. /// Returns credential identity.
/// ///

View File

@ -169,13 +169,6 @@ void eap::credentials_ttls::retrieve(_In_z_ LPCTSTR pszTargetName)
} }
LPCTSTR eap::credentials_ttls::target_suffix() const
{
assert(0); // Not that we would ever store inner&outer credentials to Windows Credential Manager joined, but for completness sake... Here we go:
return _T("TTLS");
}
wstring eap::credentials_ttls::get_identity() const wstring eap::credentials_ttls::get_identity() const
{ {
// Outer identity has the right-of-way. // Outer identity has the right-of-way.
@ -193,21 +186,17 @@ eap::credentials::source_t eap::credentials_ttls::combine(
_In_ const config_method_with_cred &cfg, _In_ const config_method_with_cred &cfg,
_In_opt_z_ LPCTSTR pszTargetName) _In_opt_z_ LPCTSTR pszTargetName)
{ {
source_t src; // Combine outer credentials.
source_t src_outer = credentials_tls::combine(
// Combine outer credentials first.
src = credentials_tls::combine(
cred_cached, cred_cached,
cfg, cfg,
pszTargetName); pszTargetName);
if (src == source_unknown) {
// Outer credentials are unknown. Enough unknowness.
return source_unknown;
}
// Combine inner credentials. // Combine inner credentials.
return m_inner->combine( source_t src_inner = m_inner->combine(
cred_cached ? ((const credentials_ttls*)cred_cached)->m_inner.get() : NULL, cred_cached ? ((const credentials_ttls*)cred_cached)->m_inner.get() : NULL,
*((const config_method_ttls&)cfg).m_inner, *((const config_method_ttls&)cfg).m_inner,
pszTargetName); pszTargetName);
return std::min<source_t>(src_outer, src_inner);
} }

View File

@ -133,7 +133,7 @@ protected:
public: public:
wxTLSCredentialsPanel *m_outer_cred; ///< Outer credentials panel wxTLSCredentialsPanel *m_outer_cred; ///< Outer credentials panel
wxPanel *m_inner_cred; ///< Inner credentials panel wxEAPCredentialsPanelBase *m_inner_cred; ///< Inner credentials panel
protected: protected:
const eap::config_provider &m_prov; ///< EAP provider const eap::config_provider &m_prov; ///< EAP provider

View File

@ -104,22 +104,23 @@ void eap::peer_ttls_ui::invoke_config_ui(
} else { } else {
// This is a blank network profile. Create default configuraton. // This is a blank network profile. Create default configuraton.
// Start with PAP inner configuration. // Inner configuration: PAP
config_method_pap *cfg_method_inner = new config_method_pap(*this); config_method_pap *cfg_method_inner = new config_method_pap(*this);
cfg_method_inner->m_use_preshared = false; cfg_method_inner->m_use_preshared = false;
cfg_method_inner->m_preshared(new credentials_pap(*this)); cfg_method_inner->m_preshared(new credentials_pap(*this));
// Outer configuration
unique_ptr<config_method_ttls> cfg_method(new config_method_ttls(*this)); unique_ptr<config_method_ttls> cfg_method(new config_method_ttls(*this));
cfg_method->m_anonymous_identity = L"@"; cfg_method->m_anonymous_identity = L"@";
cfg_method->m_use_preshared = true; cfg_method->m_use_preshared = true;
cfg_method->m_preshared.reset(new credentials_tls(*this)); cfg_method->m_preshared.reset(new credentials_tls(*this));
cfg_method->m_inner.reset(cfg_method_inner); cfg_method->m_inner.reset(cfg_method_inner);
// Start with one method. // One method
config_provider cfg_provider(*this); config_provider cfg_provider(*this);
cfg_provider.m_methods.push_back(std::move(cfg_method)); cfg_provider.m_methods.push_back(std::move(cfg_method));
// Start with one provider. // One provider
cfg.m_providers.push_back(std::move(cfg_provider)); cfg.m_providers.push_back(std::move(cfg_provider));
} }
@ -189,16 +190,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
#endif #endif
credentials_ttls cred_out(*this); credentials_ttls cred_out(*this);
cred_out.m_inner.reset(cfg_method->m_inner->make_credentials());
// Determine inner credential type.
eap_type_t type_inner;
if (dynamic_cast<const config_method_pap*>(cfg_method->m_inner.get())) {
cred_out.m_inner.reset(new credentials_pap(*this));
type_inner = eap_type_pap;
} else {
assert(0); // Unsupported inner authentication method type.
type_inner = eap_type_undefined;
}
// Combine credentials. Outer and inner separately to get the idea which one is missing. // Combine credentials. Outer and inner separately to get the idea which one is missing.
eap::credentials::source_t cred_source = cred_out.credentials_tls::combine( eap::credentials::source_t cred_source = cred_out.credentials_tls::combine(
@ -242,17 +234,15 @@ void eap::peer_ttls_ui::invoke_identity_ui(
dlg.AddContent(panel); dlg.AddContent(panel);
// Set "Remember" checkboxes according to credential source, // Set "Remember" checkboxes according to credential source,
panel->m_outer_cred->SetRememberValue(cred_source == eap::credentials::source_storage); panel->m_outer_cred->SetRemember(cred_source == eap::credentials::source_storage);
wxPAPCredentialsPanel *panel_inner_cred_pap = dynamic_cast<wxPAPCredentialsPanel*>(panel->m_inner_cred); panel->m_inner_cred->SetRemember(cred_source_inner == eap::credentials::source_storage);
if (panel_inner_cred_pap)
panel_inner_cred_pap->SetRememberValue(cred_source_inner == eap::credentials::source_storage);
// Centre and display dialog. // Centre and display dialog.
dlg.Centre(wxBOTH); dlg.Centre(wxBOTH);
result = dlg.ShowModal(); result = dlg.ShowModal();
if (result == wxID_OK) { if (result == wxID_OK) {
// Write credentials to credential manager. // Write credentials to credential manager.
if (panel->m_outer_cred->GetRememberValue()) { if (panel->m_outer_cred->GetRemember()) {
try { try {
cred_out.credentials_tls::store(cfg_prov.m_id.c_str()); cred_out.credentials_tls::store(cfg_prov.m_id.c_str());
} catch (winstd::win_runtime_error &err) { } catch (winstd::win_runtime_error &err) {
@ -262,7 +252,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
} }
} }
if (panel_inner_cred_pap && panel_inner_cred_pap->GetRememberValue()) { if (panel->m_inner_cred->GetRemember()) {
try { try {
cred_out.m_inner->store(cfg_prov.m_id.c_str()); cred_out.m_inner->store(cfg_prov.m_id.c_str());
} catch (winstd::win_runtime_error &err) { } catch (winstd::win_runtime_error &err) {