credentials_ttls is descendant of credentials_tls again

This commit is contained in:
Simon Rozman 2016-08-13 08:36:10 +02:00
parent 537d0c0cbc
commit 09924ea3d2
4 changed files with 25 additions and 39 deletions

View File

@ -36,7 +36,7 @@ namespace eap
namespace eap
{
class credentials_ttls : public credentials
class credentials_ttls : public credentials_tls
{
public:
///
@ -173,7 +173,6 @@ namespace eap
/// @}
public:
credentials_tls m_outer; ///< Outer credentials
std::unique_ptr<credentials> m_inner; ///< Inner credentials
};
}

View File

@ -29,24 +29,21 @@ using namespace winstd;
//////////////////////////////////////////////////////////////////////
eap::credentials_ttls::credentials_ttls(_In_ module &mod) :
m_outer(mod),
credentials(mod)
credentials_tls(mod)
{
}
eap::credentials_ttls::credentials_ttls(_In_ const credentials_ttls &other) :
m_outer(other.m_outer),
m_inner(other.m_inner ? (credentials*)other.m_inner->clone() : nullptr),
credentials(other)
credentials_tls(other)
{
}
eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) :
m_outer(std::move(other.m_outer)),
m_inner(std::move(other.m_inner)),
credentials(std::move(other))
credentials_tls(std::move(other))
{
}
@ -54,8 +51,7 @@ eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) :
eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_ttls &other)
{
if (this != &other) {
(credentials&)*this = other;
m_outer = other.m_outer;
(credentials_tls&)*this = other;
m_inner.reset(other.m_inner ? (credentials*)other.m_inner->clone() : nullptr);
}
@ -66,9 +62,8 @@ eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_t
eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other)
{
if (this != &other) {
(credentials&)*this = std::move(other);
m_outer = std::move(other.m_outer);
m_inner = std::move(other.m_inner);
(credentials_tls&)*this = std::move(other);
m_inner = std::move(other.m_inner);
}
return *this;
@ -83,8 +78,7 @@ eap::config* eap::credentials_ttls::clone() const
void eap::credentials_ttls::clear()
{
credentials::clear();
m_outer.clear();
credentials_tls::clear();
if (m_inner)
m_inner->clear();
}
@ -92,7 +86,7 @@ void eap::credentials_ttls::clear()
bool eap::credentials_ttls::empty() const
{
return credentials::empty() && m_outer.empty() && (!m_inner || m_inner->empty());
return credentials_tls::empty() && (!m_inner || m_inner->empty());
}
@ -101,9 +95,7 @@ void eap::credentials_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *p
assert(pDoc);
assert(pConfigRoot);
credentials::save(pDoc, pConfigRoot);
m_outer.save(pDoc, pConfigRoot);
credentials_tls::save(pDoc, pConfigRoot);
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
HRESULT hr;
@ -127,9 +119,7 @@ void eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot)
assert(pConfigRoot);
HRESULT hr;
credentials::load(pConfigRoot);
m_outer.load(pConfigRoot);
credentials_tls::load(pConfigRoot);
// TODO: For the time being, there is no detection what type is inner method. Introduce one!
if (m_inner) {
@ -144,8 +134,7 @@ void eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot)
void eap::credentials_ttls::operator<<(_Inout_ cursor_out &cursor) const
{
credentials::operator<<(cursor);
cursor << m_outer;
credentials_tls::operator<<(cursor);
if (m_inner) {
if (dynamic_cast<credentials_pap*>(m_inner.get())) {
cursor << eap_type_pap;
@ -175,16 +164,14 @@ size_t eap::credentials_ttls::get_pk_size() const
size_inner = pksizeof(eap_type_undefined);
return
credentials::get_pk_size() +
pksizeof(m_outer) +
credentials_tls::get_pk_size() +
size_inner;
}
void eap::credentials_ttls::operator>>(_Inout_ cursor_in &cursor)
{
credentials::operator>>(cursor);
cursor >> m_outer;
credentials_tls::operator>>(cursor);
eap_type_t eap_type;
cursor >> eap_type;
@ -202,7 +189,7 @@ void eap::credentials_ttls::operator>>(_Inout_ cursor_in &cursor)
void eap::credentials_ttls::store(_In_ LPCTSTR pszTargetName) const
{
m_outer.store(pszTargetName);
credentials_tls::store(pszTargetName);
if (m_inner)
m_inner->store(pszTargetName);
@ -211,7 +198,7 @@ void eap::credentials_ttls::store(_In_ LPCTSTR pszTargetName) const
void eap::credentials_ttls::retrieve(_In_ LPCTSTR pszTargetName)
{
m_outer.retrieve(pszTargetName);
credentials_tls::retrieve(pszTargetName);
if (m_inner)
m_inner->retrieve(pszTargetName);
@ -228,8 +215,8 @@ LPCTSTR eap::credentials_ttls::target_suffix() const
std::wstring eap::credentials_ttls::get_identity() const
{
// Outer identity has the right-of-way.
if (!m_outer.empty())
return m_outer.get_identity();
if (!credentials_tls::empty())
return credentials_tls::get_identity();
// Inner identity.
if (m_inner)

View File

@ -110,8 +110,8 @@ void eap::peer_ttls::get_identity(
if (!is_outer_set) {
// Outer TLS: Using EAP service cached credentials.
cred_out.m_outer = cred_in.m_outer;
log_event(&EAPMETHOD_TRACE_EVT_CRED_CACHED1, event_data((unsigned int)eap_type_tls), event_data(cred_out.m_outer.get_name()), event_data::blank);
(credentials_tls&)cred_out = (const credentials_tls&)cred_in;
log_event(&EAPMETHOD_TRACE_EVT_CRED_CACHED1, event_data((unsigned int)eap_type_tls), event_data(((credentials_tls&)cred_out).get_name()), event_data::blank);
is_outer_set = true;
}
@ -125,8 +125,8 @@ void eap::peer_ttls::get_identity(
if (!is_outer_set && cfg_method->m_outer.m_use_preshared) {
// Outer TLS: Using preshared credentials.
cred_out.m_outer = *(credentials_tls*)cfg_method->m_outer.m_preshared.get();
log_event(&EAPMETHOD_TRACE_EVT_CRED_PRESHARED1, event_data((unsigned int)eap_type_tls), event_data(cred_out.m_outer.get_name()), event_data::blank);
(credentials_tls&)cred_out = *(credentials_tls*)cfg_method->m_outer.m_preshared.get();
log_event(&EAPMETHOD_TRACE_EVT_CRED_PRESHARED1, event_data((unsigned int)eap_type_tls), event_data(((credentials_tls&)cred_out).get_name()), event_data::blank);
is_outer_set = true;
}
@ -154,8 +154,8 @@ void eap::peer_ttls::get_identity(
cred_loaded.retrieve(cfg_prov.m_id.c_str());
// Outer TLS: Using stored credentials.
cred_out.m_outer = std::move(cred_loaded);
log_event(&EAPMETHOD_TRACE_EVT_CRED_STORED1, event_data((unsigned int)eap_type_tls), event_data(cred_out.m_outer.get_name()), event_data::blank);
(credentials_tls&)cred_out = std::move(cred_loaded);
log_event(&EAPMETHOD_TRACE_EVT_CRED_STORED1, event_data((unsigned int)eap_type_tls), event_data(((credentials_tls&)cred_out).get_name()), event_data::blank);
is_outer_set = true;
} catch (...) {
// Not actually an error.

View File

@ -240,7 +240,7 @@ wxTTLSCredentialsPanel::wxTTLSCredentialsPanel(const eap::config_provider &prov,
m_outer_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
sb_content->Add(m_outer_title, 0, wxALL|wxALIGN_RIGHT, 5);
m_outer_cred = new wxTLSCredentialsPanel(m_prov, (const eap::config_method_tls&)m_cfg, ((eap::credentials_ttls&)cred).m_outer, pszCredTarget, this, is_config);
m_outer_cred = new wxTLSCredentialsPanel(m_prov, (const eap::config_method_tls&)m_cfg, (eap::credentials_tls&)cred, pszCredTarget, this, is_config);
sb_content->Add(m_outer_cred, 0, wxALL|wxEXPAND, 5);
this->SetSizer(sb_content);