eap::credentials::get_name() method introduced to allow more detailed display of certificate names

This commit is contained in:
Simon Rozman 2016-07-20 10:05:36 +02:00
parent 4f6943044f
commit a92cafea36
5 changed files with 30 additions and 7 deletions

View File

@ -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
/// @{

View File

@ -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
//////////////////////////////////////////////////////////////////////

View File

@ -432,7 +432,7 @@ protected:
m_own_clear ->Enable(false);
}
m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.get_identity() : _("<blank>"));
m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.get_name() : _("<blank>"));
if (!m_prov.m_read_only) {
// This is not a provider-locked configuration. Selectively enable/disable controls.

View File

@ -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
/// @{

View File

@ -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"<blank>");
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"<blank>");
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"<blank>";
}
LPCTSTR eap::credentials_tls::target_suffix() const
{
return _T("TLS");