eap::config_provider detemplatization

This commit is contained in:
Simon Rozman 2016-07-20 16:16:55 +02:00
parent 780b738842
commit a7d75ea72d
6 changed files with 45 additions and 30 deletions

View File

@ -23,7 +23,7 @@
using namespace std;
using namespace winstd;
eap::module g_module(eap::type_undefined);
eap::peer_base<eap::config_method_pap, eap::credentials_pap, void, void> g_module(eap::type_undefined);
static int CredWrite()

View File

@ -20,6 +20,7 @@
#pragma once
#include "../lib/PAP/include/Config.h"
#include "../lib/PAP/include/Credentials.h"
#include "../lib/EAPBase/include/Module.h"

View File

@ -306,7 +306,7 @@ namespace eap
/// @}
///
/// Makes new set of credentials for the given method type
/// Makes a new set of credentials for the given method type
///
virtual credentials* make_credentials() const = 0;
@ -356,8 +356,8 @@ namespace eap
m_lbl_alt_password(other.m_lbl_alt_password),
config(other)
{
for (std::list<std::unique_ptr<_Tmeth> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
m_methods.push_back(std::move(std::unique_ptr<_Tmeth>(*method ? (_Tmeth*)method->get()->clone() : nullptr)));
for (std::list<std::unique_ptr<config_method> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
m_methods.push_back(std::move(std::unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
}
///
@ -402,8 +402,8 @@ namespace eap
m_lbl_alt_password = other.m_lbl_alt_password;
m_methods.clear();
for (std::list<std::unique_ptr<_Tmeth> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
m_methods.push_back(std::move(std::unique_ptr<_Tmeth>(*method ? (_Tmeth*)method->get()->clone() : nullptr)));
for (std::list<std::unique_ptr<config_method> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
m_methods.push_back(std::move(std::unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
}
return *this;
@ -548,7 +548,7 @@ namespace eap
return false;
}
for (std::list<std::unique_ptr<_Tmeth> >::const_iterator method = m_methods.cbegin(), method_end = m_methods.cend(); method != method_end; ++method) {
for (std::list<std::unique_ptr<config_method> >::const_iterator method = m_methods.cbegin(), method_end = m_methods.cend(); method != method_end; ++method) {
// <AuthenticationMethod>
winstd::com_obj<IXMLDOMElement> pXmlElAuthenticationMethod;
if ((dwResult = eapxml::create_element(pDoc, winstd::bstr(L"AuthenticationMethod"), bstrNamespace, &pXmlElAuthenticationMethod))) {
@ -661,7 +661,7 @@ namespace eap
winstd::com_obj<IXMLDOMNode> pXmlElMethod;
pXmlListMethods->get_item(i, &pXmlElMethod);
std::unique_ptr<_Tmeth> cfg(new _Tmeth(m_module));
std::unique_ptr<config_method> cfg(m_module.make_config_method());
// Check EAP method type (<EAPMethod>).
DWORD dwMethodID;
@ -749,14 +749,14 @@ namespace eap
eapserial::unpack(cursor, m_lbl_alt_identity );
eapserial::unpack(cursor, m_lbl_alt_password );
std::list<_Tmeth>::size_type count;
std::list<config_method>::size_type count;
bool is_nonnull;
eapserial::unpack(cursor, count);
m_methods.clear();
for (std::list<_Tmeth>::size_type i = 0; i < count; i++) {
for (std::list<config_method>::size_type i = 0; i < count; i++) {
eapserial::unpack(cursor, is_nonnull);
if (is_nonnull) {
std::unique_ptr<_Tmeth> el(new _Tmeth(m_module));
std::unique_ptr<config_method> el(m_module.make_config_method());
el->unpack(cursor);
m_methods.push_back(std::move(el));
} else
@ -767,16 +767,16 @@ namespace eap
/// @}
public:
bool m_read_only; ///< Is profile read-only
std::wstring m_id; ///< Profile ID
winstd::tstring m_name; ///< Provider name
winstd::tstring m_help_email; ///< Helpdesk e-mail
winstd::tstring m_help_web; ///< Helpdesk website URL
winstd::tstring m_help_phone; ///< Helpdesk phone
winstd::tstring m_lbl_alt_credential; ///< Alternative label for credential prompt
winstd::tstring m_lbl_alt_identity; ///< Alternative label for identity prompt
winstd::tstring m_lbl_alt_password; ///< Alternative label for password prompt
std::list<std::unique_ptr<_Tmeth> > m_methods; ///< List of method configurations
bool m_read_only; ///< Is profile read-only
std::wstring m_id; ///< Profile ID
winstd::tstring m_name; ///< Provider name
winstd::tstring m_help_email; ///< Helpdesk e-mail
winstd::tstring m_help_web; ///< Helpdesk website URL
winstd::tstring m_help_phone; ///< Helpdesk phone
winstd::tstring m_lbl_alt_credential; ///< Alternative label for credential prompt
winstd::tstring m_lbl_alt_identity; ///< Alternative label for identity prompt
winstd::tstring m_lbl_alt_password; ///< Alternative label for password prompt
std::list<std::unique_ptr<config_method> > m_methods; ///< List of method configurations
};

View File

@ -96,6 +96,11 @@ namespace eap
///
void free_error_memory(_In_ EAP_ERROR *err);
///
/// Makes a new method config for the given method type
///
virtual config_method* make_config_method() = 0;
/// @}
/// \name Logging
@ -693,6 +698,14 @@ namespace eap
/// Constructs a EAP peer module for the given EAP type
///
peer_base(_In_ type_t eap_method) : module(eap_method) {}
///
/// Makes a new method config for the given method type
///
virtual config_method* make_config_method()
{
return new config_method_type(*this);
}
};

View File

@ -116,8 +116,8 @@ public:
for (std::list<_Tprov>::iterator provider = m_cfg.m_providers.begin(), provider_end = m_cfg.m_providers.end(); provider != provider_end; ++provider) {
bool is_single = provider->m_methods.size() == 1;
std::list<std::unique_ptr<_Tmeth> >::size_type count = 0;
std::list<std::unique_ptr<_Tmeth> >::iterator method = provider->m_methods.begin(), method_end = provider->m_methods.end();
std::list<std::unique_ptr<eap::config_method> >::size_type count = 0;
std::list<std::unique_ptr<eap::config_method> >::iterator method = provider->m_methods.begin(), method_end = provider->m_methods.end();
for (; method != method_end; ++method, count++)
m_providers->AddPage(
new _wxT(

View File

@ -121,10 +121,10 @@ protected:
/// \endcond
protected:
_Tprov &m_prov; ///< EAP provider
eap::config_method_ttls &m_cfg; ///< TTLS configuration
winstd::library m_shell32; ///< shell32.dll resource library reference
wxIcon m_icon; ///< Panel icon
_Tprov &m_prov; ///< EAP provider
eap::config_method_ttls &m_cfg; ///< TTLS configuration
winstd::library m_shell32; ///< shell32.dll resource library reference
wxIcon m_icon; ///< Panel icon
};
@ -139,9 +139,9 @@ public:
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
/// \param[in] parent Parent window
///
wxTTLSConfigWindow(_Tprov &prov, eap::config_method_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) :
wxTTLSConfigWindow(_Tprov &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent) :
m_prov(prov),
m_cfg(cfg),
m_cfg((eap::config_method_ttls&)cfg),
m_cfg_pap(cfg.m_module),
wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL)
{
@ -269,5 +269,6 @@ protected:
wxStaticText *m_inner_title; ///< Inner authentication title
wxChoicebook *m_inner_type; ///< Inner authentication type
eap::config_method_pap m_cfg_pap; ///< Temporary PAP configuration
// Temprary inner method configurations to hold data until applied
eap::config_method_pap m_cfg_pap; ///< PAP configuration
};