EapHost support in invoke_interactive_ui() added
This commit is contained in:
parent
260b78025c
commit
6284b6c29e
@ -413,49 +413,83 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
|
|||||||
throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", cred.get_id().c_str()));
|
throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", cred.get_id().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
#ifdef EAP_INNER_EAPHOST
|
||||||
|
auto cfg_inner_eaphost = dynamic_cast<config_method_eaphost*>(cfg_method->m_inner.get());
|
||||||
|
if (!cfg_inner_eaphost)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// Initialize application.
|
int result;
|
||||||
wxInitializerPeer init(m_instance);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Create wxWidget-approved parent window.
|
// Initialize application.
|
||||||
wxWindow parent;
|
wxInitializerPeer init(m_instance);
|
||||||
parent.SetHWND((WXHWND)(hwndParent ? hwndParent : GetForegroundWindow()));
|
|
||||||
parent.AdoptAttributesFromHWND();
|
|
||||||
wxTopLevelWindows.Append(&parent);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
sanitizing_wstring
|
// Create wxWidget-approved parent window.
|
||||||
challenge(reinterpret_cast<sanitizing_wstring::const_pointer>(ctx.m_data.data()), ctx.m_data.size()/sizeof(sanitizing_wstring::value_type)),
|
wxWindow parent;
|
||||||
response;
|
parent.SetHWND((WXHWND)(hwndParent ? hwndParent : GetForegroundWindow()));
|
||||||
|
parent.AdoptAttributesFromHWND();
|
||||||
|
wxTopLevelWindows.Append(&parent);
|
||||||
|
|
||||||
// Build dialog to prompt for response.
|
{
|
||||||
wxGTCResponseDialog dlg(*cfg_prov, &parent);
|
sanitizing_wstring
|
||||||
auto panel = new wxGTCResponsePanel(response, challenge.c_str(), &dlg);
|
challenge(reinterpret_cast<sanitizing_wstring::const_pointer>(ctx.m_data.data()), ctx.m_data.size()/sizeof(sanitizing_wstring::value_type)),
|
||||||
dlg.AddContent(panel);
|
response;
|
||||||
|
|
||||||
// Update dialog layout.
|
// Build dialog to prompt for response.
|
||||||
dlg.Layout();
|
wxGTCResponseDialog dlg(*cfg_prov, &parent);
|
||||||
dlg.GetSizer()->Fit(&dlg);
|
auto panel = new wxGTCResponsePanel(response, challenge.c_str(), &dlg);
|
||||||
|
dlg.AddContent(panel);
|
||||||
|
|
||||||
// Centre and display dialog.
|
// Update dialog layout.
|
||||||
dlg.Centre(wxBOTH);
|
dlg.Layout();
|
||||||
if ((result = dlg.ShowModal()) == wxID_OK) {
|
dlg.GetSizer()->Fit(&dlg);
|
||||||
// Save response.
|
|
||||||
ctx.m_data.assign(
|
// Centre and display dialog.
|
||||||
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() ),
|
dlg.Centre(wxBOTH);
|
||||||
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() + response.length()));
|
if ((result = dlg.ShowModal()) == wxID_OK) {
|
||||||
|
// Save response.
|
||||||
|
ctx.m_data.assign(
|
||||||
|
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() ),
|
||||||
|
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() + response.length()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
wxTopLevelWindows.DeleteObject(&parent);
|
wxTopLevelWindows.DeleteObject(&parent);
|
||||||
parent.SetHWND((WXHWND)NULL);
|
parent.SetHWND((WXHWND)NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != wxID_OK)
|
||||||
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
}
|
||||||
|
#ifdef EAP_INNER_EAPHOST
|
||||||
|
else {
|
||||||
|
// EapHost inner method
|
||||||
|
DWORD dwSizeofDataFromInteractiveUI;
|
||||||
|
BYTE *pDataFromInteractiveUI;
|
||||||
|
winstd::eap_error error;
|
||||||
|
DWORD dwResult = EapHostPeerInvokeInteractiveUI(
|
||||||
|
hwndParent,
|
||||||
|
(DWORD)ctx.m_data.size(),
|
||||||
|
ctx.m_data.data(),
|
||||||
|
&dwSizeofDataFromInteractiveUI,
|
||||||
|
&pDataFromInteractiveUI,
|
||||||
|
&error._Myptr);
|
||||||
|
if (dwResult == ERROR_SUCCESS) {
|
||||||
|
// Inner EAP method provided response.
|
||||||
|
ctx.m_data.assign(pDataFromInteractiveUI, pDataFromInteractiveUI + dwSizeofDataFromInteractiveUI);
|
||||||
|
} else if (dwResult == ERROR_CANCELLED) {
|
||||||
|
// Not really an error.
|
||||||
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
} else if (error) {
|
||||||
|
wxLogError(_("Invoking EAP interactive UI failed (error %u, %s, %s)."), error->dwWinError, error->pRootCauseString, error->pRepairString);
|
||||||
|
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerInvokeInteractiveUI failed.");
|
||||||
|
} else {
|
||||||
|
wxLogError(_("Invoking EAP interactive UI failed (error %u)."), dwResult);
|
||||||
|
throw win_runtime_error(dwResult, __FUNCTION__ " EapHostPeerInvokeInteractiveUI failed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (result != wxID_OK)
|
|
||||||
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
|
||||||
|
|
||||||
// Pack output data.
|
// Pack output data.
|
||||||
pack(ctx.m_data, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize);
|
pack(ctx.m_data, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user