Password change detection updated not to rely on default password value any more, but monitors password control change events

This commit is contained in:
Simon Rozman 2016-09-26 10:16:37 +02:00
parent 79cc1af86f
commit c41bc3908e
4 changed files with 22 additions and 11 deletions

View File

@ -844,6 +844,7 @@ public:
/// \param[in] is_config Is this panel used to config credentials? /// \param[in] is_config Is this panel used to config credentials?
/// ///
wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, wxWindow* parent, bool is_config = false) : wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, wxWindow* parent, bool is_config = false) :
m_password_set(false),
wxEAPCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, parent, is_config) wxEAPCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, parent, is_config)
{ {
// Load and set icon. // Load and set icon.
@ -879,7 +880,8 @@ protected:
{ {
m_identity->SetValue(m_cred.m_identity); m_identity->SetValue(m_cred.m_identity);
m_identity->SetSelection(0, -1); m_identity->SetSelection(0, -1);
m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password); m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : wxT("dummypass"));
m_password_set = false;
if (!m_is_config && m_cfg.m_use_cred) { if (!m_is_config && m_cfg.m_use_cred) {
// Credential prompt mode & Using configured credentials // Credential prompt mode & Using configured credentials
@ -898,24 +900,23 @@ protected:
return false; return false;
m_cred.m_identity = m_identity->GetValue(); m_cred.m_identity = m_identity->GetValue();
wxString pass = m_password->GetValue(); if (m_password_set)
if (pass.compare(s_dummy_password) != 0) { m_cred.m_password = m_password->GetValue();
m_cred.m_password = pass;
pass.assign(pass.length(), wxT('*'));
}
return true; return true;
} }
virtual void OnPasswordText(wxCommandEvent& /*event*/)
{
m_password_set = true;
}
/// \endcond /// \endcond
private: private:
static const wxStringCharType *s_dummy_password; bool m_password_set;
}; };
template <class _Tcred, class _Tbase>
const wxStringCharType *wxPasswordCredentialsPanel<_Tcred, _Tbase>::s_dummy_password = wxT("dummypass");
inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, int cx, int cy) inline wxIcon wxLoadIconFromResource(HINSTANCE hinst, PCWSTR pszName, int cx, int cy)
{ {

View File

@ -383,10 +383,16 @@ wxPasswordCredentialsPanelBase::wxPasswordCredentialsPanelBase( wxWindow* parent
this->SetSizer( m_sb_credentials ); this->SetSizer( m_sb_credentials );
this->Layout(); this->Layout();
// Connect Events
m_password->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxPasswordCredentialsPanelBase::OnPasswordText ), NULL, this );
} }
wxPasswordCredentialsPanelBase::~wxPasswordCredentialsPanelBase() wxPasswordCredentialsPanelBase::~wxPasswordCredentialsPanelBase()
{ {
// Disconnect Events
m_password->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxPasswordCredentialsPanelBase::OnPasswordText ), NULL, this );
} }
wxEAPProviderContactInfoPanelBase::wxEAPProviderContactInfoPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) wxEAPProviderContactInfoPanelBase::wxEAPProviderContactInfoPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )

View File

@ -2929,7 +2929,7 @@
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText"></event> <event name="OnText">OnPasswordText</event>
<event name="OnTextEnter"></event> <event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event> <event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event> <event name="OnTextURL"></event>

View File

@ -208,6 +208,10 @@ class wxPasswordCredentialsPanelBase : public wxEAPCredentialsPanelBase
wxStaticText* m_password_label; wxStaticText* m_password_label;
wxTextCtrl* m_password; wxTextCtrl* m_password;
// Virtual event handlers, overide them in your derived class
virtual void OnPasswordText( wxCommandEvent& event ) { event.Skip(); }
public: public:
wxPasswordCredentialsPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxTAB_TRAVERSAL ); wxPasswordCredentialsPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxTAB_TRAVERSAL );