config_method split into config_method and config_method_with_cred<>
This commit is contained in:
@@ -77,13 +77,51 @@ bool eap::peer_ttls_ui::invoke_identity_ui(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(cfg);
|
||||
UNREFERENCED_PARAMETER(cred);
|
||||
UNREFERENCED_PARAMETER(ppwszIdentity);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
InitCommonControls();
|
||||
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" credential prompt goes here!"), _T(PRODUCT_NAME_STR) _T(" Credentials"), MB_OK);
|
||||
if (cfg.m_providers.empty() || cfg.m_providers.front().m_methods.empty()) {
|
||||
*ppEapError = make_error(ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" Configuration has no providers and/or methods."));
|
||||
return false;
|
||||
}
|
||||
|
||||
const config_provider &cfg_prov(cfg.m_providers.front());
|
||||
const config_method_ttls *cfg_method = dynamic_cast<const config_method_ttls*>(cfg_prov.m_methods.front().get());
|
||||
assert(cfg_method);
|
||||
|
||||
// Initialize application.
|
||||
new wxApp();
|
||||
wxEntryStart(m_instance);
|
||||
|
||||
int result;
|
||||
{
|
||||
// Create wxWidget-approved parent window.
|
||||
wxWindow parent;
|
||||
parent.SetHWND((WXHWND)hwndParent);
|
||||
parent.AdoptAttributesFromHWND();
|
||||
wxTopLevelWindows.Append(&parent);
|
||||
|
||||
// Create and launch credentials dialog.
|
||||
wxEAPCredentialsDialog dlg(cfg_prov, &parent);
|
||||
wxTTLSCredentialsPanel *panel = new wxTTLSCredentialsPanel(cfg_prov, *cfg_method, cred, cfg_prov.m_id.c_str(), &dlg, true);
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
result = dlg.ShowModal();
|
||||
|
||||
wxTopLevelWindows.DeleteObject(&parent);
|
||||
parent.SetHWND((WXHWND)NULL);
|
||||
}
|
||||
|
||||
// Clean-up and return.
|
||||
wxEntryCleanup();
|
||||
if (result != wxID_OK) {
|
||||
*ppEapError = make_error(ERROR_CANCELLED, _T(__FUNCTION__) _T(" Cancelled."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build our identity. ;)
|
||||
std::wstring identity(std::move(cfg_method->get_public_identity(cred)));
|
||||
log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID, winstd::event_data(L"TTLS"), winstd::event_data(identity), winstd::event_data::blank);
|
||||
size_t size = sizeof(WCHAR)*(identity.length() + 1);
|
||||
*ppwszIdentity = (WCHAR*)alloc_memory(size);
|
||||
memcpy(*ppwszIdentity, identity.c_str(), size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -102,8 +102,8 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::co
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
if (prov.m_read_only)
|
||||
sb_content->Add(new wxEAPProviderLockedPanel(prov, this), 0, wxALL|wxEXPAND, 5);
|
||||
if (m_prov.m_read_only)
|
||||
sb_content->Add(new wxEAPProviderLockedPanel(m_prov, this), 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_inner_title = new wxStaticText(this, wxID_ANY, _("Inner Authentication"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_inner_title->SetFont(wxFont(18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
|
||||
@@ -112,7 +112,7 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::co
|
||||
|
||||
m_inner_type = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxCHB_DEFAULT);
|
||||
m_inner_type->SetToolTip( _("Select inner authentication method from the list") );
|
||||
m_inner_type->AddPage(new wxPAPConfigPanel(prov, m_cfg_pap, pszCredTarget, m_inner_type), _("PAP"));
|
||||
m_inner_type->AddPage(new wxPAPConfigPanel(m_prov, m_cfg_pap, pszCredTarget, m_inner_type), _("PAP"));
|
||||
sb_content->Add(m_inner_type, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
sb_content->Add(20, 20, 1, wxALL|wxEXPAND, 5);
|
||||
@@ -122,10 +122,10 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::co
|
||||
m_outer_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
|
||||
sb_content->Add(m_outer_title, 0, wxALL|wxALIGN_RIGHT, 5);
|
||||
|
||||
m_outer_identity = new wxTTLSConfigPanel(prov, m_cfg, this);
|
||||
m_outer_identity = new wxTTLSConfigPanel(m_prov, m_cfg, this);
|
||||
sb_content->Add(m_outer_identity, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_tls = new wxTLSConfigPanel(prov, m_cfg, pszCredTarget, this);
|
||||
m_tls = new wxTLSConfigPanel(m_prov, m_cfg.m_outer, pszCredTarget, this);
|
||||
sb_content->Add(m_tls, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
wxSize size = sb_content->CalcMin();
|
||||
@@ -205,3 +205,67 @@ void wxTTLSConfigWindow::OnInitDialog(wxInitDialogEvent& event)
|
||||
for (wxWindowList::compatibility_iterator inner = m_inner_type->GetChildren().GetFirst(); inner; inner = inner->GetNext())
|
||||
inner->GetData()->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxTTLSCredentialsPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxTTLSCredentialsPanel::wxTTLSCredentialsPanel(const eap::config_provider &prov, const eap::config_method &cfg, eap::credentials &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
|
||||
m_prov(prov),
|
||||
m_cfg((eap::config_method_ttls&)cfg),
|
||||
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
if (m_prov.m_read_only)
|
||||
sb_content->Add(new wxEAPProviderLockedPanel(m_prov, this), 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_inner_title = new wxStaticText(this, wxID_ANY, _("Inner Authentication"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_inner_title->SetFont(wxFont(18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
|
||||
m_inner_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
|
||||
sb_content->Add(m_inner_title, 0, wxALL|wxALIGN_RIGHT, 5);
|
||||
|
||||
assert(m_cfg.m_inner);
|
||||
const eap::config_method_pap *cfg_inner_pap = dynamic_cast<const eap::config_method_pap*>(m_cfg.m_inner.get());
|
||||
if (cfg_inner_pap) {
|
||||
if (!((eap::credentials_ttls&)cred).m_inner) ((eap::credentials_ttls&)cred).m_inner.reset(new eap::credentials_pap(cred.m_module));
|
||||
m_inner_cred = new wxPAPCredentialsPanel(m_prov, *cfg_inner_pap, *((eap::credentials_ttls&)cred).m_inner.get(), pszCredTarget, this, is_config);
|
||||
sb_content->Add(m_inner_cred, 0, wxALL|wxEXPAND, 5);
|
||||
} else
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
|
||||
sb_content->Add(20, 20, 1, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_outer_title = new wxStaticText(this, wxID_ANY, _("Outer Authentication"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_outer_title->SetFont(wxFont(18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
|
||||
m_outer_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
|
||||
sb_content->Add(m_outer_title, 0, wxALL|wxALIGN_RIGHT, 5);
|
||||
|
||||
m_outer_cred = new wxTLSCredentialsPanel(m_prov, (const eap::config_method_tls&)m_cfg, (eap::credentials_tls&)cred, pszCredTarget, this, is_config);
|
||||
sb_content->Add(m_outer_cred, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
m_inner_cred->SetFocusFromKbd();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxTTLSCredentialsPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxTTLSCredentialsPanel::~wxTTLSCredentialsPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxTTLSCredentialsPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
void wxTTLSCredentialsPanel::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
m_outer_cred->GetEventHandler()->ProcessEvent(event);
|
||||
m_inner_cred->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
Reference in New Issue
Block a user