config_method_ttls::m_inner is managed by std::unique_ptr now
This commit is contained in:
parent
db69c23689
commit
427e2fb892
@ -64,6 +64,8 @@ namespace eapserial
|
|||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
namespace eap {
|
namespace eap {
|
||||||
class config_method_ttls : public config_method_tls
|
class config_method_ttls : public config_method_tls
|
||||||
@ -90,11 +92,6 @@ namespace eap {
|
|||||||
///
|
///
|
||||||
config_method_ttls(_Inout_ config_method_ttls &&other);
|
config_method_ttls(_Inout_ config_method_ttls &&other);
|
||||||
|
|
||||||
///
|
|
||||||
/// Destructs configuration
|
|
||||||
///
|
|
||||||
virtual ~config_method_ttls();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copies configuration
|
/// Copies configuration
|
||||||
///
|
///
|
||||||
@ -158,7 +155,7 @@ namespace eap {
|
|||||||
virtual eap::type_t get_method_id() const;
|
virtual eap::type_t get_method_id() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
config *m_inner; ///< Inner authentication configuration
|
std::unique_ptr<config> m_inner; ///< Inner authentication configuration
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +166,7 @@ namespace eapserial
|
|||||||
{
|
{
|
||||||
pack(cursor, (const eap::config_method_tls&)val);
|
pack(cursor, (const eap::config_method_tls&)val);
|
||||||
if (val.m_inner) {
|
if (val.m_inner) {
|
||||||
if (dynamic_cast<eap::config_method_pap*>(val.m_inner)) {
|
if (dynamic_cast<eap::config_method_pap*>(val.m_inner.get())) {
|
||||||
pack(cursor, eap::type_pap);
|
pack(cursor, eap::type_pap);
|
||||||
pack(cursor, (const eap::config_method_pap&)*val.m_inner);
|
pack(cursor, (const eap::config_method_pap&)*val.m_inner);
|
||||||
} else {
|
} else {
|
||||||
@ -185,13 +182,13 @@ namespace eapserial
|
|||||||
{
|
{
|
||||||
size_t size_inner;
|
size_t size_inner;
|
||||||
if (val.m_inner) {
|
if (val.m_inner) {
|
||||||
if (dynamic_cast<eap::config_method_pap*>(val.m_inner)) {
|
if (dynamic_cast<eap::config_method_pap*>(val.m_inner.get())) {
|
||||||
size_inner =
|
size_inner =
|
||||||
get_pk_size(eap::type_pap) +
|
get_pk_size(eap::type_pap) +
|
||||||
get_pk_size((const eap::config_method_pap&)*val.m_inner);
|
get_pk_size((const eap::config_method_pap&)*val.m_inner);
|
||||||
} else {
|
} else {
|
||||||
size_inner = get_pk_size(eap::type_undefined);
|
|
||||||
assert(0); // Unsupported inner authentication method type.
|
assert(0); // Unsupported inner authentication method type.
|
||||||
|
size_inner = get_pk_size(eap::type_undefined);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
size_inner = get_pk_size(eap::type_undefined);
|
size_inner = get_pk_size(eap::type_undefined);
|
||||||
@ -206,19 +203,16 @@ namespace eapserial
|
|||||||
{
|
{
|
||||||
unpack(cursor, (eap::config_method_tls&)val);
|
unpack(cursor, (eap::config_method_tls&)val);
|
||||||
|
|
||||||
if (val.m_inner)
|
|
||||||
delete val.m_inner;
|
|
||||||
|
|
||||||
eap::type_t eap_type;
|
eap::type_t eap_type;
|
||||||
unpack(cursor, eap_type);
|
unpack(cursor, eap_type);
|
||||||
switch (eap_type) {
|
switch (eap_type) {
|
||||||
case eap::type_pap:
|
case eap::type_pap:
|
||||||
val.m_inner = new eap::config_method_pap(val.m_module);
|
val.m_inner.reset(new eap::config_method_pap(val.m_module));
|
||||||
unpack(cursor, (eap::config_method_pap&)*val.m_inner);
|
unpack(cursor, (eap::config_method_pap&)*val.m_inner);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
val.m_inner = NULL;
|
|
||||||
assert(0); // Unsupported inner authentication method type.
|
assert(0); // Unsupported inner authentication method type.
|
||||||
|
val.m_inner.reset(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,31 +29,22 @@ using namespace winstd;
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
eap::config_method_ttls::config_method_ttls(_In_ module &mod) :
|
eap::config_method_ttls::config_method_ttls(_In_ module &mod) :
|
||||||
m_inner(NULL),
|
|
||||||
config_method_tls(mod)
|
config_method_tls(mod)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
eap::config_method_ttls::config_method_ttls(const _In_ config_method_ttls &other) :
|
eap::config_method_ttls::config_method_ttls(const _In_ config_method_ttls &other) :
|
||||||
m_inner(other.m_inner ? (config_method*)other.m_inner->clone() : NULL),
|
m_inner(other.m_inner ? (config_method*)other.m_inner->clone() : nullptr),
|
||||||
config_method_tls(other)
|
config_method_tls(other)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
eap::config_method_ttls::config_method_ttls(_Inout_ config_method_ttls &&other) :
|
eap::config_method_ttls::config_method_ttls(_Inout_ config_method_ttls &&other) :
|
||||||
m_inner(other.m_inner),
|
m_inner(std::move(other.m_inner)),
|
||||||
config_method_tls(std::move(other))
|
config_method_tls(std::move(other))
|
||||||
{
|
{
|
||||||
other.m_inner = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
eap::config_method_ttls::~config_method_ttls()
|
|
||||||
{
|
|
||||||
if (m_inner)
|
|
||||||
delete m_inner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,8 +52,7 @@ eap::config_method_ttls& eap::config_method_ttls::operator=(const _In_ config_me
|
|||||||
{
|
{
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
(config_method_tls&)*this = other;
|
(config_method_tls&)*this = other;
|
||||||
if (m_inner) delete m_inner;
|
m_inner.reset(other.m_inner ? (config_method*)other.m_inner->clone() : nullptr);
|
||||||
m_inner = other.m_inner ? (config_method*)other.m_inner->clone() : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@ -73,9 +63,7 @@ eap::config_method_ttls& eap::config_method_ttls::operator=(_Inout_ config_metho
|
|||||||
{
|
{
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
(config_method_tls&&)*this = std::move(other);
|
(config_method_tls&&)*this = std::move(other);
|
||||||
if (m_inner) delete m_inner;
|
m_inner = std::move(other.m_inner);
|
||||||
m_inner = other.m_inner;
|
|
||||||
other.m_inner = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@ -107,7 +95,7 @@ bool eap::config_method_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynamic_cast<const config_method_pap*>(m_inner)) {
|
if (dynamic_cast<const config_method_pap*>(m_inner.get())) {
|
||||||
// <InnerAuthenticationMethod>/<NonEAPAuthMethod>
|
// <InnerAuthenticationMethod>/<NonEAPAuthMethod>
|
||||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElInnerAuthenticationMethod, bstr(L"NonEAPAuthMethod"), bstrNamespace, bstr(L"PAP"))) != ERROR_SUCCESS) {
|
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElInnerAuthenticationMethod, bstr(L"NonEAPAuthMethod"), bstrNamespace, bstr(L"PAP"))) != ERROR_SUCCESS) {
|
||||||
*ppEapError = m_module.make_error(dwResult, _T(__FUNCTION__) _T(" Error creating <NonEAPAuthMethod> element."));
|
*ppEapError = m_module.make_error(dwResult, _T(__FUNCTION__) _T(" Error creating <NonEAPAuthMethod> element."));
|
||||||
@ -158,8 +146,7 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
|
|||||||
{
|
{
|
||||||
// PAP
|
// PAP
|
||||||
m_module.log_config((xpath + L"/NonEAPAuthMethod").c_str(), L"PAP");
|
m_module.log_config((xpath + L"/NonEAPAuthMethod").c_str(), L"PAP");
|
||||||
assert(!m_inner);
|
m_inner.reset(new eap::config_method_pap(m_module));
|
||||||
m_inner = new eap::config_method_pap(m_module);
|
|
||||||
if (!m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError))
|
if (!m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,7 +213,7 @@ protected:
|
|||||||
m_inner_type->GetChoiceCtrl()->Enable(false);
|
m_inner_type->GetChoiceCtrl()->Enable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
eap::config_method_pap *cfg_pap = dynamic_cast<eap::config_method_pap*>(m_cfg.m_inner);
|
eap::config_method_pap *cfg_pap = dynamic_cast<eap::config_method_pap*>(m_cfg.m_inner.get());
|
||||||
if (cfg_pap) {
|
if (cfg_pap) {
|
||||||
m_cfg_pap = *cfg_pap;
|
m_cfg_pap = *cfg_pap;
|
||||||
m_inner_type->SetSelection(0); // 0=PAP
|
m_inner_type->SetSelection(0); // 0=PAP
|
||||||
@ -234,8 +234,7 @@ protected:
|
|||||||
// This is not a provider-locked configuration. Save the data.
|
// This is not a provider-locked configuration. Save the data.
|
||||||
switch (m_inner_type->GetSelection()) {
|
switch (m_inner_type->GetSelection()) {
|
||||||
case 0: // 0=PAP
|
case 0: // 0=PAP
|
||||||
delete m_cfg.m_inner;
|
m_cfg.m_inner.reset(new eap::config_method_pap(m_cfg_pap));
|
||||||
m_cfg.m_inner = new eap::config_method_pap(m_cfg_pap);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user