From e8d231d36067f004c791ecfff6b119094d9e30dd Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 31 Jan 2017 10:40:11 +0100 Subject: [PATCH] EAP-GTC implementation continues... --- lib/GTC/include/Config.h | 4 +- lib/GTC/include/Method.h | 14 +- lib/GTC/src/Config.cpp | 13 +- lib/GTC/src/Method.cpp | 9 +- lib/GTC_UI/build/GTC_UI.vcxproj | 5 - lib/GTC_UI/build/GTC_UI.vcxproj.filters | 11 - lib/GTC_UI/include/GTC_UI.h | 40 ++-- lib/GTC_UI/res/wxGTC_UI.cpp | 51 ----- lib/GTC_UI/res/wxGTC_UI.fbp | 278 ------------------------ lib/GTC_UI/res/wxGTC_UI.h | 52 ----- lib/GTC_UI/src/GTC_UI.cpp | 25 +-- lib/TTLS/src/Module.cpp | 2 +- 12 files changed, 43 insertions(+), 461 deletions(-) delete mode 100644 lib/GTC_UI/res/wxGTC_UI.cpp delete mode 100644 lib/GTC_UI/res/wxGTC_UI.fbp delete mode 100644 lib/GTC_UI/res/wxGTC_UI.h diff --git a/lib/GTC/include/Config.h b/lib/GTC/include/Config.h index 8e72da9..faf834b 100644 --- a/lib/GTC/include/Config.h +++ b/lib/GTC/include/Config.h @@ -42,7 +42,7 @@ namespace eap /// /// EAP-GTC configuration /// - class config_method_eapgtc : public config_method + class config_method_eapgtc : public config_method_with_cred { public: /// @@ -101,7 +101,7 @@ namespace eap /// /// @copydoc eap::config_method::make_credentials() - /// \returns This implementation always returns `NULL` + /// \returns This implementation always returns `eap::credentials` type of credentials /// virtual credentials* make_credentials() const; }; diff --git a/lib/GTC/include/Method.h b/lib/GTC/include/Method.h index c0170ba..c665634 100644 --- a/lib/GTC/include/Method.h +++ b/lib/GTC/include/Method.h @@ -29,8 +29,6 @@ namespace eap #include "../../EAPBase/include/Method.h" -#include - namespace eap { @@ -50,8 +48,9 @@ namespace eap /// /// \param[in] mod GTC module to use for global services /// \param[in] cfg Method configuration + /// \param[in] cred User credentials /// - method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg); + method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg, _In_ credentials &cred); /// /// Moves a GTC method @@ -93,6 +92,10 @@ namespace eap /// @} + virtual void get_result( + _In_ EapPeerMethodResultReason reason, + _Out_ EapPeerMethodResult *pResult); + /// \name User Interaction /// @{ @@ -106,12 +109,9 @@ namespace eap /// @} - virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); - protected: config_method_eapgtc &m_cfg; ///< Method configuration + credentials &m_cred; ///< Method user credentials winstd::sanitizing_wstring m_message; ///< Authenticator message winstd::sanitizing_wstring m_reply; ///< GTC reply }; diff --git a/lib/GTC/src/Config.cpp b/lib/GTC/src/Config.cpp index 1c8cf39..dff87c3 100644 --- a/lib/GTC/src/Config.cpp +++ b/lib/GTC/src/Config.cpp @@ -28,19 +28,20 @@ using namespace winstd; // eap::config_method_eapgtc ////////////////////////////////////////////////////////////////////// -eap::config_method_eapgtc::config_method_eapgtc(_In_ module &mod, _In_ unsigned int level) : config_method(mod, level) +eap::config_method_eapgtc::config_method_eapgtc(_In_ module &mod, _In_ unsigned int level) : config_method_with_cred(mod, level) { + m_cred.reset(new credentials(mod)); } eap::config_method_eapgtc::config_method_eapgtc(_In_ const config_method_eapgtc &other) : - config_method(other) + config_method_with_cred(other) { } eap::config_method_eapgtc::config_method_eapgtc(_Inout_ config_method_eapgtc &&other) : - config_method(std::move(other)) + config_method_with_cred(std::move(other)) { } @@ -48,7 +49,7 @@ eap::config_method_eapgtc::config_method_eapgtc(_Inout_ config_method_eapgtc &&o eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_In_ const config_method_eapgtc &other) { if (this != &other) - (config_method&)*this = other; + (config_method_with_cred&)*this = other; return *this; } @@ -57,7 +58,7 @@ eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_In_ const confi eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_Inout_ config_method_eapgtc &&other) { if (this != &other) - (config_method&&)*this = std::move(other); + (config_method_with_cred&&)*this = std::move(other); return *this; } @@ -83,5 +84,5 @@ const wchar_t* eap::config_method_eapgtc::get_method_str() const eap::credentials* eap::config_method_eapgtc::make_credentials() const { - return NULL; + return new eap::credentials(m_module); } diff --git a/lib/GTC/src/Method.cpp b/lib/GTC/src/Method.cpp index b1acdc9..598acd2 100644 --- a/lib/GTC/src/Method.cpp +++ b/lib/GTC/src/Method.cpp @@ -28,15 +28,17 @@ using namespace winstd; // eap::method_gtc ////////////////////////////////////////////////////////////////////// -eap::method_gtc::method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg) : +eap::method_gtc::method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg, _In_ credentials &cred) : m_cfg(cfg), + m_cred(cred), method(mod) { } eap::method_gtc::method_gtc(_Inout_ method_gtc &&other) : - m_cfg ( other.m_cfg ), + m_cfg ( other.m_cfg ), + m_cred ( other.m_cred ), m_message(std::move(other.m_message)), m_reply (std::move(other.m_reply )), method (std::move(other )) @@ -47,7 +49,8 @@ eap::method_gtc::method_gtc(_Inout_ method_gtc &&other) : eap::method_gtc& eap::method_gtc::operator=(_Inout_ method_gtc &&other) { if (this != std::addressof(other)) { - assert(std::addressof(m_cfg) == std::addressof(other.m_cfg)); // Move method within same configuration only! + assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! + assert(std::addressof(m_cred) == std::addressof(other.m_cred)); // Move method within same credentials only! (method&)*this = std::move(other ); m_message = std::move(other.m_message); m_reply = std::move(other.m_reply ); diff --git a/lib/GTC_UI/build/GTC_UI.vcxproj b/lib/GTC_UI/build/GTC_UI.vcxproj index 48f72ca..dc8046c 100644 --- a/lib/GTC_UI/build/GTC_UI.vcxproj +++ b/lib/GTC_UI/build/GTC_UI.vcxproj @@ -80,11 +80,9 @@ - - Create @@ -98,9 +96,6 @@ {d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b} - - - diff --git a/lib/GTC_UI/build/GTC_UI.vcxproj.filters b/lib/GTC_UI/build/GTC_UI.vcxproj.filters index 6bdbb43..be2a6dc 100644 --- a/lib/GTC_UI/build/GTC_UI.vcxproj.filters +++ b/lib/GTC_UI/build/GTC_UI.vcxproj.filters @@ -21,9 +21,6 @@ Header Files - - Header Files - @@ -32,13 +29,5 @@ Source Files - - Source Files - - - - - Resource Files - \ No newline at end of file diff --git a/lib/GTC_UI/include/GTC_UI.h b/lib/GTC_UI/include/GTC_UI.h index ee32e3a..b869152 100644 --- a/lib/GTC_UI/include/GTC_UI.h +++ b/lib/GTC_UI/include/GTC_UI.h @@ -21,12 +21,24 @@ #include "../../EAPBase_UI/include/EAP_UI.h" #include "../../GTC/include/Config.h" -class wxGTCMethodConfigPanel; class wxGTCConfigPanel; -#pragma once +/// \addtogroup EAPBaseGUI +/// @{ -#include "../res/wxGTC_UI.h" +/// +/// GTC credential configuration panel +/// +typedef wxEAPCredentialsConfigPanel > wxGTCCredentialsConfigPanel; + +/// +/// GTC credential entry panel +/// +typedef wxIdentityCredentialsPanel wxGTCCredentialsPanel; + +/// @} + +#pragma once #include #include @@ -37,26 +49,6 @@ class wxGTCConfigPanel; /// \addtogroup EAPBaseGUI /// @{ -/// -/// Inner EAP method config panel -/// -class wxGTCMethodConfigPanel : public wxGTCMethodConfigPanelBase -{ -public: - /// - /// Constructs an inner EAP method config panel - /// - /// \param[in ] prov Provider configuration data - /// \param[inout] cfg Method configuration data - /// \param[in ] parent Parent window - /// - wxGTCMethodConfigPanel(const eap::config_provider &prov, eap::config_method_eapgtc &cfg, wxWindow *parent); - -protected: - eap::config_method_eapgtc &m_cfg; ///< Method configuration -}; - - /// /// GTC configuration panel /// @@ -79,7 +71,7 @@ protected: /// \endcond protected: - wxGTCMethodConfigPanel *m_method; ///< Method configuration panel + wxGTCCredentialsConfigPanel *m_credentials; ///< Credentials configuration panel }; /// @} diff --git a/lib/GTC_UI/res/wxGTC_UI.cpp b/lib/GTC_UI/res/wxGTC_UI.cpp deleted file mode 100644 index 265a990..0000000 --- a/lib/GTC_UI/res/wxGTC_UI.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include - -#include "wxGTC_UI.h" - -/////////////////////////////////////////////////////////////////////////// - -wxGTCMethodConfigPanelBase::wxGTCMethodConfigPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) -{ - wxStaticBoxSizer* sb_method; - sb_method = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("GTC Settings") ), wxVERTICAL ); - - wxBoxSizer* sb_method_horiz; - sb_method_horiz = new wxBoxSizer( wxHORIZONTAL ); - - m_method_icon = new wxStaticBitmap( sb_method->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - sb_method_horiz->Add( m_method_icon, 0, wxALL, 5 ); - - wxBoxSizer* sb_method_vert; - sb_method_vert = new wxBoxSizer( wxVERTICAL ); - - m_method_label = new wxStaticText( sb_method->GetStaticBox(), wxID_ANY, _("This method requires no additional configuration."), wxDefaultPosition, wxDefaultSize, 0 ); - m_method_label->Wrap( 440 ); - sb_method_vert->Add( m_method_label, 0, wxALL|wxEXPAND, 5 ); - - - sb_method_horiz->Add( sb_method_vert, 1, wxEXPAND, 5 ); - - - sb_method->Add( sb_method_horiz, 1, wxEXPAND, 5 ); - - - this->SetSizer( sb_method ); - this->Layout(); - - // Connect Events - this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxGTCMethodConfigPanelBase::OnUpdateUI ) ); -} - -wxGTCMethodConfigPanelBase::~wxGTCMethodConfigPanelBase() -{ - // Disconnect Events - this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxGTCMethodConfigPanelBase::OnUpdateUI ) ); - -} diff --git a/lib/GTC_UI/res/wxGTC_UI.fbp b/lib/GTC_UI/res/wxGTC_UI.fbp deleted file mode 100644 index 9bdd719..0000000 --- a/lib/GTC_UI/res/wxGTC_UI.fbp +++ /dev/null @@ -1,278 +0,0 @@ - - - - - ; - C++ - 1 - source_name - 0 - 0 - . - UTF-8 - connect - wxGTC_UI - 1000 - none - 1 - wxGTC_UI - - . - #include <StdAfx.h> - 1 - 1 - 1 - 1 - UI - 1 - 1 - - 0 - wxAUI_MGR_DEFAULT - - - 1 - 1 - impl_virtual - - - 0 - wxID_ANY - - - wxGTCMethodConfigPanelBase - - 500,-1 - - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OnUpdateUI - - wxID_ANY - GTC Settings - - sb_method - wxVERTICAL - none - - - 5 - wxEXPAND - 1 - - - sb_method_horiz - wxHORIZONTAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - Load From Icon Resource; ; [32; 32] - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_method_icon - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - - sb_method_vert - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - This method requires no additional configuration. - - 0 - - - 0 - - 1 - m_method_label - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - 440 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/lib/GTC_UI/res/wxGTC_UI.h b/lib/GTC_UI/res/wxGTC_UI.h deleted file mode 100644 index c06e63e..0000000 --- a/lib/GTC_UI/res/wxGTC_UI.h +++ /dev/null @@ -1,52 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __WXGTC_UI_H__ -#define __WXGTC_UI_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class wxGTCMethodConfigPanelBase -/////////////////////////////////////////////////////////////////////////////// -class wxGTCMethodConfigPanelBase : public wxPanel -{ - private: - - protected: - wxStaticBitmap* m_method_icon; - wxStaticText* m_method_label; - - // Virtual event handlers, overide them in your derived class - virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } - - - public: - - wxGTCMethodConfigPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxTAB_TRAVERSAL ); - ~wxGTCMethodConfigPanelBase(); - -}; - -#endif //__WXGTC_UI_H__ diff --git a/lib/GTC_UI/src/GTC_UI.cpp b/lib/GTC_UI/src/GTC_UI.cpp index b3f4f53..b1edca7 100644 --- a/lib/GTC_UI/src/GTC_UI.cpp +++ b/lib/GTC_UI/src/GTC_UI.cpp @@ -21,23 +21,6 @@ #include "StdAfx.h" -////////////////////////////////////////////////////////////////////// -// wxGTCMethodConfigPanel -////////////////////////////////////////////////////////////////////// - -wxGTCMethodConfigPanel::wxGTCMethodConfigPanel(const eap::config_provider &prov, eap::config_method_eapgtc &cfg, wxWindow *parent) : - m_cfg(cfg), - wxGTCMethodConfigPanelBase(parent) -{ - UNREFERENCED_PARAMETER(prov); - - // Load and set icon. - winstd::library lib_shell32; - if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE)) - m_method_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(153))); -} - - ////////////////////////////////////////////////////////////////////// // wxGTCConfigPanel ////////////////////////////////////////////////////////////////////// @@ -47,8 +30,8 @@ wxGTCConfigPanel::wxGTCConfigPanel(const eap::config_provider &prov, eap::config wxBoxSizer* sb_content; sb_content = new wxBoxSizer( wxVERTICAL ); - m_method = new wxGTCMethodConfigPanel(prov, cfg, this); - sb_content->Add(m_method, 0, wxEXPAND, 5); + m_credentials = new wxGTCCredentialsConfigPanel(prov, cfg, this, _("GTC User ID")); + sb_content->Add(m_credentials, 0, wxEXPAND, 5); this->SetSizer(sb_content); this->Layout(); @@ -69,7 +52,7 @@ wxGTCConfigPanel::~wxGTCConfigPanel() void wxGTCConfigPanel::OnInitDialog(wxInitDialogEvent& event) { // Forward the event to child panels. - if (m_method) - m_method->GetEventHandler()->ProcessEvent(event); + if (m_credentials) + m_credentials->GetEventHandler()->ProcessEvent(event); } /// \endcond diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index fc9259e..7b372e0 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -255,7 +255,7 @@ EAP_SESSION_HANDLE eap::peer_ttls::begin_session( case eap_type_gtc : meth_inner.reset( new method_eapmsg (*this, cred_inner->get_identity().c_str(), new method_eap (*this, eap_type_gtc, - new method_gtc (*this, dynamic_cast(*cfg_inner))))); break; + new method_gtc (*this, dynamic_cast(*cfg_inner), dynamic_cast(*cred_inner))))); break; default: throw invalid_argument(__FUNCTION__ " Unsupported inner authentication method."); } }