diff --git a/lib/EAPBase/include/Credentials.h b/lib/EAPBase/include/Credentials.h index cca38ca..bcf4aec 100644 --- a/lib/EAPBase/include/Credentials.h +++ b/lib/EAPBase/include/Credentials.h @@ -239,6 +239,11 @@ namespace eap /// virtual std::wstring get_identity() const = 0; + /// + /// Returns credential name (for GUI display). + /// + virtual winstd::tstring get_name() const; + protected: /// \name Storage /// @{ diff --git a/lib/EAPBase/src/Credentials.cpp b/lib/EAPBase/src/Credentials.cpp index c6c35cb..cdb6207 100644 --- a/lib/EAPBase/src/Credentials.cpp +++ b/lib/EAPBase/src/Credentials.cpp @@ -96,6 +96,12 @@ bool eap::credentials::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppE } +tstring eap::credentials::get_name() const +{ + return get_identity(); +} + + ////////////////////////////////////////////////////////////////////// // eap::credentials_pass ////////////////////////////////////////////////////////////////////// diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 81b3fcf..a157585 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -432,7 +432,7 @@ protected: m_own_clear ->Enable(false); } - m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.get_identity() : _("")); + m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.get_name() : _("")); if (!m_prov.m_read_only) { // This is not a provider-locked configuration. Selectively enable/disable controls. diff --git a/lib/TLS/include/Credentials.h b/lib/TLS/include/Credentials.h index a0f9ab8..5bfd224 100644 --- a/lib/TLS/include/Credentials.h +++ b/lib/TLS/include/Credentials.h @@ -192,6 +192,11 @@ namespace eap /// virtual std::wstring get_identity() const; + /// + /// Returns credential name (for GUI display). + /// + virtual winstd::tstring get_name() const; + protected: /// \name Storage /// @{ diff --git a/lib/TLS/src/Credentials.cpp b/lib/TLS/src/Credentials.cpp index 768ef2d..e65529f 100644 --- a/lib/TLS/src/Credentials.cpp +++ b/lib/TLS/src/Credentials.cpp @@ -156,7 +156,7 @@ bool eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR * m_cert.create(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, aData.data(), (DWORD)aData.size()); } } - m_module.log_config((xpath + L"/ClientCertificate").c_str(), m_cert ? eap::get_cert_title(m_cert).c_str() : L""); + m_module.log_config((xpath + L"/ClientCertificate").c_str(), get_name().c_str()); return true; } @@ -177,11 +177,11 @@ bool eap::credentials_tls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **p } tstring target(target_name(pszTargetName)); - wstring identity(std::move(get_identity())); + wstring name(std::move(get_name())); // Write credentials. - assert(cred_enc.cbData < CRED_MAX_CREDENTIAL_BLOB_SIZE); - assert(identity.length() < CRED_MAX_USERNAME_LENGTH ); + assert(cred_enc.cbData < CRED_MAX_CREDENTIAL_BLOB_SIZE); + assert(name.length() < CRED_MAX_USERNAME_LENGTH ); CREDENTIAL cred = { 0, // Flags CRED_TYPE_GENERIC, // Type @@ -194,7 +194,7 @@ bool eap::credentials_tls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **p 0, // AttributeCount NULL, // Attributes NULL, // TargetAlias - (LPTSTR)identity.c_str() // UserName + (LPTSTR)name.c_str() // UserName }; if (!CredWrite(&cred, 0)) { *ppEapError = m_module.make_error(GetLastError(), _T(__FUNCTION__) _T(" CredWrite failed.")); @@ -232,7 +232,7 @@ bool eap::credentials_tls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR return false; } - m_module.log_config((wstring(pszTargetName) + L"/Certificate").c_str(), m_cert ? eap::get_cert_title(m_cert).c_str() : L""); + m_module.log_config((wstring(pszTargetName) + L"/Certificate").c_str(), get_name().c_str()); return true; } @@ -250,6 +250,13 @@ std::wstring eap::credentials_tls::get_identity() const } + +tstring eap::credentials_tls::get_name() const +{ + return m_cert ? std::move(eap::get_cert_title(m_cert)) : L""; +} + + LPCTSTR eap::credentials_tls::target_suffix() const { return _T("TLS");