Some more C casting replaced with C++ dynamic casting
This commit is contained in:
parent
6671c810f4
commit
1d06d78294
@ -191,8 +191,8 @@ eap::credentials::source_t eap::credentials_ttls::combine(
|
|||||||
|
|
||||||
// Combine inner credentials.
|
// Combine inner credentials.
|
||||||
source_t src_inner = m_inner->combine(
|
source_t src_inner = m_inner->combine(
|
||||||
cred_cached ? ((const credentials_ttls*)cred_cached)->m_inner.get() : NULL,
|
cred_cached ? dynamic_cast<const credentials_ttls*>(cred_cached)->m_inner.get() : NULL,
|
||||||
*((const config_method_ttls&)cfg).m_inner,
|
*dynamic_cast<const config_method_ttls&>(cfg).m_inner,
|
||||||
pszTargetName);
|
pszTargetName);
|
||||||
|
|
||||||
return std::min<source_t>(src_outer, src_inner);
|
return std::min<source_t>(src_outer, src_inner);
|
||||||
|
@ -98,7 +98,7 @@ void eap::peer_ttls::get_identity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build our identity. ;)
|
// Build our identity. ;)
|
||||||
wstring identity(std::move(cfg_method->get_public_identity((const credentials_ttls&)*cred_out.m_cred)));
|
wstring identity(std::move(cfg_method->get_public_identity(*dynamic_cast<const credentials_ttls*>(cred_out.m_cred.get()))));
|
||||||
log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID1, event_data((unsigned int)eap_type_ttls), event_data(identity), event_data::blank);
|
log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID1, event_data((unsigned int)eap_type_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);
|
||||||
@ -218,7 +218,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.
|
||||||
s->m_method.reset(new method_ttls(*this, *cfg_method, *(credentials_ttls*)s->m_cred.m_cred.get()));
|
s->m_method.reset(new method_ttls(*this, *cfg_method, *dynamic_cast<credentials_ttls*>(s->m_cred.m_cred.get())));
|
||||||
|
|
||||||
// Initialize method.
|
// Initialize method.
|
||||||
s->m_method->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, dwMaxSendPacketSize);
|
s->m_method->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, dwMaxSendPacketSize);
|
||||||
@ -378,7 +378,7 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials(
|
|||||||
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_ttls() to do all the work, but we would not know which credentials is missing then.
|
||||||
credentials_ttls *cred = (credentials_ttls*)cfg_method->make_credentials();
|
credentials_ttls *cred = dynamic_cast<credentials_ttls*>(cfg_method->make_credentials());
|
||||||
cred_out.m_cred.reset(cred);
|
cred_out.m_cred.reset(cred);
|
||||||
#ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE
|
#ifdef 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);
|
||||||
@ -402,7 +402,7 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials(
|
|||||||
// Combine inner credentials.
|
// Combine inner credentials.
|
||||||
eap::credentials::source_t src_inner = cred->m_inner->combine(
|
eap::credentials::source_t src_inner = cred->m_inner->combine(
|
||||||
#ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE
|
#ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE
|
||||||
has_cached ? ((credentials_ttls*)cred_in.m_cred.get())->m_inner.get() : NULL,
|
has_cached ? dynamic_cast<credentials_ttls*>(cred_in.m_cred.get())->m_inner.get() : NULL,
|
||||||
#else
|
#else
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
|
@ -199,7 +199,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
credentials_connection cred_method(*this, cfg);
|
credentials_connection cred_method(*this, cfg);
|
||||||
cred_method.m_namespace = cfg_prov->m_namespace;
|
cred_method.m_namespace = cfg_prov->m_namespace;
|
||||||
cred_method.m_id = cfg_prov->m_id;
|
cred_method.m_id = cfg_prov->m_id;
|
||||||
credentials_ttls *_cred_method = (credentials_ttls*)cfg_method->make_credentials();
|
credentials_ttls *_cred_method = dynamic_cast<credentials_ttls*>(cfg_method->make_credentials());
|
||||||
cred_method.m_cred.reset(_cred_method);
|
cred_method.m_cred.reset(_cred_method);
|
||||||
#ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE
|
#ifdef 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);
|
||||||
@ -224,7 +224,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
// Combine inner credentials.
|
// Combine inner credentials.
|
||||||
eap::credentials::source_t src_inner = _cred_method->m_inner->combine(
|
eap::credentials::source_t src_inner = _cred_method->m_inner->combine(
|
||||||
#ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE
|
#ifdef EAP_USE_NATIVE_CREDENTIAL_CACHE
|
||||||
has_cached ? ((credentials_ttls*)cred_in.m_cred.get())->m_inner.get() : NULL,
|
has_cached ? dynamic_cast<credentials_ttls*>(cred_in.m_cred.get())->m_inner.get() : NULL,
|
||||||
#else
|
#else
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
@ -299,7 +299,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
|
||||||
// Build our identity. ;)
|
// Build our identity. ;)
|
||||||
wstring identity(std::move(cfg_method->get_public_identity((const credentials_ttls&)*cred_out.m_cred)));
|
wstring identity(std::move(cfg_method->get_public_identity(*dynamic_cast<const credentials_ttls*>(cred_out.m_cred.get()))));
|
||||||
log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID1, event_data((unsigned int)eap_type_ttls), event_data(identity), event_data::blank);
|
log_event(&EAPMETHOD_TRACE_EVT_CRED_OUTER_ID1, event_data((unsigned int)eap_type_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);
|
||||||
|
@ -231,14 +231,14 @@ wxTTLSConfigWindow::~wxTTLSConfigWindow()
|
|||||||
|
|
||||||
bool wxTTLSConfigWindow::TransferDataToWindow()
|
bool wxTTLSConfigWindow::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
switch (((eap::config_method_ttls&)m_cfg).m_inner->get_method_id()) {
|
switch (dynamic_cast<eap::config_method_ttls&>(m_cfg).m_inner->get_method_id()) {
|
||||||
case winstd::eap_type_legacy_pap:
|
case winstd::eap_type_legacy_pap:
|
||||||
m_cfg_pap = *(eap::config_method_pap*)((eap::config_method_ttls&)m_cfg).m_inner.get();
|
m_cfg_pap = *(eap::config_method_pap*)dynamic_cast<eap::config_method_ttls&>(m_cfg).m_inner.get();
|
||||||
m_inner_type->SetSelection(0); // 0=PAP
|
m_inner_type->SetSelection(0); // 0=PAP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case winstd::eap_type_legacy_mschapv2:
|
case winstd::eap_type_legacy_mschapv2:
|
||||||
m_cfg_mschapv2 = *(eap::config_method_mschapv2*)((eap::config_method_ttls&)m_cfg).m_inner.get();
|
m_cfg_mschapv2 = *(eap::config_method_mschapv2*)dynamic_cast<eap::config_method_ttls&>(m_cfg).m_inner.get();
|
||||||
m_inner_type->SetSelection(1); // 1=MSCHAPv2
|
m_inner_type->SetSelection(1); // 1=MSCHAPv2
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -260,11 +260,11 @@ bool wxTTLSConfigWindow::TransferDataFromWindow()
|
|||||||
// 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
|
||||||
((eap::config_method_ttls&)m_cfg).m_inner.reset(new eap::config_method_pap(m_cfg_pap));
|
dynamic_cast<eap::config_method_ttls&>(m_cfg).m_inner.reset(new eap::config_method_pap(m_cfg_pap));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // 1=MSCHAPv2
|
case 1: // 1=MSCHAPv2
|
||||||
((eap::config_method_ttls&)m_cfg).m_inner.reset(new eap::config_method_mschapv2(m_cfg_mschapv2));
|
dynamic_cast<eap::config_method_ttls&>(m_cfg).m_inner.reset(new eap::config_method_mschapv2(m_cfg_mschapv2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user