Rename credentials_ttls => credentials_tls_tunnel to make reusable

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-01-14 15:09:10 +01:00
parent 04e6b7064f
commit a943a14d0f
8 changed files with 43 additions and 43 deletions

View File

@ -118,7 +118,7 @@ namespace eap
/// ///
/// @copydoc eap::config_method::make_credentials() /// @copydoc eap::config_method::make_credentials()
/// \returns This implementation always returns `eap::credentials_ttls` type of credentials /// \returns This implementation always returns `eap::credentials_tls_tunnel` type of credentials
/// ///
virtual credentials* make_credentials() const; virtual credentials* make_credentials() const;

View File

@ -20,7 +20,7 @@
namespace eap namespace eap
{ {
class credentials_ttls; class credentials_tls_tunnel;
} }
#pragma once #pragma once
@ -38,9 +38,9 @@ namespace eap
/// @{ /// @{
/// ///
/// TTLS credentials /// TLS tunnel credentials
/// ///
class credentials_ttls : public credentials_tls class credentials_tls_tunnel : public credentials_tls
{ {
public: public:
/// ///
@ -48,21 +48,21 @@ namespace eap
/// ///
/// \param[in] mod EAP module to use for global services /// \param[in] mod EAP module to use for global services
/// ///
credentials_ttls(_In_ module &mod); credentials_tls_tunnel(_In_ module &mod);
/// ///
/// Copies credentials /// Copies credentials
/// ///
/// \param[in] other Credentials to copy from /// \param[in] other Credentials to copy from
/// ///
credentials_ttls(_In_ const credentials_ttls &other); credentials_tls_tunnel(_In_ const credentials_tls_tunnel &other);
/// ///
/// Moves credentials /// Moves credentials
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_ttls(_Inout_ credentials_ttls &&other) noexcept; credentials_tls_tunnel(_Inout_ credentials_tls_tunnel &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -71,7 +71,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
credentials_ttls& operator=(_In_ const credentials_ttls &other); credentials_tls_tunnel& operator=(_In_ const credentials_tls_tunnel &other);
/// ///
/// Moves credentials /// Moves credentials
@ -80,7 +80,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
credentials_ttls& operator=(_Inout_ credentials_ttls &&other) noexcept; credentials_tls_tunnel& operator=(_Inout_ credentials_tls_tunnel &&other) noexcept;
virtual config* clone() const; virtual config* clone() const;
virtual void clear(); virtual void clear();
@ -116,7 +116,7 @@ namespace eap
/// ///
/// \param[in] dwFlags A combination of [EAP flags](https://msdn.microsoft.com/en-us/library/windows/desktop/bb891975.aspx) that describe the EAP authentication session behavior /// \param[in] dwFlags A combination of [EAP flags](https://msdn.microsoft.com/en-us/library/windows/desktop/bb891975.aspx) that describe the EAP authentication session behavior
/// \param[in] hTokenImpersonateUser Impersonation token for a logged-on user to collect user-related information /// \param[in] hTokenImpersonateUser Impersonation token for a logged-on user to collect user-related information
/// \param[in] cred_cached Cached credentials (optional, can be \c NULL, must be `credentials_ttls*` type) /// \param[in] cred_cached Cached credentials (optional, can be \c NULL, must be `credentials_tls_tunnel*` type)
/// \param[in] cfg Method configuration (unused, as must be as config_method_ttls is not derived from `config_method_with_cred`) /// \param[in] cfg Method configuration (unused, as must be as config_method_ttls is not derived from `config_method_with_cred`)
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from (optional, can be \c NULL) /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from (optional, can be \c NULL)
/// ///

View File

@ -190,7 +190,7 @@ namespace eap
/// \param[in] cred User credentials /// \param[in] cred User credentials
/// \param[in] inner Inner method /// \param[in] inner Inner method
/// ///
method_ttls(_In_ module &mod, _In_ config_method_ttls &cfg, _In_ credentials_ttls &cred, _In_ method *inner); method_ttls(_In_ module &mod, _In_ config_method_ttls &cfg, _In_ credentials_tls_tunnel &cred, _In_ method *inner);
/// \name Session management /// \name Session management
/// @{ /// @{
@ -230,7 +230,7 @@ namespace eap
protected: protected:
config_method_ttls &m_cfg; ///< Method configuration config_method_ttls &m_cfg; ///< Method configuration
credentials_ttls &m_cred; ///< Method user credentials credentials_tls_tunnel &m_cred; ///< Method user credentials
HANDLE m_user_ctx; ///< Handle to user context HANDLE m_user_ctx; ///< Handle to user context
winstd::tstring m_sc_target_name; ///< Schannel target name winstd::tstring m_sc_target_name; ///< Schannel target name
winstd::sec_credentials m_sc_cred; ///< Schannel client credentials winstd::sec_credentials m_sc_cred; ///< Schannel client credentials

View File

@ -231,7 +231,7 @@ const wchar_t* eap::config_method_ttls::get_method_str() const
eap::credentials* eap::config_method_ttls::make_credentials() const eap::credentials* eap::config_method_ttls::make_credentials() const
{ {
credentials_ttls *cred = new credentials_ttls(m_module); credentials_tls_tunnel *cred = new credentials_tls_tunnel(m_module);
cred->m_inner.reset(m_inner->make_credentials()); cred->m_inner.reset(m_inner->make_credentials());
return cred; return cred;
} }

View File

@ -25,30 +25,30 @@ using namespace winstd;
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// eap::credentials_ttls // eap::credentials_tls_tunnel
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
eap::credentials_ttls::credentials_ttls(_In_ module &mod) : eap::credentials_tls_tunnel::credentials_tls_tunnel(_In_ module &mod) :
credentials_tls(mod) credentials_tls(mod)
{ {
} }
eap::credentials_ttls::credentials_ttls(_In_ const credentials_ttls &other) : eap::credentials_tls_tunnel::credentials_tls_tunnel(_In_ const credentials_tls_tunnel &other) :
m_inner(other.m_inner ? dynamic_cast<credentials*>(other.m_inner->clone()) : nullptr), m_inner(other.m_inner ? dynamic_cast<credentials*>(other.m_inner->clone()) : nullptr),
credentials_tls(other) credentials_tls(other)
{ {
} }
eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) noexcept : eap::credentials_tls_tunnel::credentials_tls_tunnel(_Inout_ credentials_tls_tunnel &&other) noexcept :
m_inner(std::move(other.m_inner)), m_inner(std::move(other.m_inner)),
credentials_tls(std::move(other)) credentials_tls(std::move(other))
{ {
} }
eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_ttls &other) eap::credentials_tls_tunnel& eap::credentials_tls_tunnel::operator=(_In_ const credentials_tls_tunnel &other)
{ {
if (this != &other) { if (this != &other) {
(credentials_tls&)*this = other; (credentials_tls&)*this = other;
@ -59,7 +59,7 @@ eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_t
} }
eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other) noexcept eap::credentials_tls_tunnel& eap::credentials_tls_tunnel::operator=(_Inout_ credentials_tls_tunnel &&other) noexcept
{ {
if (this != &other) { if (this != &other) {
(credentials_tls&)*this = std::move(other); (credentials_tls&)*this = std::move(other);
@ -70,26 +70,26 @@ eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls
} }
eap::config* eap::credentials_ttls::clone() const eap::config* eap::credentials_tls_tunnel::clone() const
{ {
return new credentials_ttls(*this); return new credentials_tls_tunnel(*this);
} }
void eap::credentials_ttls::clear() void eap::credentials_tls_tunnel::clear()
{ {
credentials_tls::clear(); credentials_tls::clear();
m_inner->clear(); m_inner->clear();
} }
bool eap::credentials_ttls::empty() const bool eap::credentials_tls_tunnel::empty() const
{ {
return credentials_tls::empty() && m_inner->empty(); return credentials_tls::empty() && m_inner->empty();
} }
void eap::credentials_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot) const void eap::credentials_tls_tunnel::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot) const
{ {
assert(pDoc); assert(pDoc);
assert(pConfigRoot); assert(pConfigRoot);
@ -108,7 +108,7 @@ void eap::credentials_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *p
} }
void eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot) void eap::credentials_tls_tunnel::load(_In_ IXMLDOMNode *pConfigRoot)
{ {
assert(pConfigRoot); assert(pConfigRoot);
HRESULT hr; HRESULT hr;
@ -124,14 +124,14 @@ void eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot)
} }
void eap::credentials_ttls::operator<<(_Inout_ cursor_out &cursor) const void eap::credentials_tls_tunnel::operator<<(_Inout_ cursor_out &cursor) const
{ {
credentials_tls::operator<<(cursor); credentials_tls::operator<<(cursor);
cursor << *m_inner; cursor << *m_inner;
} }
size_t eap::credentials_ttls::get_pk_size() const size_t eap::credentials_tls_tunnel::get_pk_size() const
{ {
return return
credentials_tls::get_pk_size() + credentials_tls::get_pk_size() +
@ -139,14 +139,14 @@ size_t eap::credentials_ttls::get_pk_size() const
} }
void eap::credentials_ttls::operator>>(_Inout_ cursor_in &cursor) void eap::credentials_tls_tunnel::operator>>(_Inout_ cursor_in &cursor)
{ {
credentials_tls::operator>>(cursor); credentials_tls::operator>>(cursor);
cursor >> *m_inner; cursor >> *m_inner;
} }
void eap::credentials_ttls::store(_In_z_ LPCTSTR pszTargetName, _In_ unsigned int level) const void eap::credentials_tls_tunnel::store(_In_z_ LPCTSTR pszTargetName, _In_ unsigned int level) const
{ {
assert(0); // Not that we would ever store inner&outer credentials to Windows Credential Manager joined, but for completness sake... Here we go: assert(0); // Not that we would ever store inner&outer credentials to Windows Credential Manager joined, but for completness sake... Here we go:
@ -156,7 +156,7 @@ void eap::credentials_ttls::store(_In_z_ LPCTSTR pszTargetName, _In_ unsigned in
} }
void eap::credentials_ttls::retrieve(_In_z_ LPCTSTR pszTargetName, _In_ unsigned int level) void eap::credentials_tls_tunnel::retrieve(_In_z_ LPCTSTR pszTargetName, _In_ unsigned int level)
{ {
assert(0); // Not that we would ever retrieve inner&outer credentials to Windows Credential Manager joined, but for completness sake... Here we go: assert(0); // Not that we would ever retrieve inner&outer credentials to Windows Credential Manager joined, but for completness sake... Here we go:
@ -166,7 +166,7 @@ void eap::credentials_ttls::retrieve(_In_z_ LPCTSTR pszTargetName, _In_ unsigned
} }
wstring eap::credentials_ttls::get_identity() const wstring eap::credentials_tls_tunnel::get_identity() const
{ {
// Outer identity has the right-of-way. // Outer identity has the right-of-way.
wstring identity(credentials_tls::get_identity()); wstring identity(credentials_tls::get_identity());
@ -178,7 +178,7 @@ wstring eap::credentials_ttls::get_identity() const
} }
eap::credentials::source_t eap::credentials_ttls::combine( eap::credentials::source_t eap::credentials_tls_tunnel::combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
@ -197,7 +197,7 @@ eap::credentials::source_t eap::credentials_ttls::combine(
source_t src_inner = m_inner->combine( source_t src_inner = m_inner->combine(
dwFlags, dwFlags,
hTokenImpersonateUser, hTokenImpersonateUser,
cred_cached ? dynamic_cast<const credentials_ttls*>(cred_cached)->m_inner.get() : NULL, cred_cached ? dynamic_cast<const credentials_tls_tunnel*>(cred_cached)->m_inner.get() : NULL,
*dynamic_cast<const config_method_ttls&>(cfg).m_inner, *dynamic_cast<const config_method_ttls&>(cfg).m_inner,
pszTargetName); pszTargetName);

View File

@ -304,7 +304,7 @@ void eap::method_eapmsg::get_response_packet(
// eap::method_ttls // eap::method_ttls
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
eap::method_ttls::method_ttls(_In_ module &mod, _In_ config_method_ttls &cfg, _In_ credentials_ttls &cred, _In_ method *inner) : eap::method_ttls::method_ttls(_In_ module &mod, _In_ config_method_ttls &cfg, _In_ credentials_tls_tunnel &cred, _In_ method *inner) :
m_cfg(cfg), m_cfg(cfg),
m_cred(cred), m_cred(cred),
m_user_ctx(NULL), m_user_ctx(NULL),

View File

@ -127,7 +127,7 @@ void eap::peer_ttls::get_identity(
} }
// Build our identity. ;) // Build our identity. ;)
wstring identity(std::move(cfg_method->get_public_identity(*dynamic_cast<const credentials_ttls*>(cred_out.m_cred.get())))); wstring identity(std::move(cfg_method->get_public_identity(*dynamic_cast<const credentials_tls_tunnel*>(cred_out.m_cred.get()))));
log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID1, event_data((unsigned int)eap_type_t::ttls), event_data(identity), event_data::blank); log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID1, event_data((unsigned int)eap_type_t::ttls), event_data(identity), event_data::blank);
size_t size = sizeof(WCHAR)*(identity.length() + 1); size_t size = sizeof(WCHAR)*(identity.length() + 1);
*ppwszIdentity = (WCHAR*)alloc_memory(size); *ppwszIdentity = (WCHAR*)alloc_memory(size);
@ -204,7 +204,7 @@ void eap::peer_ttls::credentials_xml2blob(
UNREFERENCED_PARAMETER(dwConnectionDataSize); UNREFERENCED_PARAMETER(dwConnectionDataSize);
// Load credentials from XML. // Load credentials from XML.
credentials_ttls cred(*this); credentials_tls_tunnel cred(*this);
cred.load(pConfigRoot); cred.load(pConfigRoot);
// Pack credentials. // Pack credentials.
@ -249,7 +249,7 @@ EAP_SESSION_HANDLE eap::peer_ttls::begin_session(
// We have configuration, we have credentials, create method. // We have configuration, we have credentials, create method.
unique_ptr<method> meth_inner; unique_ptr<method> meth_inner;
auto cfg_inner = cfg_method->m_inner.get(); auto cfg_inner = cfg_method->m_inner.get();
auto cred_inner = dynamic_cast<credentials_ttls*>(s->m_cred.m_cred.get())->m_inner.get(); auto cred_inner = dynamic_cast<credentials_tls_tunnel*>(s->m_cred.m_cred.get())->m_inner.get();
#if EAP_INNER_EAPHOST #if EAP_INNER_EAPHOST
auto cfg_inner_eaphost = dynamic_cast<config_method_eaphost*>(cfg_inner); auto cfg_inner_eaphost = dynamic_cast<config_method_eaphost*>(cfg_inner);
if (cfg_inner_eaphost) { if (cfg_inner_eaphost) {
@ -278,7 +278,7 @@ EAP_SESSION_HANDLE eap::peer_ttls::begin_session(
s->m_method.reset( s->m_method.reset(
new method_eap (*this, eap_type_t::ttls, *s->m_cred.m_cred, new method_eap (*this, eap_type_t::ttls, *s->m_cred.m_cred,
new method_defrag(*this, 0, /* Schannel supports retrieving keying material for EAP-TTLSv0 only. */ new method_defrag(*this, 0, /* Schannel supports retrieving keying material for EAP-TTLSv0 only. */
new method_ttls (*this, *cfg_method, *dynamic_cast<credentials_ttls*>(s->m_cred.m_cred.get()), meth_inner.release())))); new method_ttls (*this, *cfg_method, *dynamic_cast<credentials_tls_tunnel*>(s->m_cred.m_cred.get()), meth_inner.release()))));
// Initialize method. // Initialize method.
s->m_method->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, dwMaxSendPacketSize); s->m_method->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, dwMaxSendPacketSize);
@ -456,8 +456,8 @@ _Success_(return != 0) const eap::config_method_ttls* eap::peer_ttls::combine_cr
const config_method_ttls *cfg_method = dynamic_cast<const config_method_ttls*>(cfg_prov->m_methods.front().get()); const config_method_ttls *cfg_method = dynamic_cast<const config_method_ttls*>(cfg_prov->m_methods.front().get());
assert(cfg_method); assert(cfg_method);
// Combine credentials. We could use eap::credentials_ttls() to do all the work, but we would not know which credentials is missing then. // Combine credentials. We could use eap::credentials_tls_tunnel() to do all the work, but we would not know which credentials is missing then.
credentials_ttls *cred = dynamic_cast<credentials_ttls*>(cfg_method->make_credentials()); credentials_tls_tunnel *cred = dynamic_cast<credentials_tls_tunnel*>(cfg_method->make_credentials());
cred_out.m_cred.reset(cred); cred_out.m_cred.reset(cred);
#if EAP_USE_NATIVE_CREDENTIAL_CACHE #if EAP_USE_NATIVE_CREDENTIAL_CACHE
bool has_cached = cred_in.m_cred && cred_in.match(*cfg_prov); bool has_cached = cred_in.m_cred && cred_in.match(*cfg_prov);
@ -485,7 +485,7 @@ _Success_(return != 0) const eap::config_method_ttls* eap::peer_ttls::combine_cr
dwFlags, dwFlags,
hTokenImpersonateUser, hTokenImpersonateUser,
#if EAP_USE_NATIVE_CREDENTIAL_CACHE #if EAP_USE_NATIVE_CREDENTIAL_CACHE
has_cached ? dynamic_cast<credentials_ttls*>(cred_in.m_cred.get())->m_inner.get() : NULL, has_cached ? dynamic_cast<credentials_tls_tunnel*>(cred_in.m_cred.get())->m_inner.get() : NULL,
#else #else
NULL, NULL,
#endif #endif

View File

@ -194,7 +194,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
// Configure output credentials. // Configure output credentials.
cred_out.m_namespace = cfg_prov->m_namespace; cred_out.m_namespace = cfg_prov->m_namespace;
cred_out.m_id = cfg_prov->m_id; cred_out.m_id = cfg_prov->m_id;
auto cred = dynamic_cast<credentials_ttls*>(cfg_method->make_credentials()); auto cred = dynamic_cast<credentials_tls_tunnel*>(cfg_method->make_credentials());
cred_out.m_cred.reset(cred); cred_out.m_cred.reset(cred);
#if EAP_USE_NATIVE_CREDENTIAL_CACHE #if EAP_USE_NATIVE_CREDENTIAL_CACHE
bool has_cached = cred_in.m_cred && cred_in.match(*cfg_prov); bool has_cached = cred_in.m_cred && cred_in.match(*cfg_prov);
@ -260,7 +260,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
dwFlags, dwFlags,
NULL, NULL,
#if EAP_USE_NATIVE_CREDENTIAL_CACHE #if EAP_USE_NATIVE_CREDENTIAL_CACHE
has_cached ? dynamic_cast<credentials_ttls*>(cred_in.m_cred.get())->m_inner.get() : NULL, has_cached ? dynamic_cast<credentials_tls_tunnel*>(cred_in.m_cred.get())->m_inner.get() : NULL,
#else #else
NULL, NULL,
#endif #endif