eap::config_method_eaphost::get_method_str() finished
This commit is contained in:
parent
65ea47eb4e
commit
dd55dfd24d
@ -150,8 +150,31 @@ namespace eap
|
|||||||
///
|
///
|
||||||
virtual credentials* make_credentials() const;
|
virtual credentials* make_credentials() const;
|
||||||
|
|
||||||
public:
|
///
|
||||||
|
/// Returns method EAP_METHOD_TYPE
|
||||||
|
///
|
||||||
|
inline const EAP_METHOD_TYPE& get_type() const
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set method EAP_METHOD_TYPE
|
||||||
|
///
|
||||||
|
inline void set_type(_In_ const EAP_METHOD_TYPE &type)
|
||||||
|
{
|
||||||
|
m_type = type;
|
||||||
|
update_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void update_type();
|
||||||
|
|
||||||
|
protected:
|
||||||
EAP_METHOD_TYPE m_type; ///< EapHost method type: (EAP type, vendor ID, vendor type, author ID) tuple
|
EAP_METHOD_TYPE m_type; ///< EapHost method type: (EAP type, vendor ID, vendor type, author ID) tuple
|
||||||
|
std::wstring m_type_str; ///< EAP method type as a string
|
||||||
|
|
||||||
|
public:
|
||||||
sanitizing_blob m_cfg_blob; ///< Method configuration BLOB
|
sanitizing_blob m_cfg_blob; ///< Method configuration BLOB
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ using namespace winstd;
|
|||||||
// eap::config_method_eaphost
|
// eap::config_method_eaphost
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
eap::config_method_eaphost::config_method_eaphost(_In_ module &mod, _In_ unsigned int level) : config_method(mod, level)
|
eap::config_method_eaphost::config_method_eaphost(_In_ module &mod, _In_ unsigned int level) :
|
||||||
|
config_method(mod, level),
|
||||||
|
m_type_str(L"EapHost")
|
||||||
{
|
{
|
||||||
memset(&m_type, 0, sizeof(EAP_METHOD_TYPE));
|
memset(&m_type, 0, sizeof(EAP_METHOD_TYPE));
|
||||||
}
|
}
|
||||||
@ -36,6 +38,7 @@ eap::config_method_eaphost::config_method_eaphost(_In_ module &mod, _In_ unsigne
|
|||||||
|
|
||||||
eap::config_method_eaphost::config_method_eaphost(_In_ const config_method_eaphost &other) :
|
eap::config_method_eaphost::config_method_eaphost(_In_ const config_method_eaphost &other) :
|
||||||
m_type (other.m_type ),
|
m_type (other.m_type ),
|
||||||
|
m_type_str (other.m_type_str),
|
||||||
m_cfg_blob (other.m_cfg_blob),
|
m_cfg_blob (other.m_cfg_blob),
|
||||||
config_method(other )
|
config_method(other )
|
||||||
{
|
{
|
||||||
@ -44,6 +47,7 @@ eap::config_method_eaphost::config_method_eaphost(_In_ const config_method_eapho
|
|||||||
|
|
||||||
eap::config_method_eaphost::config_method_eaphost(_Inout_ config_method_eaphost &&other) :
|
eap::config_method_eaphost::config_method_eaphost(_Inout_ config_method_eaphost &&other) :
|
||||||
m_type (std::move(other.m_type )),
|
m_type (std::move(other.m_type )),
|
||||||
|
m_type_str (std::move(other.m_type_str)),
|
||||||
m_cfg_blob (std::move(other.m_cfg_blob)),
|
m_cfg_blob (std::move(other.m_cfg_blob)),
|
||||||
config_method(std::move(other ))
|
config_method(std::move(other ))
|
||||||
{
|
{
|
||||||
@ -55,6 +59,7 @@ eap::config_method_eaphost& eap::config_method_eaphost::operator=(_In_ const con
|
|||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
(config_method&)*this = other;
|
(config_method&)*this = other;
|
||||||
m_type = other.m_type;
|
m_type = other.m_type;
|
||||||
|
m_type_str = other.m_type_str;
|
||||||
m_cfg_blob = other.m_cfg_blob;
|
m_cfg_blob = other.m_cfg_blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +72,7 @@ eap::config_method_eaphost& eap::config_method_eaphost::operator=(_Inout_ config
|
|||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
(config_method&&)*this = std::move(other );
|
(config_method&&)*this = std::move(other );
|
||||||
m_type = std::move(other.m_type );
|
m_type = std::move(other.m_type );
|
||||||
|
m_type_str = std::move(other.m_type_str);
|
||||||
m_cfg_blob = std::move(other.m_cfg_blob);
|
m_cfg_blob = std::move(other.m_cfg_blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,12 +129,13 @@ void eap::config_method_eaphost::load(_In_ IXMLDOMNode *pConfigRoot)
|
|||||||
eap_error error;
|
eap_error error;
|
||||||
DWORD dwResult = EapHostPeerConfigXml2Blob(0, pXmlElEapHostConfig, &cfg_data_size, &cfg_data._Myptr, &m_type, &error._Myptr);
|
DWORD dwResult = EapHostPeerConfigXml2Blob(0, pXmlElEapHostConfig, &cfg_data_size, &cfg_data._Myptr, &m_type, &error._Myptr);
|
||||||
if (dwResult == ERROR_SUCCESS) {
|
if (dwResult == ERROR_SUCCESS) {
|
||||||
|
update_type();
|
||||||
const BYTE *_cfg_data = cfg_data.get();
|
const BYTE *_cfg_data = cfg_data.get();
|
||||||
m_cfg_blob.assign(_cfg_data, _cfg_data + cfg_data_size);
|
m_cfg_blob.assign(_cfg_data, _cfg_data + cfg_data_size);
|
||||||
} else if (error)
|
} else if (error)
|
||||||
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerConfigBlob2Xml failed.");
|
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerConfigXml2Blob failed.");
|
||||||
else
|
else
|
||||||
throw win_runtime_error(dwResult, __FUNCTION__ " EapHostPeerConfigBlob2Xml failed.");
|
throw win_runtime_error(dwResult, __FUNCTION__ " EapHostPeerConfigXml2Blob failed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +160,7 @@ size_t eap::config_method_eaphost::get_pk_size() const
|
|||||||
void eap::config_method_eaphost::operator>>(_Inout_ cursor_in &cursor)
|
void eap::config_method_eaphost::operator>>(_Inout_ cursor_in &cursor)
|
||||||
{
|
{
|
||||||
config_method::operator>>(cursor);
|
config_method::operator>>(cursor);
|
||||||
cursor >> m_type ;
|
cursor >> m_type ; update_type();
|
||||||
cursor >> m_cfg_blob;
|
cursor >> m_cfg_blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +173,7 @@ eap_type_t eap::config_method_eaphost::get_method_id() const
|
|||||||
|
|
||||||
const wchar_t* eap::config_method_eaphost::get_method_str() const
|
const wchar_t* eap::config_method_eaphost::get_method_str() const
|
||||||
{
|
{
|
||||||
// TODO: Query registry for EAP method name (PeerFriendlyName using RegLoadMUIString()).
|
return m_type_str.c_str();
|
||||||
return L"EapHost";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -175,3 +181,29 @@ eap::credentials* eap::config_method_eaphost::make_credentials() const
|
|||||||
{
|
{
|
||||||
return new credentials_eaphost(m_module);
|
return new credentials_eaphost(m_module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void eap::config_method_eaphost::update_type()
|
||||||
|
{
|
||||||
|
// Query registry for EAP method name and save it to m_type_str.
|
||||||
|
// get_method_str() can return pointer to static string only, therefore we need to have the method name ready in advance.
|
||||||
|
reg_key key;
|
||||||
|
if (key.open(HKEY_LOCAL_MACHINE,
|
||||||
|
m_type.dwAuthorId == 0 ? tstring_printf(_T("SYSTEM\\CurrentControlSet\\services\\RasMan\\PPP\\EAP\\%u" ), m_type.eapType.type ).c_str() : // Legacy EAP method (RasMan)
|
||||||
|
m_type.eapType.type == 254 ? tstring_printf(_T("SYSTEM\\CurrentControlSet\\services\\EapHost\\Methods\\%u\\%u\\%u\\%u"), m_type.dwAuthorId, m_type.eapType.type, m_type.eapType.dwVendorId, m_type.eapType.dwVendorType).c_str() : // EapHost Expanded Type Peer
|
||||||
|
tstring_printf(_T("SYSTEM\\CurrentControlSet\\services\\EapHost\\Methods\\%u\\%u" ), m_type.dwAuthorId, m_type.eapType.type ).c_str(), // EapHost Peer
|
||||||
|
0,
|
||||||
|
KEY_READ) &&
|
||||||
|
RegLoadMUIStringW(key,
|
||||||
|
m_type.dwAuthorId == 0 ? L"FriendlyName" :
|
||||||
|
L"PeerFriendlyName",
|
||||||
|
m_type_str,
|
||||||
|
0,
|
||||||
|
NULL) == ERROR_SUCCESS)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Query failed. Provide generic name.
|
||||||
|
if (m_type.dwAuthorId == 0 ) sprintf(m_type_str, L"RasMan-%u" , m_type.eapType.type );
|
||||||
|
else if (m_type.eapType.type == 254) sprintf(m_type_str, L"EapHost-%u-%u-%u-%u", m_type.dwAuthorId, m_type.eapType.type, m_type.eapType.dwVendorId, m_type.eapType.dwVendorType);
|
||||||
|
else sprintf(m_type_str, L"EapHost-%u-%u" , m_type.dwAuthorId, m_type.eapType.type );
|
||||||
|
}
|
||||||
|
@ -288,7 +288,7 @@ eap::credentials::source_t eap::credentials_eaphost::combine(
|
|||||||
DWORD dwResult = EapHostPeerGetIdentity(
|
DWORD dwResult = EapHostPeerGetIdentity(
|
||||||
0,
|
0,
|
||||||
dwFlags,
|
dwFlags,
|
||||||
cfg_eaphost->m_type,
|
cfg_eaphost->get_type(),
|
||||||
(DWORD)cfg_eaphost->m_cfg_blob.size(), cfg_eaphost->m_cfg_blob.data(),
|
(DWORD)cfg_eaphost->m_cfg_blob.size(), cfg_eaphost->m_cfg_blob.data(),
|
||||||
src != source_unknown ? (DWORD)m_cred_blob.size() : 0, src != source_unknown ? m_cred_blob.data() : NULL,
|
src != source_unknown ? (DWORD)m_cred_blob.size() : 0, src != source_unknown ? m_cred_blob.data() : NULL,
|
||||||
hTokenImpersonateUser,
|
hTokenImpersonateUser,
|
||||||
|
@ -65,7 +65,7 @@ void eap::method_eaphost::begin_session(
|
|||||||
eap_error_runtime error;
|
eap_error_runtime error;
|
||||||
DWORD dwResult = EapHostPeerBeginSession(
|
DWORD dwResult = EapHostPeerBeginSession(
|
||||||
dwFlags,
|
dwFlags,
|
||||||
cfg.m_type,
|
cfg.get_type(),
|
||||||
pAttributeArray,
|
pAttributeArray,
|
||||||
hTokenImpersonateUser,
|
hTokenImpersonateUser,
|
||||||
(DWORD)cfg.m_cfg_blob.size(),
|
(DWORD)cfg.m_cfg_blob.size(),
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "../include/Credentials.h"
|
#include "../include/Credentials.h"
|
||||||
#include "../include/Method.h"
|
#include "../include/Method.h"
|
||||||
|
|
||||||
|
#include <WinStd/Win.h>
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <EapHostError.h> // include after Windows.h
|
#include <EapHostError.h> // include after Windows.h
|
||||||
#include <EapHostPeerTypes.h>
|
#include <EapHostPeerTypes.h>
|
||||||
|
@ -68,7 +68,7 @@ bool wxEapHostMethodConfigPanel::TransferDataToWindow()
|
|||||||
// Find configured method and set its selection and configuration BLOB.
|
// Find configured method and set its selection and configuration BLOB.
|
||||||
for (unsigned int i = 0, n = m_method->GetCount(); i < n; i++) {
|
for (unsigned int i = 0, n = m_method->GetCount(); i < n; i++) {
|
||||||
wxEAPMethodTypeClientData *data = dynamic_cast<wxEAPMethodTypeClientData*>(m_method->GetClientObject(i));
|
wxEAPMethodTypeClientData *data = dynamic_cast<wxEAPMethodTypeClientData*>(m_method->GetClientObject(i));
|
||||||
if (data->m_type == m_cfg.m_type) {
|
if (data->m_type == m_cfg.get_type()) {
|
||||||
m_method->SetSelection(i);
|
m_method->SetSelection(i);
|
||||||
data->m_cfg_blob = m_cfg.m_cfg_blob;
|
data->m_cfg_blob = m_cfg.m_cfg_blob;
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ bool wxEapHostMethodConfigPanel::TransferDataFromWindow()
|
|||||||
NULL;
|
NULL;
|
||||||
if (data) {
|
if (data) {
|
||||||
// Save method selection and configuration.
|
// Save method selection and configuration.
|
||||||
m_cfg.m_type = data->m_type;
|
m_cfg.set_type(data->m_type);
|
||||||
m_cfg.m_cfg_blob = data->m_cfg_blob;
|
m_cfg.m_cfg_blob = data->m_cfg_blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
winstd::eap_error error;
|
winstd::eap_error error;
|
||||||
DWORD dwResult = EapHostPeerInvokeIdentityUI(
|
DWORD dwResult = EapHostPeerInvokeIdentityUI(
|
||||||
0,
|
0,
|
||||||
cfg_inner_eaphost->m_type,
|
cfg_inner_eaphost->get_type(),
|
||||||
dwFlags,
|
dwFlags,
|
||||||
hwndParent,
|
hwndParent,
|
||||||
(DWORD)cfg_inner_eaphost->m_cfg_blob.size(), cfg_inner_eaphost->m_cfg_blob.data(),
|
(DWORD)cfg_inner_eaphost->m_cfg_blob.size(), cfg_inner_eaphost->m_cfg_blob.data(),
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d7d314f128b9ea1b8c7598c180a673fe964135df
|
Subproject commit 0fcfe95e84b3a5ba069df1b38a50709b1917a7e3
|
Loading…
x
Reference in New Issue
Block a user