config_method_with_cred::make_credentials() method moved to parent class config_method for seamless EAPMsg method support

This commit is contained in:
Simon Rozman 2016-10-10 13:20:08 +02:00
parent 864105186b
commit c660e2b3e6
5 changed files with 24 additions and 16 deletions

View File

@ -199,6 +199,9 @@ namespace eap
};
class credentials;
class config_method : public config
{
public:
@ -319,6 +322,11 @@ namespace eap
///
virtual const wchar_t* get_method_str() const = 0;
///
/// Creates a blank set of credentials suitable for this method
///
virtual credentials* make_credentials() const = 0;
public:
const unsigned int m_level; ///< Config level (0=outer, 1=inner, 2=inner-inner...)
bool m_allow_save; ///< Are credentials allowed to be saved to Windows Credential Manager?
@ -327,9 +335,6 @@ namespace eap
};
class credentials;
class config_method_with_cred : public config_method
{
public:
@ -419,11 +424,6 @@ namespace eap
/// @}
///
/// Creates a blank set of credentials suitable for this method
///
virtual credentials* make_credentials() const = 0;
public:
bool m_use_cred; ///< Use configured credentials
std::unique_ptr<credentials> m_cred; ///< Configured credentials

View File

@ -664,8 +664,7 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot)
// Matching provider found. Create matching blank credential set, then load.
if (cfg_prov->m_methods.empty())
throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str());
const config_method_with_cred *cfg_method = dynamic_cast<const config_method_with_cred*>(cfg_prov->m_methods.front().get());
m_cred.reset(cfg_method->make_credentials());
m_cred.reset(cfg_prov->m_methods.front().get()->make_credentials());
m_cred->load(pXmlElClientSideCredential);
break;
}
@ -707,8 +706,7 @@ void eap::credentials_connection::operator>>(_Inout_ cursor_in &cursor)
// Matching provider found. Create matching blank credential set, then read.
if (cfg_prov->m_methods.empty())
throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str());
const config_method_with_cred *cfg_method = dynamic_cast<const config_method_with_cred*>(cfg_prov->m_methods.front().get());
m_cred.reset(cfg_method->make_credentials());
m_cred.reset(cfg_prov->m_methods.front().get()->make_credentials());
cursor >> *m_cred;
break;
}

View File

@ -145,6 +145,11 @@ namespace eap
///
virtual const wchar_t* get_method_str() const;
///
/// Creates a blank set of credentials suitable for this method
///
virtual credentials* make_credentials() const;
public:
EAP_METHOD_TYPE m_type; ///< EapHost method type: (EAP type, vendor ID, vendor type, author ID) tuple
sanitizing_blob m_cfg_blob; ///< Method configuration BLOB

View File

@ -169,3 +169,9 @@ const wchar_t* eap::config_method_eapmsg::get_method_str() const
// TODO: Query registry for EAP method name (PeerFriendlyName using RegLoadMUIString()).
return L"EAPMsg";
}
eap::credentials* eap::config_method_eapmsg::make_credentials() const
{
return new credentials_eapmsg(m_module);
}

View File

@ -38,7 +38,7 @@ eap::config_method_ttls::config_method_ttls(_In_ module &mod, _In_ unsigned int
eap::config_method_ttls::config_method_ttls(const _In_ config_method_ttls &other) :
m_inner(other.m_inner ? dynamic_cast<config_method_with_cred*>(other.m_inner->clone()) : nullptr),
m_inner(other.m_inner ? dynamic_cast<config_method*>(other.m_inner->clone()) : nullptr),
m_anonymous_identity(other.m_anonymous_identity),
config_method_tls(other)
{
@ -57,7 +57,7 @@ eap::config_method_ttls& eap::config_method_ttls::operator=(const _In_ config_me
{
if (this != &other) {
(config_method_tls&)*this = other;
m_inner.reset(other.m_inner ? dynamic_cast<config_method_with_cred*>(other.m_inner->clone()) : nullptr);
m_inner.reset(other.m_inner ? dynamic_cast<config_method*>(other.m_inner->clone()) : nullptr);
m_anonymous_identity = other.m_anonymous_identity;
}
@ -257,8 +257,7 @@ const wchar_t* eap::config_method_ttls::get_method_str() const
eap::credentials* eap::config_method_ttls::make_credentials() const
{
credentials_ttls *cred = new credentials_ttls(m_module);
auto *cfg_inner = dynamic_cast<const config_method_with_cred*>(m_inner.get());
cred->m_inner.reset(cfg_inner ? cfg_inner->make_credentials() : nullptr);
cred->m_inner.reset(m_inner->make_credentials());
return cred;
}