diff --git a/lib/TTLS/include/Config.h b/lib/TTLS/include/Config.h index ffffb0e..19d9c7e 100644 --- a/lib/TTLS/include/Config.h +++ b/lib/TTLS/include/Config.h @@ -30,6 +30,8 @@ namespace eap #pragma once +#include "Credentials.h" + #include "../../TLS/include/Config.h" #include "../../PAP/include/Config.h" @@ -40,7 +42,7 @@ namespace eap namespace eap { - class config_method_ttls : public config_method + class config_method_ttls : public config_method_tls { public: /// @@ -143,10 +145,9 @@ namespace eap { /// /// Generates public identity using current configuration and given credentials /// - std::wstring get_public_identity(const credentials &cred) const; + std::wstring get_public_identity(const credentials_ttls &cred) const; public: - config_method_tls m_outer; ///< Outer authentication configuration std::unique_ptr m_inner; ///< Inner authentication configuration std::wstring m_anonymous_identity; ///< Anonymous identity }; diff --git a/lib/TTLS/src/Config.cpp b/lib/TTLS/src/Config.cpp index c6488ba..348b92d 100644 --- a/lib/TTLS/src/Config.cpp +++ b/lib/TTLS/src/Config.cpp @@ -29,26 +29,23 @@ using namespace winstd; ////////////////////////////////////////////////////////////////////// eap::config_method_ttls::config_method_ttls(_In_ module &mod) : - m_outer(mod), - config_method(mod) + config_method_tls(mod) { } eap::config_method_ttls::config_method_ttls(const _In_ config_method_ttls &other) : - m_outer(other.m_outer), m_inner(other.m_inner ? (config_method*)other.m_inner->clone() : nullptr), m_anonymous_identity(other.m_anonymous_identity), - config_method(other) + config_method_tls(other) { } eap::config_method_ttls::config_method_ttls(_Inout_ config_method_ttls &&other) : - m_outer(std::move(other.m_outer)), m_inner(std::move(other.m_inner)), m_anonymous_identity(std::move(other.m_anonymous_identity)), - config_method(std::move(other)) + config_method_tls(std::move(other)) { } @@ -56,8 +53,7 @@ eap::config_method_ttls::config_method_ttls(_Inout_ config_method_ttls &&other) eap::config_method_ttls& eap::config_method_ttls::operator=(const _In_ config_method_ttls &other) { if (this != &other) { - (config_method&)*this = other; - m_outer = other.m_outer; + (config_method_tls&)*this = other; m_inner.reset(other.m_inner ? (config_method*)other.m_inner->clone() : nullptr); m_anonymous_identity = other.m_anonymous_identity; } @@ -69,10 +65,9 @@ eap::config_method_ttls& eap::config_method_ttls::operator=(const _In_ config_me eap::config_method_ttls& eap::config_method_ttls::operator=(_Inout_ config_method_ttls &&other) { if (this != &other) { - (config_method&&)*this = std::move(other); - m_outer = std::move(other.m_outer); - m_inner = std::move(other.m_inner); - m_anonymous_identity = std::move(other.m_anonymous_identity); + (config_method_tls&&)*this = std::move(other); + m_inner = std::move(other.m_inner); + m_anonymous_identity = std::move(other.m_anonymous_identity); } return *this; @@ -90,7 +85,7 @@ void eap::config_method_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode assert(pDoc); assert(pConfigRoot); - config_method::save(pDoc, pConfigRoot); + config_method_tls::save(pDoc, pConfigRoot); const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); HRESULT hr; @@ -105,8 +100,6 @@ void eap::config_method_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode if (FAILED(hr = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"AnonymousIdentity"), bstrNamespace, bstr(m_anonymous_identity)))) throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - m_outer.save(pDoc, pConfigRoot); - // com_obj pXmlElInnerAuthenticationMethod; if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), bstr(L"InnerAuthenticationMethod"), bstrNamespace, &pXmlElInnerAuthenticationMethod))) @@ -129,7 +122,7 @@ void eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot) assert(pConfigRoot); HRESULT hr; - config_method::load(pConfigRoot); + config_method_tls::load(pConfigRoot); std::wstring xpath(eapxml::get_xpath(pConfigRoot)); @@ -145,8 +138,6 @@ void eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot) m_module.log_config((xpathClientSideCredential + L"/AnonymousIdentity").c_str(), m_anonymous_identity.c_str()); } - m_outer.load(pConfigRoot); - // com_obj pXmlElInnerAuthenticationMethod; if (FAILED(hr = eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod))) @@ -175,8 +166,7 @@ void eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot) void eap::config_method_ttls::operator<<(_Inout_ cursor_out &cursor) const { - config_method::operator<<(cursor); - cursor << m_outer; + config_method_tls::operator<<(cursor); if (m_inner) { if (dynamic_cast(m_inner.get())) { @@ -209,8 +199,7 @@ size_t eap::config_method_ttls::get_pk_size() const size_inner = pksizeof(eap_type_undefined); return - config_method::get_pk_size() + - pksizeof(m_outer) + + config_method_tls::get_pk_size() + size_inner + pksizeof(m_anonymous_identity); } @@ -218,8 +207,7 @@ size_t eap::config_method_ttls::get_pk_size() const void eap::config_method_ttls::operator>>(_Inout_ cursor_in &cursor) { - config_method::operator>>(cursor); - cursor >> m_outer; + config_method_tls::operator>>(cursor); eap_type_t eap_type; cursor >> eap_type; @@ -243,10 +231,10 @@ eap_type_t eap::config_method_ttls::get_method_id() const } -wstring eap::config_method_ttls::get_public_identity(const credentials &cred) const +wstring eap::config_method_ttls::get_public_identity(const credentials_ttls &cred) const { if (m_anonymous_identity.empty()) { - // Use the true identity. Outer has the right-of-way. + // Use the true identity. return cred.get_identity(); } else if (m_anonymous_identity.compare(L"@") == 0) { // Strip username part from identity (RFC 4822). diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index 928408d..b179e8a 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -123,9 +123,9 @@ void eap::peer_ttls::get_identity( } } - if (!is_outer_set && cfg_method->m_outer.m_use_preshared) { + if (!is_outer_set && cfg_method->m_use_preshared) { // Outer TLS: Using preshared credentials. - (credentials_tls&)cred_out = *(credentials_tls*)cfg_method->m_outer.m_preshared.get(); + (credentials_tls&)cred_out = *(credentials_tls*)cfg_method->m_preshared.get(); log_event(&EAPMETHOD_TRACE_EVT_CRED_PRESHARED1, event_data((unsigned int)eap_type_tls), event_data(((credentials_tls&)cred_out).get_name()), event_data::blank); is_outer_set = true; } diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index fd327b7..f66e595 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -139,15 +139,15 @@ void eap::peer_ttls_ui::invoke_identity_ui( const config_provider &cfg_prov(cfg.m_providers.front()); config_method_ttls *cfg_method = dynamic_cast(cfg_prov.m_methods.front().get()); assert(cfg_method); - config_method_pap *cfg_inner_pap = dynamic_cast(cfg_method->m_inner.get()); + config_method_with_cred *cfg_inner = dynamic_cast(cfg_method->m_inner.get()); if (dwFlags & EAP_FLAG_GUEST_ACCESS) { // Disable credential saving for guests. - cfg_method->m_outer.m_allow_save = false; - if (cfg_inner_pap) - cfg_inner_pap->m_allow_save = false; + cfg_method->m_allow_save = false; + if (cfg_inner) + cfg_inner->m_allow_save = false; else - assert(0); // Unsupported inner authentication method type. + assert(0); // Missing inner configuration. } // Initialize application. diff --git a/lib/TTLS_UI/src/TTLS_UI.cpp b/lib/TTLS_UI/src/TTLS_UI.cpp index 76f7290..dab6852 100644 --- a/lib/TTLS_UI/src/TTLS_UI.cpp +++ b/lib/TTLS_UI/src/TTLS_UI.cpp @@ -125,7 +125,7 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::co m_outer_identity = new wxTTLSConfigPanel(m_prov, m_cfg, this); sb_content->Add(m_outer_identity, 0, wxALL|wxEXPAND, 5); - m_tls = new wxTLSConfigPanel(m_prov, m_cfg.m_outer, pszCredTarget, this); + m_tls = new wxTLSConfigPanel(m_prov, m_cfg, pszCredTarget, this); sb_content->Add(m_tls, 0, wxALL|wxEXPAND, 5); wxSize size = sb_content->CalcMin();