Support for read-only configurations added
This commit is contained in:
parent
2f0948b4fd
commit
e52b9a636f
@ -227,6 +227,12 @@ namespace eap
|
||||
template <class _Tcred>
|
||||
class config_method : public config
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Configuration credentials type
|
||||
///
|
||||
typedef _Tcred credentials_type;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs configuration
|
||||
@ -420,13 +426,21 @@ namespace eap
|
||||
template <class _Tmeth>
|
||||
class config_provider : public config
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Provider method configuration type
|
||||
///
|
||||
typedef _Tmeth config_method_type;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs configuration
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
config_provider(_In_ module &mod) : config(mod)
|
||||
config_provider(_In_ module &mod) :
|
||||
m_read_only(false),
|
||||
config(mod)
|
||||
{
|
||||
}
|
||||
|
||||
@ -436,7 +450,9 @@ namespace eap
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
config_provider(_In_ const config_provider &other) :
|
||||
m_read_only(other.m_read_only),
|
||||
m_id(other.m_id),
|
||||
m_name(other.m_name),
|
||||
m_lbl_alt_credential(other.m_lbl_alt_credential),
|
||||
m_lbl_alt_identity(other.m_lbl_alt_identity),
|
||||
m_lbl_alt_password(other.m_lbl_alt_password),
|
||||
@ -451,7 +467,9 @@ namespace eap
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
config_provider(_Inout_ config_provider &&other) :
|
||||
m_read_only(std::move(other.m_read_only)),
|
||||
m_id(std::move(other.m_id)),
|
||||
m_name(std::move(other.m_name)),
|
||||
m_lbl_alt_credential(std::move(other.m_lbl_alt_credential)),
|
||||
m_lbl_alt_identity(std::move(other.m_lbl_alt_identity)),
|
||||
m_lbl_alt_password(std::move(other.m_lbl_alt_password)),
|
||||
@ -471,7 +489,9 @@ namespace eap
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = other;
|
||||
m_read_only = other.m_read_only;
|
||||
m_id = other.m_id;
|
||||
m_name = other.m_name;
|
||||
m_lbl_alt_credential = other.m_lbl_alt_credential;
|
||||
m_lbl_alt_identity = other.m_lbl_alt_identity;
|
||||
m_lbl_alt_password = other.m_lbl_alt_password;
|
||||
@ -492,7 +512,9 @@ namespace eap
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = std::move(other);
|
||||
m_read_only = std::move(m_read_only);
|
||||
m_id = std::move(other.m_id);
|
||||
m_name = std::move(other.m_name);
|
||||
m_lbl_alt_credential = std::move(other.m_lbl_alt_credential);
|
||||
m_lbl_alt_identity = std::move(other.m_lbl_alt_identity);
|
||||
m_lbl_alt_password = std::move(other.m_lbl_alt_password);
|
||||
@ -529,6 +551,12 @@ namespace eap
|
||||
DWORD dwResult;
|
||||
HRESULT hr;
|
||||
|
||||
// <read-only>
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pConfigRoot, winstd::bstr(L"read-only"), bstrNamespace, m_read_only)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <read-only> element."), NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// <ID>
|
||||
if (!m_id.empty())
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pConfigRoot, winstd::bstr(L"ID"), bstrNamespace, winstd::bstr(m_id))) != ERROR_SUCCESS) {
|
||||
@ -543,6 +571,13 @@ namespace eap
|
||||
return false;
|
||||
}
|
||||
|
||||
// <ProviderInfo>/<DisplayName>
|
||||
if (!m_name.empty())
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"DisplayName"), bstrNamespace, winstd::bstr(m_name))) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <DisplayName> element."), NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// <ProviderInfo>/<CredentialPrompt>
|
||||
if (!m_lbl_alt_credential.empty())
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"CredentialPrompt"), bstrNamespace, winstd::bstr(m_lbl_alt_credential))) != ERROR_SUCCESS) {
|
||||
@ -611,16 +646,24 @@ namespace eap
|
||||
std::wstring lang;
|
||||
LoadString(m_module.m_instance, 2, lang);
|
||||
|
||||
// <read-only>
|
||||
if ((dwResult = eapxml::get_element_value(pConfigRoot, winstd::bstr(L"eap-metadata:read-only"), &m_read_only)) != ERROR_SUCCESS)
|
||||
m_read_only = true;
|
||||
|
||||
// <ID>
|
||||
m_id.clear();
|
||||
eapxml::get_element_value(pConfigRoot, winstd::bstr(L"eap-metadata:ID"), m_id);
|
||||
|
||||
// <ProviderInfo>
|
||||
m_name.clear();
|
||||
m_lbl_alt_credential.clear();
|
||||
m_lbl_alt_identity.clear();
|
||||
m_lbl_alt_password.clear();
|
||||
winstd::com_obj<IXMLDOMElement> pXmlElProviderInfo;
|
||||
if (eapxml::select_element(pConfigRoot, winstd::bstr(L"eap-metadata:ProviderInfo"), &pXmlElProviderInfo) == ERROR_SUCCESS) {
|
||||
// <DisplayName>
|
||||
eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:DisplayName"), lang.c_str(), m_name);
|
||||
|
||||
// <CredentialPrompt>
|
||||
eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:CredentialPrompt"), lang.c_str(), m_lbl_alt_credential);
|
||||
|
||||
@ -669,7 +712,9 @@ namespace eap
|
||||
/// @}
|
||||
|
||||
public:
|
||||
bool m_read_only; ///< Is profile read-only
|
||||
std::wstring m_id; ///< Profile ID
|
||||
winstd::tstring m_name; ///< Provider name
|
||||
winstd::tstring m_lbl_alt_credential; ///< Alternative label for credential prompt
|
||||
winstd::tstring m_lbl_alt_identity; ///< Alternative label for identity prompt
|
||||
winstd::tstring m_lbl_alt_password; ///< Alternative label for password prompt
|
||||
@ -887,7 +932,9 @@ namespace eapserial
|
||||
template <class _Tmeth>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_provider<_Tmeth> &val)
|
||||
{
|
||||
pack(cursor, val.m_read_only );
|
||||
pack(cursor, val.m_id );
|
||||
pack(cursor, val.m_name );
|
||||
pack(cursor, val.m_lbl_alt_credential);
|
||||
pack(cursor, val.m_lbl_alt_identity );
|
||||
pack(cursor, val.m_lbl_alt_password );
|
||||
@ -899,7 +946,9 @@ namespace eapserial
|
||||
inline size_t get_pk_size(const eap::config_provider<_Tmeth> &val)
|
||||
{
|
||||
return
|
||||
get_pk_size(val.m_read_only ) +
|
||||
get_pk_size(val.m_id ) +
|
||||
get_pk_size(val.m_name ) +
|
||||
get_pk_size(val.m_lbl_alt_credential) +
|
||||
get_pk_size(val.m_lbl_alt_identity ) +
|
||||
get_pk_size(val.m_lbl_alt_password ) +
|
||||
@ -910,7 +959,9 @@ namespace eapserial
|
||||
template <class _Tmeth>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_provider<_Tmeth> &val)
|
||||
{
|
||||
unpack(cursor, val.m_read_only );
|
||||
unpack(cursor, val.m_id );
|
||||
unpack(cursor, val.m_name );
|
||||
unpack(cursor, val.m_lbl_alt_credential);
|
||||
unpack(cursor, val.m_lbl_alt_identity );
|
||||
unpack(cursor, val.m_lbl_alt_password );
|
||||
|
@ -441,10 +441,15 @@ namespace eap
|
||||
class peer_base : public module
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Provider configuration data type
|
||||
///
|
||||
typedef config_provider<_Tcfg> provider_config_type;
|
||||
|
||||
///
|
||||
/// Configuration data type
|
||||
///
|
||||
typedef config_providers<config_provider<_Tcfg> > config_type;
|
||||
typedef config_providers<provider_config_type> config_type;
|
||||
|
||||
///
|
||||
/// Identity data type
|
||||
|
@ -280,7 +280,10 @@ bool eap::credentials_pass::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR
|
||||
return false;
|
||||
}
|
||||
|
||||
m_identity = cred->UserName;
|
||||
if (cred->UserName)
|
||||
m_identity = cred->UserName;
|
||||
else
|
||||
m_identity.clear();
|
||||
|
||||
// Decrypt the password using user's key.
|
||||
string password_base64;
|
||||
|
@ -150,7 +150,7 @@ bool eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void
|
||||
vector<unsigned char, sanitizing_allocator<unsigned char> > buf(size);
|
||||
memcpy(buf.data(), data, size);
|
||||
if (!CryptGetKeyParam(key, KP_BLOCKLEN, dwBlockLen, 0)) dwBlockLen = 0;
|
||||
buf.reserve((size + dwBlockLen - 1) / dwBlockLen * dwBlockLen);
|
||||
buf.reserve(std::max<size_t>((size + dwBlockLen - 1) / dwBlockLen, 1) * dwBlockLen);
|
||||
|
||||
// Encrypt the data using our public key.
|
||||
if (!CryptEncrypt(key, hHash, TRUE, 0, buf)) {
|
||||
|
@ -26,7 +26,7 @@
|
||||
///
|
||||
/// EAP configuration dialog
|
||||
///
|
||||
template <class _Tcfg, class _wxT> class wxEAPConfigDialog;
|
||||
template <class _Tmeth, class _wxT> class wxEAPConfigDialog;
|
||||
|
||||
///
|
||||
/// EAP credentials dialog
|
||||
@ -38,15 +38,20 @@ class wxEAPCredentialsDialog;
|
||||
///
|
||||
class wxEAPBannerPanel;
|
||||
|
||||
///
|
||||
/// EAP Provider-locked congifuration note
|
||||
///
|
||||
template <class _Tprov> class wxEAPProviderLocked;
|
||||
|
||||
///
|
||||
/// Base template for credentials configuration panel
|
||||
///
|
||||
template <class _Tcfg, class _Tcred, class _Tpanel> class wxEAPCredentialsConfigPanel;
|
||||
template <class _Tprov, class _Tmeth, class _wxT> class wxEAPCredentialsConfigPanel;
|
||||
|
||||
///
|
||||
/// Base template for all credential panels
|
||||
///
|
||||
template <class _Tbase, class _Tcred> class wxCredentialsPanel;
|
||||
template <class _Tcred, class _Tbase> class wxCredentialsPanel;
|
||||
|
||||
///
|
||||
/// Password credentials panel
|
||||
@ -115,6 +120,7 @@ public:
|
||||
for (; method != method_end; ++method, count++)
|
||||
m_providers->AddPage(
|
||||
new _wxT(
|
||||
*provider,
|
||||
provider->m_methods.front(),
|
||||
provider->m_id.c_str(),
|
||||
m_providers),
|
||||
@ -182,18 +188,51 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
template <class _Tcfg, class _Tcred, class _Tpanel>
|
||||
template <class _Tprov>
|
||||
class wxEAPProviderLocked : public wxEAPProviderLockedBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a notice pannel and set the title text
|
||||
///
|
||||
wxEAPProviderLocked(_Tprov &prov, wxWindow* parent) : wxEAPProviderLockedBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_provider_locked_icon, m_icon, m_shell32, MAKEINTRESOURCE(48));
|
||||
|
||||
m_provider_locked_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::string_printf(_("Your %ls provider"), prov.m_id.c_str()).c_str() : _("Your provider")));
|
||||
m_provider_locked_label->Wrap(452);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool AcceptsFocusFromKeyboard() const { return false; }
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov, class _Tmeth, class _wxT>
|
||||
class wxEAPCredentialsConfigPanel : public wxEAPCredentialsConfigPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credential configuration panel
|
||||
///
|
||||
/// \param[inout] 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
|
||||
///
|
||||
wxEAPCredentialsConfigPanel(_Tcfg &cfg, LPCTSTR pszCredTarget, wxWindow *parent) :
|
||||
wxEAPCredentialsConfigPanel(_Tprov &prov, _Tmeth &cfg, LPCTSTR pszCredTarget, wxWindow *parent) :
|
||||
m_prov(prov),
|
||||
m_cfg(cfg),
|
||||
m_target(pszCredTarget),
|
||||
m_cred(m_cfg.m_module),
|
||||
@ -201,7 +240,7 @@ public:
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(48));
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(/*16770*/269));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -209,29 +248,41 @@ protected:
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(wxEAPCredentialsConfigPanelBase::TransferDataToWindow(), false);
|
||||
if (m_prov.m_read_only) {
|
||||
// This is provider-locked configuration. Disable controls.
|
||||
m_own ->Enable(false);
|
||||
m_preshared ->Enable(false);
|
||||
m_preshared_identity->Enable(false);
|
||||
m_preshared_set ->Enable(false);
|
||||
}
|
||||
|
||||
if (!m_cfg.m_use_preshared) {
|
||||
m_own->SetValue(true);
|
||||
m_cred.clear();
|
||||
} else {
|
||||
m_preshared->SetValue(true);
|
||||
m_cred = m_cfg.m_preshared;
|
||||
}
|
||||
|
||||
return true;
|
||||
return wxEAPCredentialsConfigPanelBase::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
if (m_own->GetValue()) {
|
||||
m_cfg.m_use_preshared = false;
|
||||
} else {
|
||||
m_cfg.m_use_preshared = true;
|
||||
m_cfg.m_preshared = m_cred;
|
||||
wxCHECK(wxEAPCredentialsConfigPanelBase::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Save the data.
|
||||
if (m_own->GetValue()) {
|
||||
m_cfg.m_use_preshared = false;
|
||||
} else {
|
||||
m_cfg.m_use_preshared = true;
|
||||
m_cfg.m_preshared = m_cred;
|
||||
}
|
||||
}
|
||||
|
||||
return wxEAPCredentialsConfigPanelBase::TransferDataFromWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -240,33 +291,48 @@ protected:
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
DWORD dwResult;
|
||||
|
||||
bool has_own;
|
||||
std::unique_ptr<CREDENTIAL, winstd::CredFree_delete<CREDENTIAL> > cred;
|
||||
if (CredRead(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
m_identity_own->SetValue(cred->UserName && cred->UserName[0] != 0 ? cred->UserName : _("<blank>"));
|
||||
has_own = true;
|
||||
} else if ((dwResult = GetLastError()) == ERROR_NOT_FOUND) {
|
||||
m_identity_own->Clear();
|
||||
has_own = false;
|
||||
if (m_cfg.m_allow_save) {
|
||||
bool has_own;
|
||||
std::unique_ptr<CREDENTIAL, winstd::CredFree_delete<CREDENTIAL> > cred;
|
||||
if (CredRead(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
m_own_identity->SetValue(cred->UserName && cred->UserName[0] != 0 ? cred->UserName : _("<blank>"));
|
||||
has_own = true;
|
||||
} else if ((dwResult = GetLastError()) == ERROR_NOT_FOUND) {
|
||||
m_own_identity->Clear();
|
||||
has_own = false;
|
||||
} else {
|
||||
m_own_identity->SetValue(wxString::Format(_("<error %u>"), dwResult));
|
||||
has_own = true;
|
||||
}
|
||||
|
||||
if (m_own->GetValue()) {
|
||||
m_own_identity->Enable(true);
|
||||
m_own_set ->Enable(true);
|
||||
m_own_clear ->Enable(has_own);
|
||||
} else {
|
||||
m_own_identity->Enable(false);
|
||||
m_own_set ->Enable(false);
|
||||
m_own_clear ->Enable(false);
|
||||
}
|
||||
} else {
|
||||
m_identity_own->SetValue(wxString::Format(_("<error %u>"), dwResult));
|
||||
has_own = true;
|
||||
m_own_identity->Clear();
|
||||
|
||||
m_own_identity->Enable(false);
|
||||
m_own_set ->Enable(false);
|
||||
m_own_clear ->Enable(false);
|
||||
}
|
||||
|
||||
if (m_own->GetValue()) {
|
||||
m_identity_own ->Enable(true);
|
||||
m_set_own ->Enable(true);
|
||||
m_clear_own ->Enable(has_own);
|
||||
m_identity_preshared->Enable(false);
|
||||
m_identity_preshared->SetValue(wxEmptyString);
|
||||
m_set_preshared ->Enable(false);
|
||||
} else {
|
||||
m_identity_own ->Enable(false);
|
||||
m_set_own ->Enable(false);
|
||||
m_clear_own ->Enable(false);
|
||||
m_identity_preshared->Enable(true);
|
||||
m_identity_preshared->SetValue(!m_cred.empty() ? m_cred.m_identity : _("<blank>"));
|
||||
m_set_preshared ->Enable(true);
|
||||
m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.m_identity : _("<blank>"));
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Selectively enable/disable controls.
|
||||
if (m_own->GetValue()) {
|
||||
m_preshared_identity->Enable(false);
|
||||
m_preshared_set ->Enable(false);
|
||||
} else {
|
||||
m_preshared_identity->Enable(true);
|
||||
m_preshared_set ->Enable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +343,7 @@ protected:
|
||||
|
||||
wxEAPCredentialsDialog dlg(this);
|
||||
|
||||
_Tpanel *panel = new _Tpanel(m_cred, m_target.c_str(), &dlg, true);
|
||||
_wxT *panel = new _wxT(m_cred, m_target.c_str(), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
@ -299,7 +365,7 @@ protected:
|
||||
|
||||
wxEAPCredentialsDialog dlg(this);
|
||||
|
||||
_Tpanel *panel = new _Tpanel(m_cred, _T(""), &dlg, true);
|
||||
_wxT *panel = new _wxT(m_cred, _T(""), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
@ -308,17 +374,18 @@ protected:
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tcfg &m_cfg; ///< EAP configuration
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
_Tprov &m_prov; ///< EAP provider
|
||||
_Tmeth &m_cfg; ///< EAP configuration
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
|
||||
private:
|
||||
_Tcred m_cred; ///< Temporary credential data
|
||||
typename _Tmeth::credentials_type m_cred; ///< Temporary credential data
|
||||
};
|
||||
|
||||
|
||||
template <class _Tbase, class _Tcred>
|
||||
template <class _Tcred, class _Tbase>
|
||||
class wxCredentialsPanel : public _Tbase
|
||||
{
|
||||
public:
|
||||
@ -348,8 +415,6 @@ protected:
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(_Tbase::TransferDataToWindow(), false);
|
||||
|
||||
if (!m_target.empty()) {
|
||||
// Read credentials from Credential Manager
|
||||
EAP_ERROR *pEapError;
|
||||
@ -363,12 +428,14 @@ protected:
|
||||
wxLogError(_("Reading credentials failed."));
|
||||
}
|
||||
|
||||
return true;
|
||||
return _Tbase::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(_Tbase::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_target.empty()) {
|
||||
// Write credentials to credential manager.
|
||||
if (m_remember->GetValue()) {
|
||||
@ -383,7 +450,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
return _Tbase::TransferDataFromWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
@ -394,7 +461,7 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class wxPasswordCredentialsPanel : public wxCredentialsPanel<wxPasswordCredentialsPanelBase, eap::credentials_pass>
|
||||
class wxPasswordCredentialsPanel : public wxCredentialsPanel<eap::credentials_pass, wxPasswordCredentialsPanelBase>
|
||||
{
|
||||
public:
|
||||
///
|
||||
|
@ -119,6 +119,35 @@ wxEAPBannerPanelBase::~wxEAPBannerPanelBase()
|
||||
{
|
||||
}
|
||||
|
||||
wxEAPProviderLockedBase::wxEAPProviderLockedBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
|
||||
{
|
||||
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK ) );
|
||||
|
||||
wxBoxSizer* sb_provider_locked_horiz;
|
||||
sb_provider_locked_horiz = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_provider_locked_icon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sb_provider_locked_horiz->Add( m_provider_locked_icon, 0, wxALL, 5 );
|
||||
|
||||
wxBoxSizer* sb_provider_locked_vert;
|
||||
sb_provider_locked_vert = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_provider_locked_label = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_provider_locked_label->Wrap( 452 );
|
||||
sb_provider_locked_vert->Add( m_provider_locked_label, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
sb_provider_locked_horiz->Add( sb_provider_locked_vert, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( sb_provider_locked_horiz );
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
wxEAPProviderLockedBase::~wxEAPProviderLockedBase()
|
||||
{
|
||||
}
|
||||
|
||||
wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
|
||||
{
|
||||
wxStaticBoxSizer* sb_credentials;
|
||||
@ -151,10 +180,10 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
|
||||
sz_own_inner->Add( m_own, 2, wxEXPAND, 5 );
|
||||
|
||||
m_identity_own = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_identity_own->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
m_own_identity = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_own_identity->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
|
||||
sz_own_inner->Add( m_identity_own, 3, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
sz_own_inner->Add( m_own_identity, 3, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
sz_own->Add( sz_own_inner, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
@ -162,15 +191,15 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
wxBoxSizer* sb_buttons_own;
|
||||
sb_buttons_own = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_clear_own = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Clear Credentials"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_clear_own->SetToolTip( _("Click to clear your credentials from Credential Manager.\nNote: You will be prompted to enter credentials when connecting.") );
|
||||
m_own_clear = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Clear Credentials"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_own_clear->SetToolTip( _("Click to clear your credentials from Credential Manager.\nNote: You will be prompted to enter credentials when connecting.") );
|
||||
|
||||
sb_buttons_own->Add( m_clear_own, 0, wxRIGHT, 5 );
|
||||
sb_buttons_own->Add( m_own_clear, 0, wxRIGHT, 5 );
|
||||
|
||||
m_set_own = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_set_own->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
m_own_set = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_own_set->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
|
||||
sb_buttons_own->Add( m_set_own, 0, wxLEFT, 5 );
|
||||
sb_buttons_own->Add( m_own_set, 0, wxLEFT, 5 );
|
||||
|
||||
|
||||
sz_own->Add( sb_buttons_own, 0, wxALIGN_RIGHT, 5 );
|
||||
@ -189,10 +218,10 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
|
||||
sz_preshared_inner->Add( m_preshared, 2, wxEXPAND, 5 );
|
||||
|
||||
m_identity_preshared = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_identity_preshared->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
m_preshared_identity = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_preshared_identity->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
|
||||
sz_preshared_inner->Add( m_identity_preshared, 3, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
sz_preshared_inner->Add( m_preshared_identity, 3, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
sz_preshared->Add( sz_preshared_inner, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
@ -200,10 +229,10 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
wxBoxSizer* sb_buttons_preshared;
|
||||
sb_buttons_preshared = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_set_preshared = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_set_preshared->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
m_preshared_set = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_preshared_set->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
|
||||
sb_buttons_preshared->Add( m_set_preshared, 0, 0, 5 );
|
||||
sb_buttons_preshared->Add( m_preshared_set, 0, 0, 5 );
|
||||
|
||||
|
||||
sz_preshared->Add( sb_buttons_preshared, 0, wxALIGN_RIGHT, 5 );
|
||||
@ -226,18 +255,18 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPCredentialsConfigPanelBase::OnUpdateUI ) );
|
||||
m_clear_own->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this );
|
||||
m_set_own->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this );
|
||||
m_set_preshared->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this );
|
||||
m_own_clear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this );
|
||||
m_own_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this );
|
||||
m_preshared_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this );
|
||||
}
|
||||
|
||||
wxEAPCredentialsConfigPanelBase::~wxEAPCredentialsConfigPanelBase()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPCredentialsConfigPanelBase::OnUpdateUI ) );
|
||||
m_clear_own->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this );
|
||||
m_set_own->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this );
|
||||
m_set_preshared->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this );
|
||||
m_own_clear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this );
|
||||
m_own_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this );
|
||||
m_preshared_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this );
|
||||
|
||||
}
|
||||
|
||||
|
@ -623,6 +623,240 @@
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="Panel" expanded="1">
|
||||
<property name="aui_managed">0</property>
|
||||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||
<property name="bg">wxSYS_COLOUR_INFOBK</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="event_handler">impl_virtual</property>
|
||||
<property name="fg"></property>
|
||||
<property name="font"></property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">wxEAPProviderLockedBase</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">500,-1</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxSIMPLE_BORDER|wxTAB_TRAVERSAL</property>
|
||||
<event name="OnAuiFindManager"></event>
|
||||
<event name="OnAuiPaneButton"></event>
|
||||
<event name="OnAuiPaneClose"></event>
|
||||
<event name="OnAuiPaneMaximize"></event>
|
||||
<event name="OnAuiPaneRestore"></event>
|
||||
<event name="OnAuiRender"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnInitDialog"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sb_provider_locked_horiz</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticBitmap" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap">Load From Icon Resource; ; [32; 32]</property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_provider_locked_icon</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sb_provider_locked_vert</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label"></property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_provider_locked_label</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<property name="wrap">452</property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="Panel" expanded="1">
|
||||
<property name="aui_managed">0</property>
|
||||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||
@ -1020,7 +1254,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_identity_own</property>
|
||||
<property name="name">m_own_identity</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@ -1123,7 +1357,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_clear_own</property>
|
||||
<property name="name">m_own_clear</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@ -1211,7 +1445,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_set_own</property>
|
||||
<property name="name">m_own_set</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@ -1408,7 +1642,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_identity_preshared</property>
|
||||
<property name="name">m_preshared_identity</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@ -1511,7 +1745,7 @@
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_set_preshared</property>
|
||||
<property name="name">m_preshared_set</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
@ -1622,7 +1856,7 @@
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<object class="wxStaticBoxSizer" expanded="0">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Client Credentials</property>
|
||||
<property name="minimum_size"></property>
|
||||
@ -1630,11 +1864,11 @@
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sb_credentials_horiz</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
@ -1720,11 +1954,11 @@
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sb_credentials_vert</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
@ -1812,11 +2046,11 @@
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxFlexGridSizer" expanded="1">
|
||||
<object class="wxFlexGridSizer" expanded="0">
|
||||
<property name="cols">2</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">1</property>
|
||||
@ -1828,11 +2062,11 @@
|
||||
<property name="permission">none</property>
|
||||
<property name="rows">0</property>
|
||||
<property name="vgap">5</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<object class="wxStaticText" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
@ -1911,11 +2145,11 @@
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">2</property>
|
||||
<object class="wxTextCtrl" expanded="1">
|
||||
<object class="wxTextCtrl" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
@ -2002,11 +2236,11 @@
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<object class="wxStaticText" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
@ -2085,11 +2319,11 @@
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">2</property>
|
||||
<object class="wxTextCtrl" expanded="1">
|
||||
<object class="wxTextCtrl" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
@ -2178,11 +2412,11 @@
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="1">
|
||||
<object class="wxCheckBox" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -101,6 +101,24 @@ class wxEAPBannerPanelBase : public wxPanel
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class wxEAPProviderLockedBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class wxEAPProviderLockedBase : public wxPanel
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticBitmap* m_provider_locked_icon;
|
||||
wxStaticText* m_provider_locked_label;
|
||||
|
||||
public:
|
||||
|
||||
wxEAPProviderLockedBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxSIMPLE_BORDER|wxTAB_TRAVERSAL );
|
||||
~wxEAPProviderLockedBase();
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class wxEAPCredentialsConfigPanelBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -112,12 +130,12 @@ class wxEAPCredentialsConfigPanelBase : public wxPanel
|
||||
wxStaticBitmap* m_credentials_icon;
|
||||
wxStaticText* m_credentials_label;
|
||||
wxRadioButton* m_own;
|
||||
wxTextCtrl* m_identity_own;
|
||||
wxButton* m_clear_own;
|
||||
wxButton* m_set_own;
|
||||
wxTextCtrl* m_own_identity;
|
||||
wxButton* m_own_clear;
|
||||
wxButton* m_own_set;
|
||||
wxRadioButton* m_preshared;
|
||||
wxTextCtrl* m_identity_preshared;
|
||||
wxButton* m_set_preshared;
|
||||
wxTextCtrl* m_preshared_identity;
|
||||
wxButton* m_preshared_set;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
|
@ -72,7 +72,7 @@ const wxStringCharType *wxPasswordCredentialsPanel::s_dummy_password = wxT("dumm
|
||||
|
||||
|
||||
wxPasswordCredentialsPanel::wxPasswordCredentialsPanel(eap::credentials_pass &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
|
||||
wxCredentialsPanel<wxPasswordCredentialsPanelBase, eap::credentials_pass>(cred, pszCredTarget, parent, is_config)
|
||||
wxCredentialsPanel<eap::credentials_pass, wxPasswordCredentialsPanelBase>(cred, pszCredTarget, parent, is_config)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
@ -82,6 +82,8 @@ wxPasswordCredentialsPanel::wxPasswordCredentialsPanel(eap::credentials_pass &cr
|
||||
|
||||
bool wxPasswordCredentialsPanel::TransferDataToWindow()
|
||||
{
|
||||
// Inherited TransferDataToWindow() calls m_cred.retrieve().
|
||||
// Therefore, call it now, to set m_cred.
|
||||
wxCHECK(__super::TransferDataToWindow(), false);
|
||||
|
||||
m_identity->SetValue(m_cred.m_identity);
|
||||
@ -102,5 +104,7 @@ bool wxPasswordCredentialsPanel::TransferDataFromWindow()
|
||||
pass.assign(pass.length(), wxT('*'));
|
||||
}
|
||||
|
||||
// Inherited TransferDataFromWindow() calls m_cred.store().
|
||||
// Therefore, call it only now, that m_cred is set.
|
||||
return __super::TransferDataFromWindow();
|
||||
}
|
||||
|
@ -83,7 +83,6 @@
|
||||
<ClInclude Include="..\src\StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\PAP_UI.cpp" />
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
|
@ -26,8 +26,5 @@
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\PAP_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -25,12 +25,12 @@
|
||||
///
|
||||
/// PAP credentials configuration panel
|
||||
///
|
||||
typedef wxEAPCredentialsConfigPanel<eap::config_pap, eap::credentials_pap, wxPasswordCredentialsPanel> wxPAPCredentialsConfigPanel;
|
||||
template <class _Tprov> class wxPAPCredentialsConfigPanel;
|
||||
|
||||
///
|
||||
/// PAP configuration panel
|
||||
///
|
||||
class wxPAPConfigPanel;
|
||||
template <class _Tprov> class wxPAPConfigPanel;
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -40,25 +40,69 @@ class wxPAPConfigPanel;
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxPAPCredentialsConfigPanel : public wxEAPCredentialsConfigPanel<_Tprov, eap::config_pap, wxPasswordCredentialsPanel>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a PAP credential configuration panel
|
||||
///
|
||||
/// \param[inout] 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
|
||||
///
|
||||
wxPAPCredentialsConfigPanel(_Tprov &prov, eap::config_pap &cfg, LPCTSTR pszCredTarget, wxWindow *parent) :
|
||||
wxEAPCredentialsConfigPanel<_Tprov, eap::config_pap, wxPasswordCredentialsPanel>(prov, cfg, pszCredTarget, parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxPAPConfigPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxPAPConfigPanel(eap::config_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent);
|
||||
wxPAPConfigPanel(_Tprov &prov, eap::config_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_credentials = new wxPAPCredentialsConfigPanel<_Tprov>(prov, cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_credentials, 0, wxEXPAND, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxPAPConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
///
|
||||
/// Destructs the configuration panel
|
||||
///
|
||||
virtual ~wxPAPConfigPanel();
|
||||
virtual ~wxPAPConfigPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxPAPConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event);
|
||||
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
if (m_credentials)
|
||||
m_credentials->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
wxPAPCredentialsConfigPanel *m_credentials; ///< Credentials configuration panel
|
||||
wxStaticText *m_label; ///< No-configuration notice
|
||||
wxPAPCredentialsConfigPanel<_Tprov> *m_credentials; ///< Credentials configuration panel
|
||||
};
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 Amebis
|
||||
Copyright 2016 GÉANT
|
||||
|
||||
This file is part of GÉANTLink.
|
||||
|
||||
GÉANTLink is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GÉANTLink is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxPAPConfigPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxPAPConfigPanel::wxPAPConfigPanel(eap::config_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
if (cfg.m_allow_save) {
|
||||
m_credentials = new wxPAPCredentialsConfigPanel(cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_credentials, 0, wxEXPAND, 5);
|
||||
|
||||
m_label = NULL;
|
||||
} else {
|
||||
m_credentials = NULL;
|
||||
|
||||
m_label = new wxStaticText(this, wxID_ANY, _("This method requires no additional settings."), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_label->Wrap(-1);
|
||||
sb_content->Add(m_label, 0, wxEXPAND, 5);
|
||||
}
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxPAPConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxPAPConfigPanel::~wxPAPConfigPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxPAPConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
void wxPAPConfigPanel::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
if (m_credentials)
|
||||
m_credentials->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
@ -24,9 +24,16 @@
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <cryptuiapi.h>
|
||||
#include <Windows.h>
|
||||
#include <WinCrypt.h> // Must include after <Windows.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
///
|
||||
/// Helper class for auto-destroyable certificates used in wxWidget's item containers
|
||||
@ -56,17 +63,17 @@ class wxEAPTLSCredentialsPanel;
|
||||
///
|
||||
/// EAPTLS server trust configuration panel
|
||||
///
|
||||
class wxEAPTLSServerTrustPanel;
|
||||
template <class _Tprov> class wxEAPTLSServerTrustPanel;
|
||||
|
||||
///
|
||||
/// TLS credentials configuration panel
|
||||
///
|
||||
typedef wxEAPCredentialsConfigPanel<eap::config_tls, eap::credentials_tls, wxEAPTLSCredentialsPanel> wxEAPTLSCredentialsConfigPanel;
|
||||
template <class _Tprov> class wxEAPTLSCredentialsConfigPanel;
|
||||
|
||||
///
|
||||
/// EAPTLS configuration panel
|
||||
///
|
||||
class wxEAPTLSConfigPanel;
|
||||
template <class _Tprov> class wxEAPTLSConfigPanel;
|
||||
|
||||
namespace eap
|
||||
{
|
||||
@ -249,7 +256,7 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class wxEAPTLSCredentialsPanel : public wxCredentialsPanel<wxEAPTLSCredentialsPanelBase, eap::credentials_tls>
|
||||
class wxEAPTLSCredentialsPanel : public wxCredentialsPanel<eap::credentials_tls, wxEAPTLSCredentialsPanelBase>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -270,23 +277,150 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPTLSServerTrustPanel : public wxEAPTLSServerTrustConfigPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxEAPTLSServerTrustPanel(eap::config_tls &cfg, wxWindow* parent);
|
||||
wxEAPTLSServerTrustPanel(_Tprov &prov, eap::config_tls &cfg, wxWindow* parent) :
|
||||
m_prov(prov),
|
||||
m_cfg(cfg),
|
||||
wxEAPTLSServerTrustConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_certmgr.load(_T("certmgr.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_server_trust_icon, m_icon, m_certmgr, MAKEINTRESOURCE(218));
|
||||
|
||||
// Do not use cfg.m_server_names directly, so we can decide not to store the value in case of provider-locked configuration.
|
||||
// Never rely on control disabled state alone, as they can be enabled using external tool like Spy++.
|
||||
m_server_names->SetValidator(wxFQDNListValidator(&m_server_names_val));
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
virtual void OnRootCA(wxCommandEvent& event);
|
||||
virtual void OnRootCADClick(wxCommandEvent& event);
|
||||
virtual void OnRootCAAddStore(wxCommandEvent& event);
|
||||
virtual void OnRootCAAddFile(wxCommandEvent& event);
|
||||
virtual void OnRootCARemove(wxCommandEvent& event);
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
if (m_prov.m_read_only) {
|
||||
// This is provider-locked configuration. Disable controls.
|
||||
m_root_ca_add_store->Enable(false);
|
||||
m_root_ca_add_file ->Enable(false);
|
||||
m_root_ca_remove ->Enable(false);
|
||||
m_server_names ->Enable(false);
|
||||
}
|
||||
|
||||
// Populate trusted CA list.
|
||||
for (std::list<winstd::cert_context>::const_iterator cert = m_cfg.m_trusted_root_ca.cbegin(), cert_end = m_cfg.m_trusted_root_ca.cend(); cert != cert_end; ++cert) {
|
||||
winstd::tstring name;
|
||||
if (CertGetNameString(*cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name) > 0)
|
||||
m_root_ca->Append(wxString(name), new wxCertificateClientData(cert->duplicate()));
|
||||
}
|
||||
|
||||
// Set server acceptable names. The edit control will get populated by validator.
|
||||
m_server_names_val = m_cfg.m_server_names;
|
||||
|
||||
return wxEAPTLSServerTrustConfigPanelBase::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(wxEAPTLSServerTrustConfigPanelBase::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Save the data.
|
||||
|
||||
// Parse trusted CA list.
|
||||
m_cfg.m_trusted_root_ca.clear();
|
||||
for (unsigned int i = 0, i_end = m_root_ca->GetCount(); i < i_end; i++) {
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(m_root_ca->GetClientObject(i));
|
||||
if (cert)
|
||||
m_cfg.add_trusted_ca(cert->m_cert->dwCertEncodingType, cert->m_cert->pbCertEncoded, cert->m_cert->cbCertEncoded);
|
||||
}
|
||||
|
||||
// Save acceptable server names.
|
||||
m_cfg.m_server_names = m_server_names_val;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdateUI(wxUpdateUIEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Selectively enable/disable controls.
|
||||
wxArrayInt selections;
|
||||
m_root_ca_remove->Enable(m_root_ca->GetSelections(selections) ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnRootCADClick(wxCommandEvent& event)
|
||||
{
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(event.GetClientObject());
|
||||
if (cert)
|
||||
CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, cert->m_cert, this->GetHWND(), NULL, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
virtual void OnRootCAAddStore(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
winstd::cert_store store;
|
||||
if (store.create(NULL, _T("ROOT"))) {
|
||||
winstd::cert_context cert;
|
||||
cert.attach(CryptUIDlgSelectCertificateFromStore(store, this->GetHWND(), NULL, NULL, 0, 0, NULL));
|
||||
if (cert)
|
||||
AddRootCA(cert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnRootCAAddFile(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
const wxString separator(wxT("|"));
|
||||
wxFileDialog open_dialog(this, _("Add Certificate"), wxEmptyString, wxEmptyString,
|
||||
_("Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.p7b;*.pem") + separator +
|
||||
_("X.509 Certificate Files (*.cer;*.crt;*.der;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.pem") + separator +
|
||||
_("PKCS #7 Certificate Files (*.p7b)") + separator + wxT("*.p7b") + separator +
|
||||
_("All Files (*.*)") + separator + wxT("*.*"),
|
||||
wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_MULTIPLE);
|
||||
if (open_dialog.ShowModal() == wxID_CANCEL) {
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
wxArrayString paths;
|
||||
open_dialog.GetPaths(paths);
|
||||
for (size_t i = 0, i_end = paths.GetCount(); i < i_end; i++) {
|
||||
// Load certificate(s) from file.
|
||||
winstd::cert_store cs;
|
||||
if (cs.create(CERT_STORE_PROV_FILENAME, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, NULL, CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, (LPCTSTR)(paths[i]))) {
|
||||
for (PCCERT_CONTEXT cert = NULL; (cert = CertEnumCertificatesInStore(cs, cert)) != NULL;)
|
||||
AddRootCA(cert);
|
||||
} else
|
||||
wxMessageBox(wxString::Format(_("Invalid or unsupported certificate file %s"), paths[i]), _("Error"), wxOK | wxICON_EXCLAMATION, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnRootCARemove(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
wxArrayInt selections;
|
||||
for (int i = m_root_ca->GetSelections(selections); i--; )
|
||||
m_root_ca->Delete(selections[i]);
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
///
|
||||
@ -298,34 +432,110 @@ protected:
|
||||
/// - \c true if certificate was added;
|
||||
/// - \c false if duplicate found or an error occured.
|
||||
///
|
||||
bool AddRootCA(PCCERT_CONTEXT cert);
|
||||
bool AddRootCA(PCCERT_CONTEXT cert)
|
||||
{
|
||||
for (unsigned int i = 0, i_end = m_root_ca->GetCount(); i < i_end; i++) {
|
||||
wxCertificateClientData *c = dynamic_cast<wxCertificateClientData*>(m_root_ca->GetClientObject(i));
|
||||
if (c && c->m_cert &&
|
||||
c->m_cert->cbCertEncoded == cert->cbCertEncoded &&
|
||||
memcmp(c->m_cert->pbCertEncoded, cert->pbCertEncoded, cert->cbCertEncoded) == 0)
|
||||
{
|
||||
// This certificate is already on the list.
|
||||
m_root_ca->SetSelection(i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add certificate to the list.
|
||||
winstd::tstring name;
|
||||
if (CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name) > 0) {
|
||||
int i = m_root_ca->Append(wxString(name), new wxCertificateClientData(CertDuplicateCertificateContext(cert)));
|
||||
if (0 <= i) {
|
||||
m_root_ca->SetSelection(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
eap::config_tls &m_cfg; ///< TLS configuration
|
||||
winstd::library m_certmgr; ///< certmgr.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
_Tprov &m_prov; ///< EAP provider
|
||||
eap::config_tls &m_cfg; ///< TLS configuration
|
||||
winstd::library m_certmgr; ///< certmgr.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
std::list<std::string> m_server_names_val; ///< Acceptable authenticating server names
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPTLSCredentialsConfigPanel : public wxEAPCredentialsConfigPanel<_Tprov, eap::config_tls, wxEAPTLSCredentialsPanel>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credential configuration panel
|
||||
///
|
||||
/// \param[inout] 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
|
||||
///
|
||||
wxEAPTLSCredentialsConfigPanel(_Tprov &prov, eap::config_tls &cfg, LPCTSTR pszCredTarget, wxWindow *parent) :
|
||||
wxEAPCredentialsConfigPanel<_Tprov, eap::config_tls, wxEAPTLSCredentialsPanel>(prov, cfg, pszCredTarget, parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPTLSConfigPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxEAPTLSConfigPanel(eap::config_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent);
|
||||
wxEAPTLSConfigPanel(_Tprov &prov, eap::config_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_server_trust = new wxEAPTLSServerTrustPanel<_Tprov>(prov, cfg, this);
|
||||
sb_content->Add(m_server_trust, 0, wxDOWN|wxEXPAND, 5);
|
||||
|
||||
m_credentials = new wxEAPTLSCredentialsConfigPanel<_Tprov>(prov, cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_credentials, 0, wxUP|wxEXPAND, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTLSConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructs the configuration panel
|
||||
///
|
||||
virtual ~wxEAPTLSConfigPanel();
|
||||
virtual ~wxEAPTLSConfigPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTLSConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event);
|
||||
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
m_server_trust->GetEventHandler()->ProcessEvent(event);
|
||||
if (m_credentials)
|
||||
m_credentials->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
wxEAPTLSServerTrustPanel *m_server_trust; ///< Server trust configuration panel
|
||||
wxEAPTLSCredentialsConfigPanel *m_credentials; ///< Credentials configuration panel
|
||||
wxEAPTLSServerTrustPanel<_Tprov> *m_server_trust; ///< Server trust configuration panel
|
||||
wxEAPTLSCredentialsConfigPanel<_Tprov> *m_credentials; ///< Credentials configuration panel
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ wxEAPTLSServerTrustConfigPanelBase::wxEAPTLSServerTrustConfigPanelBase( wxWindow
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
m_root_ca->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCA ), NULL, this );
|
||||
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnUpdateUI ) );
|
||||
m_root_ca->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCADClick ), NULL, this );
|
||||
m_root_ca_add_store->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCAAddStore ), NULL, this );
|
||||
m_root_ca_add_file->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCAAddFile ), NULL, this );
|
||||
@ -106,7 +106,7 @@ wxEAPTLSServerTrustConfigPanelBase::wxEAPTLSServerTrustConfigPanelBase( wxWindow
|
||||
wxEAPTLSServerTrustConfigPanelBase::~wxEAPTLSServerTrustConfigPanelBase()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_root_ca->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCA ), NULL, this );
|
||||
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnUpdateUI ) );
|
||||
m_root_ca->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCADClick ), NULL, this );
|
||||
m_root_ca_add_store->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCAAddStore ), NULL, this );
|
||||
m_root_ca_add_file->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPTLSServerTrustConfigPanelBase::OnRootCAAddFile ), NULL, this );
|
||||
|
@ -77,7 +77,7 @@
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<event name="OnUpdateUI">OnUpdateUI</event>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Server Trust</property>
|
||||
@ -431,7 +431,7 @@
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnListBox">OnRootCA</event>
|
||||
<event name="OnListBox"></event>
|
||||
<event name="OnListBoxDClick">OnRootCADClick</event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
|
@ -53,7 +53,7 @@ class wxEAPTLSServerTrustConfigPanelBase : public wxPanel
|
||||
wxStaticText* m_server_names_note;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnRootCA( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void OnRootCADClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRootCAAddStore( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRootCAAddFile( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
@ -25,8 +25,3 @@
|
||||
#include "../../../include/Version.h"
|
||||
|
||||
#include "../include/TLS_UI.h"
|
||||
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <cryptuiapi.h>
|
||||
|
@ -332,7 +332,7 @@ bool wxFQDNListValidator::Parse(const wxString &val_in, size_t i_start, size_t i
|
||||
// Skip trailing white-space.
|
||||
for (; i < i_end && _istspace(buf[i_end - 1]); i_end--);
|
||||
|
||||
if (wxHostNameValidator::Parse(val_in, i, i_end, ctrl, parent, fqdn)) {
|
||||
if (wxFQDNValidator::Parse(val_in, i, i_end, ctrl, parent, fqdn)) {
|
||||
// The rest of the FQDN list parsed succesfully.
|
||||
if (fqdn && !fqdn->empty()) _val_out.push_back(std::move(*fqdn));
|
||||
if (val_out) *val_out = std::move(_val_out);
|
||||
@ -349,7 +349,7 @@ bool wxFQDNListValidator::Parse(const wxString &val_in, size_t i_start, size_t i
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTLSCredentialsPanel::wxEAPTLSCredentialsPanel(eap::credentials_tls &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
|
||||
wxCredentialsPanel<wxEAPTLSCredentialsPanelBase, eap::credentials_tls>(cred, pszCredTarget, parent, is_config)
|
||||
wxCredentialsPanel<eap::credentials_tls, wxEAPTLSCredentialsPanelBase>(cred, pszCredTarget, parent, is_config)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
@ -359,8 +359,6 @@ wxEAPTLSCredentialsPanel::wxEAPTLSCredentialsPanel(eap::credentials_tls &cred, L
|
||||
|
||||
bool wxEAPTLSCredentialsPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(__super::TransferDataToWindow(), false);
|
||||
|
||||
// Populate certificate list.
|
||||
bool is_found = false;
|
||||
winstd::cert_store store;
|
||||
@ -400,7 +398,7 @@ bool wxEAPTLSCredentialsPanel::TransferDataToWindow()
|
||||
m_cert_select_val->SetSelection(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
return __super::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
@ -419,6 +417,8 @@ bool wxEAPTLSCredentialsPanel::TransferDataFromWindow()
|
||||
m_cred.clear();
|
||||
}
|
||||
|
||||
// Inherited TransferDataFromWindow() calls m_cred.store().
|
||||
// Therefore, call it only now, that m_cred is set.
|
||||
return __super::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
@ -428,192 +428,3 @@ void wxEAPTLSCredentialsPanel::OnCertSelect(wxCommandEvent& event)
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
m_cert_select_val->Enable(m_cert_select->GetValue());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTLSServerTrustPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTLSServerTrustPanel::wxEAPTLSServerTrustPanel(eap::config_tls &cfg, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
wxEAPTLSServerTrustConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_certmgr.load(_T("certmgr.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_server_trust_icon, m_icon, m_certmgr, MAKEINTRESOURCE(218));
|
||||
|
||||
m_server_names->SetValidator(wxFQDNListValidator(&(m_cfg.m_server_names)));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSServerTrustPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(wxEAPTLSServerTrustConfigPanelBase::TransferDataToWindow(), false);
|
||||
|
||||
// Populate trusted CA list.
|
||||
for (std::list<winstd::cert_context>::const_iterator cert = m_cfg.m_trusted_root_ca.cbegin(), cert_end = m_cfg.m_trusted_root_ca.cend(); cert != cert_end; ++cert) {
|
||||
winstd::tstring name;
|
||||
if (CertGetNameString(*cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name) > 0)
|
||||
m_root_ca->Append(wxString(name), new wxCertificateClientData(cert->duplicate()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSServerTrustPanel::TransferDataFromWindow()
|
||||
{
|
||||
// Parse trusted CA list.
|
||||
m_cfg.m_trusted_root_ca.clear();
|
||||
for (unsigned int i = 0, i_end = m_root_ca->GetCount(); i < i_end; i++) {
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(m_root_ca->GetClientObject(i));
|
||||
if (cert)
|
||||
m_cfg.add_trusted_ca(cert->m_cert->dwCertEncodingType, cert->m_cert->pbCertEncoded, cert->m_cert->cbCertEncoded);
|
||||
}
|
||||
|
||||
return wxEAPTLSServerTrustConfigPanelBase::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCA(wxCommandEvent& event)
|
||||
{
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(event.GetClientObject());
|
||||
m_root_ca_remove->Enable(cert ? true : false);
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCADClick(wxCommandEvent& event)
|
||||
{
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(event.GetClientObject());
|
||||
if (cert)
|
||||
CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, cert->m_cert, this->GetHWND(), NULL, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCAAddStore(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
winstd::cert_store store;
|
||||
if (store.create(NULL, _T("ROOT"))) {
|
||||
winstd::cert_context cert;
|
||||
cert.attach(CryptUIDlgSelectCertificateFromStore(store, this->GetHWND(), NULL, NULL, 0, 0, NULL));
|
||||
if (cert)
|
||||
AddRootCA(cert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCAAddFile(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
const wxString separator(wxT("|"));
|
||||
wxFileDialog open_dialog(this, _("Add Certificate"), wxEmptyString, wxEmptyString,
|
||||
_("Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.p7b;*.pem") + separator +
|
||||
_("X.509 Certificate Files (*.cer;*.crt;*.der;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.pem") + separator +
|
||||
_("PKCS #7 Certificate Files (*.p7b)") + separator + wxT("*.p7b") + separator +
|
||||
_("All Files (*.*)") + separator + wxT("*.*"),
|
||||
wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_MULTIPLE);
|
||||
if (open_dialog.ShowModal() == wxID_CANCEL) {
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
wxArrayString paths;
|
||||
open_dialog.GetPaths(paths);
|
||||
for (size_t i = 0, i_end = paths.GetCount(); i < i_end; i++) {
|
||||
// Load certificate(s) from file.
|
||||
winstd::cert_store cs;
|
||||
if (cs.create(CERT_STORE_PROV_FILENAME, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, NULL, CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, (LPCTSTR)(paths[i]))) {
|
||||
for (PCCERT_CONTEXT cert = NULL; (cert = CertEnumCertificatesInStore(cs, cert)) != NULL;)
|
||||
AddRootCA(cert);
|
||||
} else
|
||||
wxMessageBox(wxString::Format(_("Invalid or unsupported certificate file %s"), paths[i]), _("Error"), wxOK | wxICON_EXCLAMATION, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCARemove(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
wxArrayInt selections;
|
||||
for (int i = m_root_ca->GetSelections(selections); i--; )
|
||||
m_root_ca->Delete(selections[i]);
|
||||
|
||||
m_root_ca_remove->Enable(false);
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSServerTrustPanel::AddRootCA(PCCERT_CONTEXT cert)
|
||||
{
|
||||
for (unsigned int i = 0, i_end = m_root_ca->GetCount(); i < i_end; i++) {
|
||||
wxCertificateClientData *c = dynamic_cast<wxCertificateClientData*>(m_root_ca->GetClientObject(i));
|
||||
if (c && c->m_cert &&
|
||||
c->m_cert->cbCertEncoded == cert->cbCertEncoded &&
|
||||
memcmp(c->m_cert->pbCertEncoded, cert->pbCertEncoded, cert->cbCertEncoded) == 0)
|
||||
{
|
||||
// This certificate is already on the list.
|
||||
m_root_ca->SetSelection(i);
|
||||
m_root_ca_remove->Enable();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add certificate to the list.
|
||||
winstd::tstring name;
|
||||
if (CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name) > 0) {
|
||||
int i = m_root_ca->Append(wxString(name), new wxCertificateClientData(CertDuplicateCertificateContext(cert)));
|
||||
if (0 <= i) {
|
||||
m_root_ca->SetSelection(i);
|
||||
m_root_ca_remove->Enable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTLSConfigPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTLSConfigPanel::wxEAPTLSConfigPanel(eap::config_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_server_trust = new wxEAPTLSServerTrustPanel(cfg, this);
|
||||
if (cfg.m_allow_save) {
|
||||
sb_content->Add(m_server_trust, 0, wxDOWN|wxEXPAND, 5);
|
||||
m_credentials = new wxEAPTLSCredentialsConfigPanel(cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_credentials, 0, wxUP|wxEXPAND, 5);
|
||||
} else {
|
||||
sb_content->Add(m_server_trust, 0, wxEXPAND, 5);
|
||||
m_credentials = NULL;
|
||||
}
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTLSConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxEAPTLSConfigPanel::~wxEAPTLSConfigPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTLSConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSConfigPanel::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
m_server_trust->GetEventHandler()->ProcessEvent(event);
|
||||
if (m_credentials)
|
||||
m_credentials->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
@ -87,7 +87,6 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\res\wxTTLS_UI.cpp" />
|
||||
<ClCompile Include="..\src\Module.cpp" />
|
||||
<ClCompile Include="..\src\TTLS_UI.cpp" />
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
|
@ -32,9 +32,6 @@
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TTLS_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\res\wxTTLS_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -21,12 +21,12 @@
|
||||
///
|
||||
/// EAPTTLS configuration panel
|
||||
///
|
||||
class wxEAPTTLSConfigPanel;
|
||||
template <class _Tprov> class wxEAPTTLSConfigPanel;
|
||||
|
||||
///
|
||||
/// EAPTTLS configuration
|
||||
///
|
||||
class wxEAPTTLSConfig;
|
||||
template <class _Tprov> class wxEAPTTLSConfig;
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -46,28 +46,89 @@ class wxEAPTTLSConfig;
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPTTLSConfigPanel : public wxEAPTTLSConfigPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxEAPTTLSConfigPanel(eap::config_ttls &cfg, wxWindow* parent);
|
||||
wxEAPTTLSConfigPanel(_Tprov &prov, eap::config_ttls &cfg, wxWindow* parent) :
|
||||
m_prov(prov),
|
||||
m_cfg(cfg),
|
||||
wxEAPTTLSConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_outer_identity_icon, m_icon, m_shell32, MAKEINTRESOURCE(265));
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
virtual void OnOuterIdentityCustom(wxCommandEvent& event);
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
if (m_prov.m_read_only) {
|
||||
// This is provider-locked configuration. Disable controls.
|
||||
m_outer_identity_same ->Enable(false);
|
||||
m_outer_identity_empty ->Enable(false);
|
||||
m_outer_identity_custom ->Enable(false);
|
||||
m_outer_identity_custom_val->Enable(false);
|
||||
}
|
||||
|
||||
// Populate identity controls.
|
||||
if (m_cfg.m_anonymous_identity.empty()) {
|
||||
m_outer_identity_same->SetValue(true);
|
||||
} else if (m_cfg.m_anonymous_identity == L"@") {
|
||||
m_outer_identity_empty->SetValue(true);
|
||||
} else {
|
||||
m_outer_identity_custom->SetValue(true);
|
||||
m_outer_identity_custom_val->SetValue(m_cfg.m_anonymous_identity);
|
||||
}
|
||||
|
||||
return wxEAPTTLSConfigPanelBase::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(wxEAPTTLSConfigPanelBase::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Save the data.
|
||||
if (m_outer_identity_same->GetValue())
|
||||
m_cfg.m_anonymous_identity.clear();
|
||||
else if (m_outer_identity_empty->GetValue())
|
||||
m_cfg.m_anonymous_identity = L"@";
|
||||
else
|
||||
m_cfg.m_anonymous_identity = m_outer_identity_custom_val->GetValue();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdateUI(wxUpdateUIEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Selectively enable/disable controls.
|
||||
m_outer_identity_custom_val->Enable(m_outer_identity_custom->GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
eap::config_ttls &m_cfg; ///< TLS configuration
|
||||
_Tprov &m_prov; ///< EAP provider
|
||||
eap::config_ttls &m_cfg; ///< TTLS configuration
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPTTLSConfig : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
@ -78,25 +139,134 @@ public:
|
||||
/// \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
|
||||
///
|
||||
wxEAPTTLSConfig(eap::config_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent);
|
||||
wxEAPTTLSConfig(_Tprov &prov, eap::config_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) :
|
||||
m_prov(prov),
|
||||
m_cfg(cfg),
|
||||
m_cfg_pap(cfg.m_module),
|
||||
wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
if (prov.m_read_only)
|
||||
sb_content->Add(new wxEAPProviderLocked<_Tprov>(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);
|
||||
|
||||
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<_Tprov>(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);
|
||||
|
||||
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_identity = new wxEAPTTLSConfigPanel<_Tprov>(prov, m_cfg, this);
|
||||
sb_content->Add(m_outer_identity, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_tls = new wxEAPTLSConfigPanel<_Tprov>(prov, m_cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_tls, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
wxSize size = sb_content->CalcMin();
|
||||
if (size.y > 500) {
|
||||
// Increase the width to allow space for vertical scroll bar (to prevent horizontal one) and truncate the height.
|
||||
size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
|
||||
size.y = 500;
|
||||
}
|
||||
this->SetMinSize(size);
|
||||
this->SetScrollRate(5, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
m_inner_type->SetFocusFromKbd();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTTLSConfig::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Destructs the configuration panel
|
||||
///
|
||||
virtual ~wxEAPTTLSConfig();
|
||||
virtual ~wxEAPTTLSConfig()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTTLSConfig::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event);
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
if (m_prov.m_read_only) {
|
||||
// This is provider-locked configuration. Disable controls.
|
||||
m_inner_type->GetChoiceCtrl()->Enable(false);
|
||||
}
|
||||
|
||||
eap::config_pap *cfg_pap = dynamic_cast<eap::config_pap*>(m_cfg.m_inner);
|
||||
if (cfg_pap) {
|
||||
m_cfg_pap = *cfg_pap;
|
||||
m_inner_type->SetSelection(0); // 0=PAP
|
||||
} else
|
||||
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
|
||||
|
||||
// Do not invoke inherited TransferDataToWindow(), as it will call others TransferDataToWindow().
|
||||
// This will handle wxEAPTTLSConfig::OnInitDialog() via wxEVT_INIT_DIALOG forwarding.
|
||||
return true /*wxScrolledWindow::TransferDataToWindow()*/;
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(wxScrolledWindow::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Save the data.
|
||||
switch (m_inner_type->GetSelection()) {
|
||||
case 0: // 0=PAP
|
||||
delete m_cfg.m_inner;
|
||||
m_cfg.m_inner = new eap::config_pap(m_cfg_pap);
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Call TransferDataToWindow() manually, as wxScrolledWindow somehow skips that.
|
||||
TransferDataToWindow();
|
||||
|
||||
// Forward the event to child panels.
|
||||
m_outer_identity->GetEventHandler()->ProcessEvent(event);
|
||||
m_tls->GetEventHandler()->ProcessEvent(event);
|
||||
for (wxWindowList::compatibility_iterator inner = m_inner_type->GetChildren().GetFirst(); inner; inner = inner->GetNext())
|
||||
inner->GetData()->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tprov &m_prov; ///< EAP provider
|
||||
eap::config_ttls &m_cfg; ///< TTLS configuration
|
||||
wxStaticText *m_outer_title; ///< Outer authentication title
|
||||
wxEAPTTLSConfigPanel *m_outer_identity; ///< Outer identity configuration panel
|
||||
wxEAPTLSConfigPanel *m_tls; ///< TLS configuration panel
|
||||
wxEAPTTLSConfigPanel<_Tprov> *m_outer_identity; ///< Outer identity configuration panel
|
||||
wxEAPTLSConfigPanel<_Tprov> *m_tls; ///< TLS configuration panel
|
||||
wxStaticText *m_inner_title; ///< Inner authentication title
|
||||
wxChoicebook *m_inner_type; ///< Inner authentication type
|
||||
|
||||
|
@ -72,12 +72,12 @@ wxEAPTTLSConfigPanelBase::wxEAPTTLSConfigPanelBase( wxWindow* parent, wxWindowID
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
m_outer_identity_custom->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( wxEAPTTLSConfigPanelBase::OnOuterIdentityCustom ), NULL, this );
|
||||
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPTTLSConfigPanelBase::OnUpdateUI ) );
|
||||
}
|
||||
|
||||
wxEAPTTLSConfigPanelBase::~wxEAPTTLSConfigPanelBase()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_outer_identity_custom->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( wxEAPTTLSConfigPanelBase::OnOuterIdentityCustom ), NULL, this );
|
||||
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPTTLSConfigPanelBase::OnUpdateUI ) );
|
||||
|
||||
}
|
||||
|
@ -77,7 +77,7 @@
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<event name="OnUpdateUI">OnUpdateUI</event>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Outer Identity</property>
|
||||
@ -541,7 +541,7 @@
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRadioButton">OnOuterIdentityCustom</event>
|
||||
<event name="OnRadioButton"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
|
@ -45,7 +45,7 @@ class wxEAPTTLSConfigPanelBase : public wxPanel
|
||||
wxTextCtrl* m_outer_identity_custom_val;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnOuterIdentityCustom( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
@ -50,7 +50,7 @@ bool eap::peer_ttls_ui::invoke_config_ui(
|
||||
wxTopLevelWindows.Append(&parent);
|
||||
|
||||
// Create and launch configuration dialog.
|
||||
wxEAPConfigDialog<config_ttls, wxEAPTTLSConfig> dlg(cfg, &parent);
|
||||
wxEAPConfigDialog<config_ttls, wxEAPTTLSConfig<provider_config_type> > dlg(cfg, &parent);
|
||||
result = dlg.ShowModal();
|
||||
|
||||
wxTopLevelWindows.DeleteObject(&parent);
|
||||
|
@ -1,184 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 Amebis
|
||||
Copyright 2016 GÉANT
|
||||
|
||||
This file is part of GÉANTLink.
|
||||
|
||||
GÉANTLink is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GÉANTLink is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTTLSConfigPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTTLSConfigPanel::wxEAPTTLSConfigPanel(eap::config_ttls &cfg, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
wxEAPTTLSConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_outer_identity_icon, m_icon, m_shell32, MAKEINTRESOURCE(265));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfigPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(wxEAPTTLSConfigPanelBase::TransferDataToWindow(), false);
|
||||
|
||||
// Populate identity controls.
|
||||
if (m_cfg.m_anonymous_identity.empty()) {
|
||||
m_outer_identity_same->SetValue(true);
|
||||
m_outer_identity_custom_val->Enable(false);
|
||||
} else if (m_cfg.m_anonymous_identity == L"@") {
|
||||
m_outer_identity_empty->SetValue(true);
|
||||
m_outer_identity_custom_val->Enable(false);
|
||||
} else {
|
||||
m_outer_identity_custom->SetValue(true);
|
||||
m_outer_identity_custom_val->Enable(true);
|
||||
m_outer_identity_custom_val->SetValue(m_cfg.m_anonymous_identity);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfigPanel::TransferDataFromWindow()
|
||||
{
|
||||
if (m_outer_identity_same->GetValue())
|
||||
m_cfg.m_anonymous_identity.clear();
|
||||
else if (m_outer_identity_empty->GetValue())
|
||||
m_cfg.m_anonymous_identity = L"@";
|
||||
else
|
||||
m_cfg.m_anonymous_identity = m_outer_identity_custom_val->GetValue();
|
||||
|
||||
return wxEAPTTLSConfigPanelBase::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTTLSConfigPanel::OnOuterIdentityCustom(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
m_outer_identity_custom_val->Enable(m_outer_identity_custom->GetValue());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTTLSConfig
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTTLSConfig::wxEAPTTLSConfig(eap::config_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
m_cfg_pap(cfg.m_module),
|
||||
wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
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);
|
||||
|
||||
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(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);
|
||||
|
||||
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_identity = new wxEAPTTLSConfigPanel(m_cfg, this);
|
||||
sb_content->Add(m_outer_identity, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_tls = new wxEAPTLSConfigPanel(m_cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_tls, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
wxSize size = sb_content->CalcMin();
|
||||
if (size.y > 500) {
|
||||
// Increase the width to allow space for vertical scroll bar (to prevent horizontal one) and truncate the height.
|
||||
size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
|
||||
size.y = 500;
|
||||
}
|
||||
this->SetMinSize(size);
|
||||
this->SetScrollRate(5, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
m_outer_identity->SetFocusFromKbd();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTTLSConfig::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxEAPTTLSConfig::~wxEAPTTLSConfig()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTTLSConfig::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfig::TransferDataToWindow()
|
||||
{
|
||||
eap::config_pap *cfg_pap = dynamic_cast<eap::config_pap*>(m_cfg.m_inner);
|
||||
if (cfg_pap) {
|
||||
m_cfg_pap = *cfg_pap;
|
||||
m_inner_type->SetSelection(0); // 0=PAP
|
||||
} else
|
||||
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
|
||||
|
||||
// Do not invoke inherited TransferDataToWindow(), as it will call others TransferDataToWindow().
|
||||
// This will handle wxEAPTTLSConfig::OnInitDialog() via wxEVT_INIT_DIALOG forwarding.
|
||||
return true /*wxScrolledWindow::TransferDataToWindow()*/;
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfig::TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(wxScrolledWindow::TransferDataFromWindow(), false);
|
||||
|
||||
switch (m_inner_type->GetSelection()) {
|
||||
case 0: // 0=PAP
|
||||
delete m_cfg.m_inner;
|
||||
m_cfg.m_inner = new eap::config_pap(m_cfg_pap);
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTTLSConfig::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Call TransferDataToWindow() manually, as wxScrolledWindow somehow skips that.
|
||||
TransferDataToWindow();
|
||||
|
||||
// Forward the event to child panels.
|
||||
m_outer_identity->GetEventHandler()->ProcessEvent(event);
|
||||
m_tls->GetEventHandler()->ProcessEvent(event);
|
||||
for (wxWindowList::compatibility_iterator inner = m_inner_type->GetChildren().GetFirst(); inner; inner = inner->GetNext())
|
||||
inner->GetData()->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit 7510410b5660ba9027feb432f8f18940e000f376
|
||||
Subproject commit 5d47a19972d64b7f537b675fcbf435759d9c95e5
|
Loading…
x
Reference in New Issue
Block a user