diff --git a/CredWrite/Main.cpp b/CredWrite/Main.cpp index 5a59a11..e6e3917 100644 --- a/CredWrite/Main.cpp +++ b/CredWrite/Main.cpp @@ -72,11 +72,10 @@ static int CredWrite() } else { // Get the realm from user name. LPCWSTR _identity = cred_pap.m_identity.c_str(), domain; - if ((domain = wcschr(_identity, L'@')) != NULL) - target_name = domain + 1; - else if ((domain = wcschr(_identity, L'\\')) != NULL) - target_name.assign(_identity, domain); - else + if ((domain = wcschr(_identity, L'@')) != NULL) { + target_name = L"urn:RFC4282:realm:"; + target_name += domain + 1; + } else target_name = L"*"; } diff --git a/EAPMethods/locale/EAPMethods.pot b/EAPMethods/locale/EAPMethods.pot index 8c71416..140c916 100644 --- a/EAPMethods/locale/EAPMethods.pot +++ b/EAPMethods/locale/EAPMethods.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: EAPMethods\n" -"POT-Creation-Date: 2016-08-31 17:41+0200\n" +"POT-Creation-Date: 2016-09-02 19:08+0200\n" "PO-Revision-Date: 2016-06-02 12:27+0200\n" "Last-Translator: Simon Rozman \n" "Language-Team: Amebis, d. o. o., Kamnik \n" @@ -178,30 +178,38 @@ msgid "Assign your organization a unique ID to allow sharing the same credential msgstr "" #: lib/EAPBase_UI/res/wxEAP_UI.cpp:542 +msgid "&Namespace:" +msgstr "" + +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:546 +msgid "urn:RFC4282:realm" +msgstr "" + +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:546 +msgid "urn:uuid" +msgstr "" + +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:558 msgid "Provider unique &identifier:" msgstr "" -#: lib/EAPBase_UI/res/wxEAP_UI.cpp:547 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:563 msgid "Your organization ID to assign same credentials from other profiles" msgstr "" -#: lib/EAPBase_UI/res/wxEAP_UI.cpp:551 -msgid "(Examples: contoso.com, DOT-UK, etc.)" -msgstr "" - -#: lib/EAPBase_UI/res/wxEAP_UI.cpp:576 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:588 msgid "Configuration Lock" msgstr "" -#: lib/EAPBase_UI/res/wxEAP_UI.cpp:587 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:599 msgid "Your configuration can be locked to prevent accidental modification by end-users. Users will only be allowed to enter credentials." msgstr "" -#: lib/EAPBase_UI/res/wxEAP_UI.cpp:594 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:606 msgid "&Lock this configuration and prevent any further modification via user interface." msgstr "" -#: lib/EAPBase_UI/res/wxEAP_UI.cpp:597 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:609 msgid "(Warning: Once locked, you can not revert using this dialog!)" msgstr "" @@ -210,8 +218,8 @@ msgstr "" msgid "%s Credentials" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:123 lib/EAPBase_UI/include/EAP_UI.h:351 -#: lib/EAPBase_UI/include/EAP_UI.h:361 lib/EAPBase_UI/res/wxEAP_UI.h:118 +#: lib/EAPBase_UI/src/EAP_UI.cpp:123 lib/EAPBase_UI/include/EAP_UI.h:352 +#: lib/EAPBase_UI/include/EAP_UI.h:362 lib/EAPBase_UI/res/wxEAP_UI.h:119 msgid "EAP Credentials" msgstr "" @@ -220,42 +228,32 @@ msgstr "" msgid "For additional help and instructions, please contact %s at:" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:168 -#, c-format -msgid "your %ls provider" -msgstr "" - -#: lib/EAPBase_UI/src/EAP_UI.cpp:168 +#: lib/EAPBase_UI/src/EAP_UI.cpp:167 msgid "your provider" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:187 +#: lib/EAPBase_UI/src/EAP_UI.cpp:186 msgid "Open the default web browser" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:198 +#: lib/EAPBase_UI/src/EAP_UI.cpp:197 msgid "Open your e-mail program" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:209 +#: lib/EAPBase_UI/src/EAP_UI.cpp:208 msgid "Dial the phone number" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:229 +#: lib/EAPBase_UI/src/EAP_UI.cpp:228 #, c-format msgid "%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification." msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:231 -#, c-format -msgid "Your %ls provider" -msgstr "" - -#: lib/EAPBase_UI/src/EAP_UI.cpp:231 +#: lib/EAPBase_UI/src/EAP_UI.cpp:229 msgid "Your provider" msgstr "" -#: lib/EAPBase_UI/src/EAP_UI.cpp:251 +#: lib/EAPBase_UI/src/EAP_UI.cpp:249 msgid "Previous attempt to connect failed. Please, make sure your credentials are correct, or try again later." msgstr "" @@ -429,73 +427,77 @@ msgstr "" msgid "Custom outer identity to use" msgstr "" -#: lib/TTLS_UI/src/Module.cpp:272 lib/TTLS_UI/src/Module.cpp:282 -#: lib/EAPBase_UI/include/EAP_UI.h:690 +#: lib/TTLS_UI/src/Module.cpp:275 lib/TTLS_UI/src/Module.cpp:285 +#: lib/EAPBase_UI/include/EAP_UI.h:689 #, c-format msgid "Error writing credentials to Credential Manager: %hs (error %u)" msgstr "" -#: lib/TTLS_UI/src/Module.cpp:274 lib/TTLS_UI/src/Module.cpp:284 -#: lib/EAPBase_UI/include/EAP_UI.h:693 +#: lib/TTLS_UI/src/Module.cpp:277 lib/TTLS_UI/src/Module.cpp:287 +#: lib/EAPBase_UI/include/EAP_UI.h:692 msgid "Writing credentials failed." msgstr "" -#: lib/TTLS_UI/src/TTLS_UI.cpp:107 lib/TTLS_UI/src/TTLS_UI.cpp:220 +#: lib/TTLS_UI/src/TTLS_UI.cpp:108 lib/TTLS_UI/src/TTLS_UI.cpp:235 msgid "Inner Authentication" msgstr "" -#: lib/TTLS_UI/src/TTLS_UI.cpp:113 +#: lib/TTLS_UI/src/TTLS_UI.cpp:114 msgid "Select inner authentication method from the list" msgstr "" -#: lib/TTLS_UI/src/TTLS_UI.cpp:115 +#: lib/TTLS_UI/src/TTLS_UI.cpp:116 msgid "PAP" msgstr "" -#: lib/TTLS_UI/src/TTLS_UI.cpp:120 lib/TTLS_UI/src/TTLS_UI.cpp:241 +#: lib/TTLS_UI/src/TTLS_UI.cpp:118 +msgid "MSCHAPv2" +msgstr "" + +#: lib/TTLS_UI/src/TTLS_UI.cpp:123 lib/TTLS_UI/src/TTLS_UI.cpp:256 msgid "Outer Authentication" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:288 +#: lib/EAPBase_UI/include/EAP_UI.h:289 #, c-format msgid "Are you sure you want to permanently remove %ls provider from configuration?" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:288 +#: lib/EAPBase_UI/include/EAP_UI.h:289 msgid "Warning" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:548 +#: lib/EAPBase_UI/include/EAP_UI.h:549 msgid "Provider Settings" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:706 +#: lib/EAPBase_UI/include/EAP_UI.h:705 #, c-format msgid "Deleting credentials failed (error %u)." msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:739 +#: lib/EAPBase_UI/include/EAP_UI.h:738 #, c-format msgid "" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:743 +#: lib/EAPBase_UI/include/EAP_UI.h:742 msgid "" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:754 lib/EAPBase_UI/include/EAP_UI.h:763 +#: lib/EAPBase_UI/include/EAP_UI.h:753 lib/EAPBase_UI/include/EAP_UI.h:762 msgid "" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:754 lib/EAPBase_UI/include/EAP_UI.h:763 +#: lib/EAPBase_UI/include/EAP_UI.h:753 lib/EAPBase_UI/include/EAP_UI.h:762 msgid "" msgstr "" -#: lib/EAPBase_UI/include/EAP_UI.h:968 +#: lib/EAPBase_UI/include/EAP_UI.h:962 msgid "" msgstr "" -#: lib/EAPBase_UI/res/wxEAP_UI.h:68 +#: lib/EAPBase_UI/res/wxEAP_UI.h:69 msgid "EAP Connection Configuration" msgstr "" diff --git a/lib/EAPBase/include/Config.h b/lib/EAPBase/include/Config.h index b6ee2ce..7028598 100644 --- a/lib/EAPBase/include/Config.h +++ b/lib/EAPBase/include/Config.h @@ -454,9 +454,25 @@ namespace eap /// @} + /// + /// Returns provider namespace and ID concatenated + /// + inline std::wstring get_id() const + { + if (m_namespace.empty()) + return m_id; + else { + std::wstring id(m_namespace); + id += L':'; + id += m_id; + return id; + } + } + public: - bool m_read_only; ///< Is profile read-only + std::wstring m_namespace; ///< Provider namespace URI std::wstring m_id; ///< Provider ID + bool m_read_only; ///< Is profile read-only winstd::tstring m_name; ///< Provider name winstd::tstring m_help_email; ///< Helpdesk e-mail winstd::tstring m_help_web; ///< Helpdesk website URL diff --git a/lib/EAPBase/include/Credentials.h b/lib/EAPBase/include/Credentials.h index 288878e..a976d58 100644 --- a/lib/EAPBase/include/Credentials.h +++ b/lib/EAPBase/include/Credentials.h @@ -476,8 +476,34 @@ namespace eap /// @} + /// + /// Returns provider namespace and ID concatenated + /// + inline std::wstring get_id() const + { + if (m_namespace.empty()) + return m_id; + else { + std::wstring id(m_namespace); + id += L':'; + id += m_id; + return id; + } + } + + /// + /// Checks if credentials match given provider. + /// + inline bool match(_In_ const config_provider &cfg_provider) const + { + return + _wcsicmp(m_namespace.c_str(), cfg_provider.m_namespace.c_str()) == 0 && + _wcsicmp(m_id .c_str(), cfg_provider.m_id .c_str()) == 0; + } + public: const config_connection& m_cfg; ///< Connection configuration + std::wstring m_namespace; ///< Provider namespace URI std::wstring m_id; ///< Provider ID std::unique_ptr m_cred; ///< Credentials }; diff --git a/lib/EAPBase/include/EAPXML.h b/lib/EAPBase/include/EAPXML.h index 8c5c2be..afa73ab 100644 --- a/lib/EAPBase/include/EAPXML.h +++ b/lib/EAPBase/include/EAPXML.h @@ -48,6 +48,17 @@ namespace eapxml inline HRESULT put_element_value(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_ bool bValue); inline HRESULT put_element_base64(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); inline HRESULT put_element_hex(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ BSTR *pbstrValue); + template inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::basic_string &sValue); + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ DWORD *pdwValue); + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ bool *pbValue); + template inline HRESULT get_attrib_base64(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue); + template inline HRESULT get_attrib_hex(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue); + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_z_ const BSTR bstrValue); + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_ DWORD dwValue); + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_ bool bValue); + inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); + inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); inline std::wstring get_xpath(_In_ IXMLDOMNode *pXmlNode); } @@ -384,6 +395,144 @@ namespace eapxml } + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ BSTR *pbstrValue) + { + assert(pbstrValue); + + HRESULT hr; + winstd::com_obj pXmlAttributes; + winstd::com_obj pXmlAt; + VARIANT varValue; + V_VT(&varValue) = VT_EMPTY; + + return + SUCCEEDED(hr = pXmlParent->get_attributes(&pXmlAttributes)) ? + SUCCEEDED(hr = pXmlAttributes->getNamedItem(bstrAttributeName, &pXmlAt)) ? + pXmlAt ? + SUCCEEDED(hr = pXmlAt->get_nodeValue(&varValue)) ? + V_VT(&varValue) == VT_BSTR ? *pbstrValue = V_BSTR(&varValue), S_OK : E_UNEXPECTED : hr : E_NOT_SET : hr : hr; + } + + + template + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::basic_string &sValue) + { + winstd::bstr bstr; + HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr); + if (SUCCEEDED(hr)) + sValue.assign(bstr, bstr.length()); + return hr; + } + + + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ DWORD *pdwValue) + { + assert(pdwValue); + + winstd::bstr bstr; + HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr); + if (SUCCEEDED(hr)) + *pdwValue = wcstoul(bstr, NULL, 10); + return hr; + } + + + inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ bool *pbValue) + { + assert(pbValue); + + winstd::bstr bstr; + HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr); + if (SUCCEEDED(hr)) { + if (CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"true" , -1, NULL, NULL, 0) == CSTR_EQUAL || + CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"1" , -1, NULL, NULL, 0) == CSTR_EQUAL) + *pbValue = true; + else if ( + CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"false", -1, NULL, NULL, 0) == CSTR_EQUAL || + CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"0" , -1, NULL, NULL, 0) == CSTR_EQUAL) + *pbValue = false; + else + hr = E_NOT_VALID_STATE; + } + + return hr; + } + + + template + inline HRESULT get_attrib_base64(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue) + { + winstd::bstr bstr; + HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr); + if (SUCCEEDED(hr)) { + winstd::base64_dec dec; + bool is_last; + dec.decode(aValue, is_last, (BSTR)bstr, bstr.length()); + } + + return hr; + } + + + template + inline HRESULT get_attrib_hex(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue) + { + winstd::bstr bstr; + HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr); + if (SUCCEEDED(hr)) { + winstd::hex_dec dec; + bool is_last; + dec.decode(aValue, is_last, (BSTR)bstr, bstr.length()); + } + + return hr; + } + + + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_z_ const BSTR bstrValue) + { + HRESULT hr; + winstd::com_obj pXmlEl; + VARIANT varValue; + V_VT(&varValue) = VT_BSTR; + V_BSTR(&varValue) = bstrValue; + + return + SUCCEEDED(hr = pCurrentDOMNode->QueryInterface(__uuidof(IXMLDOMElement), (void**)&pXmlEl)) && + SUCCEEDED(hr = pXmlEl->setAttribute(bstrAttributeName, varValue)) ? S_OK : hr; + } + + + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_ DWORD dwValue) + { + return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(winstd::wstring_printf(L"%d", dwValue))); + } + + + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_ bool bValue) + { + return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(bValue ? L"true": L"false")); + } + + + inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen) + { + std::wstring sBase64; + winstd::base64_enc enc; + enc.encode(sBase64, pValue, nValueLen); + return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(sBase64)); + } + + + inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen) + { + std::wstring sHex; + winstd::hex_enc enc; + enc.encode(sHex, pValue, nValueLen); + return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(sHex)); + } + + inline std::wstring get_xpath(_In_ IXMLDOMNode *pXmlNode) { if (pXmlNode) { diff --git a/lib/EAPBase/src/Config.cpp b/lib/EAPBase/src/Config.cpp index 28e7993..d6779bd 100644 --- a/lib/EAPBase/src/Config.cpp +++ b/lib/EAPBase/src/Config.cpp @@ -287,8 +287,9 @@ eap::config_provider::config_provider(_In_ module &mod) : eap::config_provider::config_provider(_In_ const config_provider &other) : - m_read_only (other.m_read_only ), + m_namespace (other.m_namespace ), m_id (other.m_id ), + m_read_only (other.m_read_only ), m_name (other.m_name ), m_help_email (other.m_help_email ), m_help_web (other.m_help_web ), @@ -305,8 +306,9 @@ eap::config_provider::config_provider(_In_ const config_provider &other) : eap::config_provider::config_provider(_Inout_ config_provider &&other) : - m_read_only (std::move(other.m_read_only )), + m_namespace (std::move(other.m_namespace )), m_id (std::move(other.m_id )), + m_read_only (std::move(other.m_read_only )), m_name (std::move(other.m_name )), m_help_email (std::move(other.m_help_email )), m_help_web (std::move(other.m_help_web )), @@ -324,8 +326,9 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider { if (this != &other) { (config&)*this = other; - m_read_only = other.m_read_only; + m_namespace = other.m_namespace; m_id = other.m_id; + m_read_only = other.m_read_only; m_name = other.m_name; m_help_email = other.m_help_email; m_help_web = other.m_help_web; @@ -348,8 +351,9 @@ eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider && { if (this != &other) { (config&&)*this = std::move(other ); - m_read_only = std::move(other.m_read_only ); + m_namespace = std::move(other.m_namespace ); m_id = std::move(other.m_id ); + m_read_only = std::move(other.m_read_only ); m_name = std::move(other.m_name ); m_help_email = std::move(other.m_help_email ); m_help_web = std::move(other.m_help_web ); @@ -376,15 +380,20 @@ void eap::config_provider::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pC HRESULT hr; + // namespace + if (!m_namespace.empty()) + if (FAILED(hr = eapxml::put_attrib_value(pConfigRoot, bstr(L"namespace"), bstr(m_namespace)))) + throw com_runtime_error(hr, __FUNCTION__ " Error creating namespace attribute."); + + // ID + if (!m_id.empty()) + if (FAILED(hr = eapxml::put_attrib_value(pConfigRoot, bstr(L"ID"), bstr(m_id)))) + throw com_runtime_error(hr, __FUNCTION__ " Error creating ID attribute."); + // if (FAILED(hr = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"read-only"), namespace_eapmetadata, m_read_only))) throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - // - if (!m_id.empty()) - if (FAILED(hr = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"ID"), namespace_eapmetadata, bstr(m_id)))) - throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - // com_obj pXmlElProviderInfo; if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ProviderInfo"), bstr(L"ProviderInfo"), namespace_eapmetadata, &pXmlElProviderInfo))) @@ -458,16 +467,21 @@ void eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot) config::load(pConfigRoot); + // namespace + m_namespace.clear(); + eapxml::get_attrib_value(pConfigRoot, bstr(L"namespace"), m_namespace); + m_module.log_config((xpath + L" namespace").c_str(), m_namespace.c_str()); + + // ID + m_id.clear(); + eapxml::get_attrib_value(pConfigRoot, bstr(L"ID"), m_id); + m_module.log_config((xpath + L" ID").c_str(), m_id.c_str()); + // if (FAILED(hr = eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:read-only"), &m_read_only))) m_read_only = true; m_module.log_config((xpath + L"/read-only").c_str(), m_read_only); - // - m_id.clear(); - eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:ID"), m_id); - m_module.log_config((xpath + L"/ID").c_str(), m_id.c_str()); - // m_name.clear(); m_help_email.clear(); @@ -550,8 +564,9 @@ void eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot) void eap::config_provider::operator<<(_Inout_ cursor_out &cursor) const { config::operator<<(cursor); - cursor << m_read_only ; + cursor << m_namespace ; cursor << m_id ; + cursor << m_read_only ; cursor << m_name ; cursor << m_help_email ; cursor << m_help_web ; @@ -567,8 +582,9 @@ size_t eap::config_provider::get_pk_size() const { return config::get_pk_size() + - pksizeof(m_read_only ) + + pksizeof(m_namespace ) + pksizeof(m_id ) + + pksizeof(m_read_only ) + pksizeof(m_name ) + pksizeof(m_help_email ) + pksizeof(m_help_web ) + @@ -583,8 +599,9 @@ size_t eap::config_provider::get_pk_size() const void eap::config_provider::operator>>(_Inout_ cursor_in &cursor) { config::operator>>(cursor); - cursor >> m_read_only ; + cursor >> m_namespace ; cursor >> m_id ; + cursor >> m_read_only ; cursor >> m_name ; cursor >> m_help_email ; cursor >> m_help_web ; diff --git a/lib/EAPBase/src/Credentials.cpp b/lib/EAPBase/src/Credentials.cpp index a649829..85e7cd8 100644 --- a/lib/EAPBase/src/Credentials.cpp +++ b/lib/EAPBase/src/Credentials.cpp @@ -431,19 +431,21 @@ eap::credentials_connection::credentials_connection(_In_ module &mod, _In_ const eap::credentials_connection::credentials_connection(_In_ const credentials_connection &other) : - m_cfg (other.m_cfg ), - m_id (other.m_id ), - m_cred(other.m_cred ? (credentials*)other.m_cred->clone() : nullptr), - config(other ) + m_cfg (other.m_cfg ), + m_namespace(other.m_namespace), + m_id (other.m_id ), + m_cred (other.m_cred ? (credentials*)other.m_cred->clone() : nullptr), + config (other ) { } eap::credentials_connection::credentials_connection(_Inout_ credentials_connection &&other) : - m_cfg ( other.m_cfg ), - m_id (std::move(other.m_id )), - m_cred(std::move(other.m_cred)), - config(std::move(other )) + m_cfg ( other.m_cfg ), + m_namespace(std::move(other.m_namespace)), + m_id (std::move(other.m_id )), + m_cred (std::move(other.m_cred )), + config (std::move(other )) { } @@ -452,6 +454,7 @@ eap::credentials_connection& eap::credentials_connection::operator=(_In_ const c { if (this != &other) { (config&)*this = other; + m_namespace = other.m_namespace; m_id = other.m_id; m_cred.reset(other.m_cred ? (credentials*)other.m_cred->clone() : nullptr); } @@ -463,9 +466,10 @@ eap::credentials_connection& eap::credentials_connection::operator=(_In_ const c eap::credentials_connection& eap::credentials_connection::operator=(_Inout_ credentials_connection &&other) { if (this != &other) { - (config&)*this = std::move(other ); - m_id = std::move(other.m_id ); - m_cred = std::move(other.m_cred); + (config&)*this = std::move(other ); + m_namespace = std::move(other.m_namespace); + m_id = std::move(other.m_id ); + m_cred = std::move(other.m_cred ); } return *this; @@ -487,11 +491,22 @@ void eap::credentials_connection::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMN HRESULT hr; - // - if (FAILED(hr = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"IdentityProviderID"), namespace_eapmetadata, bstr(m_id)))) - throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); + // Create node. + com_obj pXmlElIdentityProvider; + if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:EAPIdentityProvider"), bstr(L"EAPIdentityProvider"), namespace_eapmetadata, &pXmlElIdentityProvider))) + throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - m_cred->save(pDoc, pConfigRoot); + // namespace + if (!m_namespace.empty()) + if (FAILED(hr = eapxml::put_attrib_value(pXmlElIdentityProvider, bstr(L"namespace"), bstr(m_namespace)))) + throw com_runtime_error(hr, __FUNCTION__ " Error creating namespace attribute."); + + // ID + if (!m_id.empty()) + if (FAILED(hr = eapxml::put_attrib_value(pXmlElIdentityProvider, bstr(L"ID"), bstr(m_id)))) + throw com_runtime_error(hr, __FUNCTION__ " Error creating ID attribute."); + + m_cred->save(pDoc, pXmlElIdentityProvider); } @@ -502,27 +517,37 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot) config::load(pConfigRoot); - std::wstring xpath(eapxml::get_xpath(pConfigRoot)); + // + winstd::com_obj pXmlElClientSideCredential; + if (FAILED(hr = eapxml::select_element(pConfigRoot, winstd::bstr(L"eap-metadata:EAPIdentityProvider"), &pXmlElClientSideCredential))) + throw com_runtime_error(hr, __FUNCTION__ " Error loading element."); - if (FAILED(hr = eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:IdentityProviderID"), m_id))) - m_id.clear(); + std::wstring xpath(eapxml::get_xpath(pXmlElClientSideCredential)); - m_module.log_config((xpath + L"/IdentityProviderID").c_str(), m_id.c_str()); + // namespace + m_namespace.clear(); + eapxml::get_attrib_value(pXmlElClientSideCredential, bstr(L"namespace"), m_namespace); + m_module.log_config((xpath + L" namespace").c_str(), m_namespace.c_str()); + + // ID + m_id.clear(); + eapxml::get_attrib_value(pXmlElClientSideCredential, bstr(L"ID"), m_id); + m_module.log_config((xpath + L" ID").c_str(), m_id.c_str()); // Look-up the provider. for (config_connection::provider_list::const_iterator cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) { if (cfg_prov != cfg_prov_end) { - if (_wcsicmp(cfg_prov->m_id.c_str(), m_id.c_str()) == 0) { + if (match(*cfg_prov)) { // Matching provider found. Create matching blank credential set, then load. if (cfg_prov->m_methods.empty()) - throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->m_id.c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str()); const config_method_with_cred *cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); m_cred.reset(cfg_method->make_credentials()); - m_cred->load(pConfigRoot); + m_cred->load(pXmlElClientSideCredential); break; } } else - throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider ID within this connection configuration (provider ID: %ls).", m_id.c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str()).c_str()); } } @@ -530,8 +555,9 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot) void eap::credentials_connection::operator<<(_Inout_ cursor_out &cursor) const { config::operator<<(cursor); - cursor << m_id ; - cursor << *m_cred; + cursor << m_namespace; + cursor << m_id ; + cursor << *m_cred ; } @@ -539,29 +565,31 @@ size_t eap::credentials_connection::get_pk_size() const { return config::get_pk_size() + - pksizeof( m_id ) + - pksizeof(*m_cred); + pksizeof( m_namespace) + + pksizeof( m_id ) + + pksizeof(*m_cred ); } void eap::credentials_connection::operator>>(_Inout_ cursor_in &cursor) { config::operator>>(cursor); - cursor >> m_id; + cursor >> m_namespace; + cursor >> m_id ; // Look-up the provider. for (config_connection::provider_list::const_iterator cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) { if (cfg_prov != cfg_prov_end) { - if (_wcsicmp(cfg_prov->m_id.c_str(), m_id.c_str()) == 0) { + if (match(*cfg_prov)) { // Matching provider found. Create matching blank credential set, then read. if (cfg_prov->m_methods.empty()) - throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->m_id.c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str()); const config_method_with_cred *cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); m_cred.reset(cfg_method->make_credentials()); cursor >> *m_cred; break; } } else - throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider ID within this connection configuration (provider ID: %ls).", m_id.c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str()).c_str()); } } diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 881da62..67f17e7 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -199,20 +199,21 @@ public: this->SetIcon(wxIcon(wxICON(product.ico))); #endif + wstring target_name; for (eap::config_connection::provider_list::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::vector >::size_type count = 0; std::vector >::iterator method = provider->m_methods.begin(), method_end = provider->m_methods.end(); - for (; method != method_end; ++method, count++) + for (; method != method_end; ++method, count++) { m_providers->AddPage( new _wxT( *provider, *method->get(), - provider->m_id.c_str(), m_providers), is_single ? wxEAPGetProviderName(provider->m_name) : winstd::tstring_printf(_T("%s (%u)"), wxEAPGetProviderName(provider->m_name), count)); + } } this->Layout(); @@ -259,7 +260,8 @@ protected: eap::config_provider cfg_provider(m_cfg.m_module); GUID guid; CoCreateGuid(&guid); - cfg_provider.m_id = std::move(winstd::wstring_guid(guid)); + cfg_provider.m_namespace = L"urn:uuid"; + cfg_provider.m_id = winstd::wstring_guid(guid).substr(1, 36); cfg_provider.m_methods.push_back(std::move(cfg_method)); // Append provider. @@ -271,7 +273,6 @@ protected: new _wxT( cfg_provider2, *cfg_method2, - cfg_provider2.m_id.c_str(), m_providers), wxEAPGetProviderName(cfg_provider2.m_name), true); @@ -562,15 +563,13 @@ public: /// /// Constructs a credential configuration panel /// - /// \param[in] prov Provider configuration data - /// \param[inout] cfg Configuration data - /// \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 + /// \param[in] prov Provider configuration data + /// \param[inout] cfg Configuration data + /// \param[in] parent Parent window /// - wxEAPCredentialsConfigPanel(const eap::config_provider &prov, eap::config_method_with_cred &cfg, LPCTSTR pszCredTarget, wxWindow *parent) : + wxEAPCredentialsConfigPanel(const eap::config_provider &prov, eap::config_method_with_cred &cfg, wxWindow *parent) : m_prov(prov), m_cfg(cfg), - m_target(pszCredTarget), m_has_own(false), m_cred_own(cfg.m_module), m_cred_preshared(cfg.m_module), @@ -678,12 +677,12 @@ protected: // Display credential prompt. wxEAPCredentialsDialog dlg(m_prov, this); - _wxT *panel = new _wxT(m_prov, m_cfg, m_cred_own, m_target.c_str(), &dlg, true); + _wxT *panel = new _wxT(m_prov, m_cfg, m_cred_own, &dlg, true); dlg.AddContent(panel); if (dlg.ShowModal() == wxID_OK && panel->GetRemember()) { // Write credentials to credential manager. try { - m_cred_own.store(m_target.c_str()); + m_cred_own.store(m_prov.get_id().c_str()); m_has_own = TRUE; UpdateOwnIdentity(); } catch (winstd::win_runtime_error &err) { @@ -699,7 +698,7 @@ protected: virtual void OnClearOwn(wxCommandEvent& /*event*/) { - if (CredDelete(m_cred_own.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0)) { + if (CredDelete(m_cred_own.target_name(m_prov.get_id().c_str()).c_str(), CRED_TYPE_GENERIC, 0)) { m_own_identity->Clear(); m_has_own = false; } else @@ -711,7 +710,7 @@ protected: { wxEAPCredentialsDialog dlg(m_prov, this); - _wxT *panel = new _wxT(m_prov, m_cfg, m_cred_preshared, _T(""), &dlg, true); + _wxT *panel = new _wxT(m_prov, m_cfg, m_cred_preshared, &dlg, true); dlg.AddContent(panel); if (dlg.ShowModal() == wxID_OK) @@ -728,7 +727,7 @@ protected: void RetrieveOwnCredentials() { try { - m_cred_own.retrieve(m_target.c_str()); + m_cred_own.retrieve(m_prov.get_id().c_str()); m_has_own = true; UpdateOwnIdentity(); } catch (winstd::win_runtime_error &err) { @@ -768,7 +767,6 @@ protected: protected: const eap::config_provider &m_prov; ///< EAP provider eap::config_method_with_cred &m_cfg; ///< EAP method configuration - winstd::tstring m_target; ///< Credential Manager target private: bool m_has_own; ///< Does the user has (some sort of) credentials stored in Credential Manager? @@ -789,18 +787,16 @@ public: /// /// Constructs a credentials panel /// - /// \param[in] prov Provider configuration data - /// \param[in] cfg Configuration data - /// \param[inout] cred Credentials data - /// \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 - /// \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] prov Provider configuration data + /// \param[in] cfg Configuration data + /// \param[inout] cred Credentials data + /// \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. /// - wxEAPCredentialsPanel(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, wxWindow* parent, bool is_config = false) : m_prov(prov), m_cfg(cfg), m_cred(cred), - m_target(pszCredTarget), m_is_config(is_config), _Tbase(parent) { @@ -845,7 +841,6 @@ protected: const eap::config_provider &m_prov; ///< Provider configuration const eap::config_method_with_cred &m_cfg; ///< Method configuration _Tcred &m_cred; ///< Credentials - winstd::tstring m_target; ///< Credential Manager target bool m_is_config; ///< Is this a configuration dialog? }; @@ -857,15 +852,14 @@ public: /// /// Constructs a password credentials panel /// - /// \param[in] prov Provider configuration data - /// \param[in] cfg Configuration data - /// \param[inout] cred Credentials data - /// \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 - /// \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] prov Provider configuration data + /// \param[in] cfg Configuration data + /// \param[inout] cred Credentials data + /// \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. /// - wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) : - wxEAPCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, pszCredTarget, parent, is_config) + wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, wxWindow* parent, bool is_config = false) : + wxEAPCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, parent, is_config) { // Load and set icon. winstd::library lib_shell32; @@ -875,7 +869,7 @@ public: bool layout = false; if (!m_prov.m_lbl_alt_credential.empty()) { m_credentials_label->SetLabel(m_prov.m_lbl_alt_credential); - m_credentials_label->Wrap( 445 ); + m_credentials_label->Wrap( 440 ); layout = true; } diff --git a/lib/EAPBase_UI/res/wxEAP_UI.cpp b/lib/EAPBase_UI/res/wxEAP_UI.cpp index 1efe615..72f3e36 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.cpp +++ b/lib/EAPBase_UI/res/wxEAP_UI.cpp @@ -239,7 +239,7 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare sb_credentials_vert = new wxBoxSizer( wxVERTICAL ); m_credentials_label = new wxStaticText( sb_credentials->GetStaticBox(), wxID_ANY, _("Manage credentials used to connect."), wxDefaultPosition, wxDefaultSize, 0 ); - m_credentials_label->Wrap( 445 ); + m_credentials_label->Wrap( 440 ); sb_credentials_vert->Add( m_credentials_label, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* sb_cred_radio; @@ -364,7 +364,7 @@ wxEAPCredentialsPassPanelBase::wxEAPCredentialsPassPanelBase( wxWindow* parent, sb_credentials_vert = new wxBoxSizer( wxVERTICAL ); m_credentials_label = new wxStaticText( sb_credentials->GetStaticBox(), wxID_ANY, _("Please provide your user ID and password."), wxDefaultPosition, wxDefaultSize, 0 ); - m_credentials_label->Wrap( 445 ); + m_credentials_label->Wrap( 440 ); sb_credentials_vert->Add( m_credentials_label, 0, wxALL|wxEXPAND, 5 ); wxFlexGridSizer* sb_credentials_tbl; @@ -429,7 +429,7 @@ wxEAPProviderContactInfoPanelBase::wxEAPProviderContactInfoPanelBase( wxWindow* sb_provider_contact_vert = new wxBoxSizer( wxVERTICAL ); m_provider_contact_label = new wxStaticText( sb_provider_contact->GetStaticBox(), wxID_ANY, _("Describe your organization to customize user prompts. When organization is introduced, end-users find program messages easier to understand and act."), wxDefaultPosition, wxDefaultSize, 0 ); - m_provider_contact_label->Wrap( 445 ); + m_provider_contact_label->Wrap( 440 ); sb_provider_contact_vert->Add( m_provider_contact_label, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* sb_provider_name; @@ -533,9 +533,25 @@ wxEAPProviderIDPanelBase::wxEAPProviderIDPanelBase( wxWindow* parent, wxWindowID sb_provider_id_vert = new wxBoxSizer( wxVERTICAL ); m_provider_id_label_outer = new wxStaticText( sb_provider_id->GetStaticBox(), wxID_ANY, _("Assign your organization a unique ID to allow sharing the same credential set across different network profiles."), wxDefaultPosition, wxDefaultSize, 0 ); - m_provider_id_label_outer->Wrap( 445 ); + m_provider_id_label_outer->Wrap( 440 ); sb_provider_id_vert->Add( m_provider_id_label_outer, 0, wxALL|wxEXPAND, 5 ); + wxBoxSizer* sb_provider_namespace; + sb_provider_namespace = new wxBoxSizer( wxVERTICAL ); + + m_provider_namespace_label = new wxStaticText( sb_provider_id->GetStaticBox(), wxID_ANY, _("&Namespace:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_provider_namespace_label->Wrap( -1 ); + sb_provider_namespace->Add( m_provider_namespace_label, 0, wxBOTTOM, 5 ); + + wxString m_provider_namespaceChoices[] = { _("urn:RFC4282:realm"), _("urn:uuid") }; + int m_provider_namespaceNChoices = sizeof( m_provider_namespaceChoices ) / sizeof( wxString ); + m_provider_namespace = new wxChoice( sb_provider_id->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_provider_namespaceNChoices, m_provider_namespaceChoices, 0 ); + m_provider_namespace->SetSelection( 0 ); + sb_provider_namespace->Add( m_provider_namespace, 0, wxEXPAND, 5 ); + + + sb_provider_id_vert->Add( sb_provider_namespace, 0, wxEXPAND|wxALL, 5 ); + wxBoxSizer* sb_provider_id_inner; sb_provider_id_inner = new wxBoxSizer( wxVERTICAL ); @@ -546,11 +562,7 @@ wxEAPProviderIDPanelBase::wxEAPProviderIDPanelBase( wxWindow* parent, wxWindowID m_provider_id = new wxTextCtrl( sb_provider_id->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_provider_id->SetToolTip( _("Your organization ID to assign same credentials from other profiles") ); - sb_provider_id_inner->Add( m_provider_id, 0, wxEXPAND|wxBOTTOM, 5 ); - - m_provider_id_note = new wxStaticText( sb_provider_id->GetStaticBox(), wxID_ANY, _("(Examples: contoso.com, DOT-UK, etc.)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_provider_id_note->Wrap( -1 ); - sb_provider_id_inner->Add( m_provider_id_note, 0, wxALIGN_RIGHT, 5 ); + sb_provider_id_inner->Add( m_provider_id, 0, wxEXPAND, 5 ); sb_provider_id_vert->Add( sb_provider_id_inner, 0, wxEXPAND|wxALL, 5 ); @@ -585,7 +597,7 @@ wxEAPProviderLockPanelBase::wxEAPProviderLockPanelBase( wxWindow* parent, wxWind sb_provider_lock_vert = new wxBoxSizer( wxVERTICAL ); m_provider_lock_label = new wxStaticText( sb_provider_lock->GetStaticBox(), wxID_ANY, _("Your configuration can be locked to prevent accidental modification by end-users. Users will only be allowed to enter credentials."), wxDefaultPosition, wxDefaultSize, 0 ); - m_provider_lock_label->Wrap( 445 ); + m_provider_lock_label->Wrap( 440 ); sb_provider_lock_vert->Add( m_provider_lock_label, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* sb_provider_lock_inner; diff --git a/lib/EAPBase_UI/res/wxEAP_UI.fbp b/lib/EAPBase_UI/res/wxEAP_UI.fbp index bd4b4ba..030a955 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.fbp +++ b/lib/EAPBase_UI/res/wxEAP_UI.fbp @@ -1623,7 +1623,7 @@ - 445 + 440 @@ -2579,7 +2579,7 @@ - 445 + 440 @@ -3281,7 +3281,7 @@ - 445 + 440 @@ -4431,7 +4431,7 @@ - 445 + 440 @@ -4457,6 +4457,188 @@ + + 5 + wxEXPAND|wxALL + 0 + + + sb_provider_namespace + wxVERTICAL + none + + 5 + wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + &Namespace: + + 0 + + + 0 + + 1 + m_provider_namespace_label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "urn:RFC4282:realm" "urn:uuid" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_provider_namespace + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND|wxALL @@ -4551,7 +4733,7 @@ 5 - wxEXPAND|wxBOTTOM + wxEXPAND 0 1 @@ -4640,89 +4822,6 @@ - - 5 - wxALIGN_RIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - (Examples: contoso.com, DOT-UK, etc.) - - 0 - - - 0 - - 1 - m_provider_id_note - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4947,7 +5046,7 @@ - 445 + 440 diff --git a/lib/EAPBase_UI/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h index cafa5f3..0d941fb 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.h +++ b/lib/EAPBase_UI/res/wxEAP_UI.h @@ -35,6 +35,7 @@ class wxEAPBannerPanel; #include #include #include +#include /////////////////////////////////////////////////////////////////////////// @@ -251,9 +252,10 @@ class wxEAPProviderIDPanelBase : public wxPanel protected: wxStaticBitmap* m_provider_id_icon; wxStaticText* m_provider_id_label_outer; + wxStaticText* m_provider_namespace_label; + wxChoice* m_provider_namespace; wxStaticText* m_provider_id_label; wxTextCtrl* m_provider_id; - wxStaticText* m_provider_id_note; public: diff --git a/lib/EAPBase_UI/src/EAP_UI.cpp b/lib/EAPBase_UI/src/EAP_UI.cpp index 5aecfb1..b023791 100644 --- a/lib/EAPBase_UI/src/EAP_UI.cpp +++ b/lib/EAPBase_UI/src/EAP_UI.cpp @@ -164,8 +164,7 @@ void wxEAPNotePanel::CreateContactFields(const eap::config_provider &prov) { if (!prov.m_help_email.empty() || !prov.m_help_web.empty() || !prov.m_help_phone.empty()) { m_provider_notice = new wxStaticText(this, wxID_ANY, wxString::Format(_("For additional help and instructions, please contact %s at:"), - !prov.m_name.empty() ? prov.m_name.c_str() : - !prov.m_id .empty() ? winstd::tstring_printf(_("your %ls provider"), prov.m_id.c_str()).c_str() : _("your provider")), wxDefaultPosition, wxDefaultSize, 0); + !prov.m_name.empty() ? prov.m_name.c_str() : _("your provider")), wxDefaultPosition, wxDefaultSize, 0); m_provider_notice->Wrap(449); m_note_vert->Add(m_provider_notice, 0, wxUP|wxLEFT|wxRIGHT|wxEXPAND, 5); @@ -227,8 +226,7 @@ wxEAPProviderLockedPanel::wxEAPProviderLockedPanel(const eap::config_provider &p m_note_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(48))); m_note_label->SetLabel(wxString::Format(_("%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification."), - !prov.m_name.empty() ? prov.m_name.c_str() : - !prov.m_id .empty() ? winstd::tstring_printf(_("Your %ls provider"), prov.m_id.c_str()).c_str() : _("Your provider"))); + !prov.m_name.empty() ? prov.m_name.c_str() : _("Your provider"))); m_note_label->Wrap(449); CreateContactFields(prov); @@ -343,7 +341,8 @@ wxEAPProviderIDPanel::wxEAPProviderIDPanel(eap::config_provider &prov, wxWindow* bool wxEAPProviderIDPanel::TransferDataToWindow() { - m_provider_id->SetValue(m_prov.m_id); + m_provider_namespace->SetStringSelection(m_prov.m_namespace); + m_provider_id ->SetValue(m_prov.m_id); return wxEAPProviderIDPanelBase::TransferDataToWindow(); } @@ -353,7 +352,8 @@ bool wxEAPProviderIDPanel::TransferDataFromWindow() { wxCHECK(wxEAPProviderIDPanelBase::TransferDataFromWindow(), false); - m_prov.m_id = m_provider_id->GetValue(); + m_prov.m_namespace = m_provider_namespace->GetStringSelection(); + m_prov.m_id = m_provider_id ->GetValue(); return true; } diff --git a/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h b/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h index 16af1c1..3ae1204 100644 --- a/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h +++ b/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h @@ -51,7 +51,7 @@ public: /// /// Constructs a configuration panel /// - wxMSCHAPv2ConfigPanel(const eap::config_provider &prov, eap::config_method_mschapv2 &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + wxMSCHAPv2ConfigPanel(const eap::config_provider &prov, eap::config_method_mschapv2 &cfg, wxWindow* parent); /// /// Destructs the configuration panel diff --git a/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp b/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp index c45d225..69cd00b 100644 --- a/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp +++ b/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp @@ -25,12 +25,12 @@ // wxMSCHAPv2ConfigPanel ////////////////////////////////////////////////////////////////////// -wxMSCHAPv2ConfigPanel::wxMSCHAPv2ConfigPanel(const eap::config_provider &prov, eap::config_method_mschapv2 &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent) +wxMSCHAPv2ConfigPanel::wxMSCHAPv2ConfigPanel(const eap::config_provider &prov, eap::config_method_mschapv2 &cfg, wxWindow* parent) : wxPanel(parent) { wxBoxSizer* sb_content; sb_content = new wxBoxSizer( wxVERTICAL ); - m_credentials = new wxMSCHAPv2CredentialsConfigPanel(prov, cfg, pszCredTarget, this); + m_credentials = new wxMSCHAPv2CredentialsConfigPanel(prov, cfg, this); sb_content->Add(m_credentials, 0, wxEXPAND, 5); this->SetSizer(sb_content); diff --git a/lib/PAP_UI/include/PAP_UI.h b/lib/PAP_UI/include/PAP_UI.h index 374f8cc..3747855 100644 --- a/lib/PAP_UI/include/PAP_UI.h +++ b/lib/PAP_UI/include/PAP_UI.h @@ -51,7 +51,7 @@ public: /// /// Constructs a configuration panel /// - wxPAPConfigPanel(const eap::config_provider &prov, eap::config_method_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + wxPAPConfigPanel(const eap::config_provider &prov, eap::config_method_pap &cfg, wxWindow* parent); /// /// Destructs the configuration panel diff --git a/lib/PAP_UI/src/PAP_UI.cpp b/lib/PAP_UI/src/PAP_UI.cpp index 1986f60..e8a7f6a 100644 --- a/lib/PAP_UI/src/PAP_UI.cpp +++ b/lib/PAP_UI/src/PAP_UI.cpp @@ -25,12 +25,12 @@ // wxPAPConfigPanel ////////////////////////////////////////////////////////////////////// -wxPAPConfigPanel::wxPAPConfigPanel(const eap::config_provider &prov, eap::config_method_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent) +wxPAPConfigPanel::wxPAPConfigPanel(const eap::config_provider &prov, eap::config_method_pap &cfg, wxWindow* parent) : wxPanel(parent) { wxBoxSizer* sb_content; sb_content = new wxBoxSizer( wxVERTICAL ); - m_credentials = new wxPAPCredentialsConfigPanel(prov, cfg, pszCredTarget, this); + m_credentials = new wxPAPCredentialsConfigPanel(prov, cfg, this); sb_content->Add(m_credentials, 0, wxEXPAND, 5); this->SetSizer(sb_content); diff --git a/lib/TLS_UI/include/TLS_UI.h b/lib/TLS_UI/include/TLS_UI.h index f0073cc..e80859a 100644 --- a/lib/TLS_UI/include/TLS_UI.h +++ b/lib/TLS_UI/include/TLS_UI.h @@ -254,14 +254,13 @@ public: /// /// Constructs a configuration panel /// - /// \param[in] prov Provider configuration data - /// \param[in] cfg Configuration data - /// \param[inout] cred Credentials data - /// \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 - /// \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] prov Provider configuration data + /// \param[in] cfg Configuration data + /// \param[inout] cred Credentials data + /// \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. /// - wxTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, eap::credentials_tls &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false); + wxTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, eap::credentials_tls &cred, wxWindow* parent, bool is_config = false); protected: /// \cond internal @@ -315,7 +314,7 @@ public: /// /// Constructs a configuration panel /// - wxTLSConfigPanel(const eap::config_provider &prov, eap::config_method_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + wxTLSConfigPanel(const eap::config_provider &prov, eap::config_method_tls &cfg, wxWindow* parent); /// /// Destructs the configuration panel diff --git a/lib/TLS_UI/res/wxTLS_UI.cpp b/lib/TLS_UI/res/wxTLS_UI.cpp index 75b31dd..0147793 100644 --- a/lib/TLS_UI/res/wxTLS_UI.cpp +++ b/lib/TLS_UI/res/wxTLS_UI.cpp @@ -26,7 +26,7 @@ wxEAPTLSServerTrustConfigPanelBase::wxEAPTLSServerTrustConfigPanelBase( wxWindow sb_server_trust_vert = new wxBoxSizer( wxVERTICAL ); m_server_trust_label = new wxStaticText( sb_server_trust->GetStaticBox(), wxID_ANY, _("Describe the servers you trust to prevent credential interception in case of man-in-the-middle attacks."), wxDefaultPosition, wxDefaultSize, 0 ); - m_server_trust_label->Wrap( 445 ); + m_server_trust_label->Wrap( 440 ); sb_server_trust_vert->Add( m_server_trust_label, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* sb_root_ca; @@ -129,7 +129,7 @@ wxTLSCredentialsPanelBase::wxTLSCredentialsPanelBase( wxWindow* parent, wxWindow sb_credentials_vert = new wxBoxSizer( wxVERTICAL ); m_credentials_label = new wxStaticText( sb_credentials->GetStaticBox(), wxID_ANY, _("Please select your client certificate to use for authentication."), wxDefaultPosition, wxDefaultSize, 0 ); - m_credentials_label->Wrap( 445 ); + m_credentials_label->Wrap( 440 ); sb_credentials_vert->Add( m_credentials_label, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* sb_cert_radio; diff --git a/lib/TLS_UI/res/wxTLS_UI.fbp b/lib/TLS_UI/res/wxTLS_UI.fbp index 371d02d..70b72ba 100644 --- a/lib/TLS_UI/res/wxTLS_UI.fbp +++ b/lib/TLS_UI/res/wxTLS_UI.fbp @@ -242,7 +242,7 @@ - 445 + 440 @@ -1215,7 +1215,7 @@ - 445 + 440 diff --git a/lib/TLS_UI/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp index c1b2c42..dd6e1e0 100644 --- a/lib/TLS_UI/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -311,8 +311,8 @@ bool wxFQDNListValidator::Parse(const wxString &val_in, size_t i_start, size_t i // wxTLSCredentialsPanel ////////////////////////////////////////////////////////////////////// -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) : - wxEAPCredentialsPanel(prov, cfg, cred, pszCredTarget, parent, is_config) +wxTLSCredentialsPanel::wxTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, eap::credentials_tls &cred, wxWindow* parent, bool is_config) : + wxEAPCredentialsPanel(prov, cfg, cred, parent, is_config) { // Load and set icon. winstd::library lib_shell32; @@ -568,7 +568,7 @@ bool wxTLSServerTrustPanel::AddRootCA(PCCERT_CONTEXT cert) // wxTLSConfigPanel ////////////////////////////////////////////////////////////////////// -wxTLSConfigPanel::wxTLSConfigPanel(const eap::config_provider &prov, eap::config_method_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : +wxTLSConfigPanel::wxTLSConfigPanel(const eap::config_provider &prov, eap::config_method_tls &cfg, wxWindow* parent) : m_prov(prov), m_cfg(cfg), wxPanel(parent) @@ -579,7 +579,7 @@ wxTLSConfigPanel::wxTLSConfigPanel(const eap::config_provider &prov, eap::config m_server_trust = new wxTLSServerTrustPanel(prov, cfg, this); sb_content->Add(m_server_trust, 0, wxDOWN|wxEXPAND, 5); - m_credentials = new wxTLSCredentialsConfigPanel(prov, cfg, pszCredTarget, this); + m_credentials = new wxTLSCredentialsConfigPanel(prov, cfg, this); sb_content->Add(m_credentials, 0, wxUP|wxEXPAND, 5); this->SetSizer(sb_content); diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index db35368..1d8bae0 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -206,15 +206,15 @@ EAP_SESSION_HANDLE eap::peer_ttls::begin_session( for (config_connection::provider_list::iterator cfg_prov = s->m_cfg.m_providers.begin(), cfg_prov_end = s->m_cfg.m_providers.end();; ++cfg_prov) { if (cfg_prov != cfg_prov_end) { - if (_wcsicmp(cfg_prov->m_id.c_str(), s->m_cred.m_id.c_str()) == 0) { + if (s->m_cred.match(*cfg_prov)) { // Matching provider found. if (cfg_prov->m_methods.empty()) - throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->m_id.c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str()); cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); break; } } else - throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider ID within this connection configuration (provider ID: %ls).", s->m_cred.m_id.c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", s->m_cred.get_id().c_str()).c_str()); } // We have configuration, we have credentials, create method. @@ -360,9 +360,11 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials( user_impersonator impersonating(hTokenImpersonateUser); for (config_connection::provider_list::const_iterator cfg_prov = cfg.m_providers.cbegin(), cfg_prov_end = cfg.m_providers.cend(); cfg_prov != cfg_prov_end; ++cfg_prov) { + wstring target_name(std::move(cfg_prov->get_id())); + // Get method configuration. if (cfg_prov->m_methods.empty()) { - log_event(&EAPMETHOD_TRACE_EVT_CRED_NO_METHOD, event_data(cfg_prov->m_id), event_data::blank); + log_event(&EAPMETHOD_TRACE_EVT_CRED_NO_METHOD, event_data(target_name), event_data::blank); continue; } const config_method_ttls *cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); @@ -372,11 +374,11 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials( credentials_ttls *cred = (credentials_ttls*)cfg_method->make_credentials(); cred_out.m_cred.reset(cred); #ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE - bool is_own = cred_in.m_cred && _wcsicmp(cred_in.m_id.c_str(), cfg_prov->m_id.c_str()) == 0; + bool is_own = cred_in.m_cred && cred_in.match(*cfg_prov); #endif // Combine outer credentials. - LPCTSTR target_name = (dwFlags & EAP_FLAG_GUEST_ACCESS) == 0 ? cfg_prov->m_id.c_str() : NULL; + LPCTSTR _target_name = (dwFlags & EAP_FLAG_GUEST_ACCESS) == 0 ? target_name.c_str() : NULL; eap::credentials::source_t src_outer = cred->credentials_tls::combine( #ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE is_own ? cred_in.m_cred.get() : NULL, @@ -384,9 +386,9 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials( NULL, #endif *cfg_method, - target_name); + _target_name); if (src_outer == eap::credentials::source_unknown) { - log_event(&EAPMETHOD_TRACE_EVT_CRED_UNKNOWN3, event_data(cfg_prov->m_id), event_data((unsigned int)eap_type_tls), event_data::blank); + log_event(&EAPMETHOD_TRACE_EVT_CRED_UNKNOWN3, event_data(target_name), event_data((unsigned int)eap_type_tls), event_data::blank); continue; } @@ -398,9 +400,9 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials( NULL, #endif *cfg_method->m_inner, - target_name); + _target_name); if (src_inner == eap::credentials::source_unknown) { - log_event(&EAPMETHOD_TRACE_EVT_CRED_UNKNOWN3, event_data(cfg_prov->m_id), event_data((unsigned int)cfg_method->m_inner->get_method_id()), event_data::blank); + log_event(&EAPMETHOD_TRACE_EVT_CRED_UNKNOWN3, event_data(target_name), event_data((unsigned int)cfg_method->m_inner->get_method_id()), event_data::blank); continue; } @@ -409,18 +411,19 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials( if ((dwFlags & EAP_FLAG_MACHINE_AUTH) == 0) { if (cfg_method->m_auth_failed) { // Outer: Credentials failed on last connection attempt. - log_event(&EAPMETHOD_TRACE_EVT_CRED_PROBLEM1, event_data(cfg_prov->m_id), event_data((unsigned int)eap_type_tls), event_data::blank); + log_event(&EAPMETHOD_TRACE_EVT_CRED_PROBLEM1, event_data(target_name), event_data((unsigned int)eap_type_tls), event_data::blank); continue; } if (cfg_method->m_inner->m_auth_failed) { // Inner: Credentials failed on last connection attempt. - log_event(&EAPMETHOD_TRACE_EVT_CRED_PROBLEM1, event_data(cfg_prov->m_id), event_data((unsigned int)cfg_method->m_inner->get_method_id()), event_data::blank); + log_event(&EAPMETHOD_TRACE_EVT_CRED_PROBLEM1, event_data(target_name), event_data((unsigned int)cfg_method->m_inner->get_method_id()), event_data::blank); continue; } } - cred_out.m_id = cfg_prov->m_id; + cred_out.m_namespace = cfg_prov->m_namespace; + cred_out.m_id = cfg_prov->m_id; return cfg_method; } diff --git a/lib/TTLS_UI/include/TTLS_UI.h b/lib/TTLS_UI/include/TTLS_UI.h index b9927e0..87ca6f5 100644 --- a/lib/TTLS_UI/include/TTLS_UI.h +++ b/lib/TTLS_UI/include/TTLS_UI.h @@ -79,12 +79,11 @@ public: /// /// Constructs a configuration window /// - /// \param[in] prov Provider configuration data - /// \param[inout] cfg Configuration data - /// \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 + /// \param[in] prov Provider configuration data + /// \param[inout] cfg Configuration data + /// \param[in] parent Parent window /// - wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, wxWindow* parent); /// /// Destructs the configuration window @@ -119,14 +118,13 @@ public: /// /// Constructs a configuration panel /// - /// \param[in] prov Provider configuration data - /// \param[in] cfg Configuration data - /// \param[inout] cred Credentials data - /// \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 - /// \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] prov Provider configuration data + /// \param[in] cfg Configuration data + /// \param[inout] cred Credentials data + /// \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. /// - wxTTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method &cfg, eap::credentials &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false); + wxTTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method &cfg, eap::credentials &cred, wxWindow* parent, bool is_config = false); /// /// Destructs the configuration panel diff --git a/lib/TTLS_UI/res/wxTTLS_UI.cpp b/lib/TTLS_UI/res/wxTTLS_UI.cpp index eec016b..b2be307 100644 --- a/lib/TTLS_UI/res/wxTTLS_UI.cpp +++ b/lib/TTLS_UI/res/wxTTLS_UI.cpp @@ -26,7 +26,7 @@ wxTTLSConfigPanelBase::wxTTLSConfigPanelBase( wxWindow* parent, wxWindowID id, c sb_outer_identity_vert = new wxBoxSizer( wxVERTICAL ); m_outer_identity_label = new wxStaticText( sb_outer_identity->GetStaticBox(), wxID_ANY, _("Select the user ID supplicant introduces itself as to authenticator:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_outer_identity_label->Wrap( 445 ); + m_outer_identity_label->Wrap( 440 ); sb_outer_identity_vert->Add( m_outer_identity_label, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* sb_outer_identity_radio; diff --git a/lib/TTLS_UI/res/wxTTLS_UI.fbp b/lib/TTLS_UI/res/wxTTLS_UI.fbp index 87741c0..b598dcd 100644 --- a/lib/TTLS_UI/res/wxTTLS_UI.fbp +++ b/lib/TTLS_UI/res/wxTTLS_UI.fbp @@ -242,7 +242,7 @@ - 445 + 440 diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index 6ad3619..74b5269 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -185,9 +185,11 @@ void eap::peer_ttls_ui::invoke_identity_ui( bool combined = false; wxEAPCredentialsConnectionDialog dlg(&parent); for (config_connection::provider_list::iterator cfg_prov = cfg.m_providers.begin(), cfg_prov_end = cfg.m_providers.end(); cfg_prov != cfg_prov_end; ++cfg_prov) { + wstring target_name(std::move(cfg_prov->get_id())); + // Get method configuration. if (cfg_prov->m_methods.empty()) { - log_event(&EAPMETHOD_TRACE_EVT_CRED_NO_METHOD, event_data(cfg_prov->m_id), event_data::blank); + log_event(&EAPMETHOD_TRACE_EVT_CRED_NO_METHOD, event_data(target_name), event_data::blank); continue; } config_method_ttls *cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); @@ -195,15 +197,16 @@ void eap::peer_ttls_ui::invoke_identity_ui( // Prepare new set of credentials for given provider. credentials_connection cred_method(*this, cfg); - cred_method.m_id = cfg_prov->m_id; + cred_method.m_namespace = cfg_prov->m_namespace; + cred_method.m_id = cfg_prov->m_id; credentials_ttls *_cred_method = (credentials_ttls*)cfg_method->make_credentials(); cred_method.m_cred.reset(_cred_method); #ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE - bool is_own = cred_in.m_cred && _wcsicmp(cred_in.m_id.c_str(), cfg_prov->m_id.c_str()) == 0; + bool is_own = cred_in.m_cred && cred_in.match(*cfg_prov); #endif // Combine outer credentials. - LPCTSTR target_name = (dwFlags & EAP_FLAG_GUEST_ACCESS) == 0 ? cfg_prov->m_id.c_str() : NULL; + LPCTSTR _target_name = (dwFlags & EAP_FLAG_GUEST_ACCESS) == 0 ? target_name.c_str() : NULL; eap::credentials::source_t src_outer = _cred_method->credentials_tls::combine( #ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE is_own ? cred_in.m_cred.get() : NULL, @@ -211,7 +214,7 @@ void eap::peer_ttls_ui::invoke_identity_ui( NULL, #endif *cfg_method, - target_name); + _target_name); // Combine inner credentials. eap::credentials::source_t src_inner = _cred_method->m_inner->combine( @@ -221,7 +224,7 @@ void eap::peer_ttls_ui::invoke_identity_ui( NULL, #endif *cfg_method->m_inner, - target_name); + _target_name); if (dwFlags & EAP_FLAG_GUEST_ACCESS) { // Disable credential saving for guests. @@ -230,7 +233,7 @@ void eap::peer_ttls_ui::invoke_identity_ui( } // Create method credentials panel. - wxTTLSCredentialsPanel *panel = new wxTTLSCredentialsPanel(*cfg_prov, *cfg_method, *_cred_method, cfg_prov->m_id.c_str(), dlg.m_providers); + wxTTLSCredentialsPanel *panel = new wxTTLSCredentialsPanel(*cfg_prov, *cfg_method, *_cred_method, dlg.m_providers); // Set "Remember" checkboxes according to credential source, panel->m_outer_cred->SetRemember(src_outer == eap::credentials::source_storage); @@ -262,11 +265,12 @@ void eap::peer_ttls_ui::invoke_identity_ui( cfg_method = res.first; cred_out = res.second; credentials_ttls *_cred_out = dynamic_cast(cred_out.m_cred.get()); + wstring target_name(std::move(cred_out.get_id())); // Write credentials to credential manager. if (panel->m_outer_cred->GetRemember()) { try { - _cred_out->credentials_tls::store(cred_out.m_id.c_str()); + _cred_out->credentials_tls::store(target_name.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 (...) { @@ -276,7 +280,7 @@ void eap::peer_ttls_ui::invoke_identity_ui( if (panel->m_inner_cred->GetRemember()) { try { - _cred_out->m_inner->store(cred_out.m_id.c_str()); + _cred_out->m_inner->store(target_name.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 (...) { diff --git a/lib/TTLS_UI/src/TTLS_UI.cpp b/lib/TTLS_UI/src/TTLS_UI.cpp index 55567ca..682cf6c 100644 --- a/lib/TTLS_UI/src/TTLS_UI.cpp +++ b/lib/TTLS_UI/src/TTLS_UI.cpp @@ -93,7 +93,7 @@ void wxTTLSConfigPanel::OnUpdateUI(wxUpdateUIEvent& /*event*/) // wxTTLSConfigWindow ////////////////////////////////////////////////////////////////////// -wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : +wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, wxWindow* parent) : m_cfg((eap::config_method_ttls&)cfg), m_cfg_pap(cfg.m_module), m_cfg_mschapv2(cfg.m_module), @@ -112,9 +112,9 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_m m_inner_type = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxCHB_DEFAULT); m_inner_type->SetToolTip( _("Select inner authentication method from the list") ); - wxPAPConfigPanel *panel_pap = new wxPAPConfigPanel(m_prov, m_cfg_pap, pszCredTarget, m_inner_type); + wxPAPConfigPanel *panel_pap = new wxPAPConfigPanel(m_prov, m_cfg_pap, m_inner_type); m_inner_type->AddPage(panel_pap, _("PAP")); - wxMSCHAPv2ConfigPanel *panel_mschapv2 = new wxMSCHAPv2ConfigPanel(m_prov, m_cfg_mschapv2, pszCredTarget, m_inner_type); + wxMSCHAPv2ConfigPanel *panel_mschapv2 = new wxMSCHAPv2ConfigPanel(m_prov, m_cfg_mschapv2, m_inner_type); m_inner_type->AddPage(panel_mschapv2, _("MSCHAPv2")); sb_content->Add(m_inner_type, 0, wxALL|wxEXPAND, 5); @@ -128,7 +128,7 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_m 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, pszCredTarget, this); + m_tls = new wxTLSConfigPanel(m_prov, m_cfg, this); sb_content->Add(m_tls, 0, wxALL|wxEXPAND, 5); wxSize size = sb_content->CalcMin(); @@ -224,7 +224,7 @@ void wxTTLSConfigWindow::OnUpdateUI(wxUpdateUIEvent& /*event*/) // wxTTLSCredentialsPanel ////////////////////////////////////////////////////////////////////// -wxTTLSCredentialsPanel::wxTTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method &cfg, eap::credentials &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) : +wxTTLSCredentialsPanel::wxTTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method &cfg, eap::credentials &cred, wxWindow* parent, bool is_config) : m_prov(prov), m_cfg((eap::config_method_ttls&)cfg), wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize) @@ -246,7 +246,7 @@ wxTTLSCredentialsPanel::wxTTLSCredentialsPanel(const eap::config_provider &prov, if (cfg_inner_pap) { eap::credentials_ttls &cred_ttls = (eap::credentials_ttls&)cred; if (!cred_ttls.m_inner) cred_ttls.m_inner.reset(new eap::credentials_pap(cred.m_module)); - m_inner_cred = new wxPAPCredentialsPanel(m_prov, *cfg_inner_pap, *(eap::credentials_pap*)cred_ttls.m_inner.get(), pszCredTarget, this, is_config); + m_inner_cred = new wxPAPCredentialsPanel(m_prov, *cfg_inner_pap, *(eap::credentials_pap*)cred_ttls.m_inner.get(), this, is_config); sb_content->Add(m_inner_cred, 0, wxALL|wxEXPAND, 5); } else assert(0); // Unsupported inner authentication method type. @@ -261,7 +261,7 @@ wxTTLSCredentialsPanel::wxTTLSCredentialsPanel(const eap::config_provider &prov, if (m_cfg.m_auth_failed) sb_content->Add(new wxEAPCredentialWarningPanel(m_prov, this), 0, wxALL|wxEXPAND, 5); - m_outer_cred = new wxTLSCredentialsPanel(m_prov, (const eap::config_method_tls&)m_cfg, (eap::credentials_tls&)cred, pszCredTarget, this, is_config); + m_outer_cred = new wxTLSCredentialsPanel(m_prov, (const eap::config_method_tls&)m_cfg, (eap::credentials_tls&)cred, this, is_config); sb_content->Add(m_outer_cred, 0, wxALL|wxEXPAND, 5); this->SetSizer(sb_content);