Provider identity is now coherent to draft-winter-opsawg-eap-metadata-02
This commit is contained in:
@@ -454,9 +454,25 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Returns provider namespace and ID concatenated
|
||||
///
|
||||
inline std::wstring get_id() const
|
||||
{
|
||||
if (m_namespace.empty())
|
||||
return m_id;
|
||||
else {
|
||||
std::wstring id(m_namespace);
|
||||
id += L':';
|
||||
id += m_id;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
bool m_read_only; ///< Is profile read-only
|
||||
std::wstring m_namespace; ///< Provider namespace URI
|
||||
std::wstring m_id; ///< Provider ID
|
||||
bool m_read_only; ///< Is profile read-only
|
||||
winstd::tstring m_name; ///< Provider name
|
||||
winstd::tstring m_help_email; ///< Helpdesk e-mail
|
||||
winstd::tstring m_help_web; ///< Helpdesk website URL
|
||||
|
@@ -476,8 +476,34 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Returns provider namespace and ID concatenated
|
||||
///
|
||||
inline std::wstring get_id() const
|
||||
{
|
||||
if (m_namespace.empty())
|
||||
return m_id;
|
||||
else {
|
||||
std::wstring id(m_namespace);
|
||||
id += L':';
|
||||
id += m_id;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks if credentials match given provider.
|
||||
///
|
||||
inline bool match(_In_ const config_provider &cfg_provider) const
|
||||
{
|
||||
return
|
||||
_wcsicmp(m_namespace.c_str(), cfg_provider.m_namespace.c_str()) == 0 &&
|
||||
_wcsicmp(m_id .c_str(), cfg_provider.m_id .c_str()) == 0;
|
||||
}
|
||||
|
||||
public:
|
||||
const config_connection& m_cfg; ///< Connection configuration
|
||||
std::wstring m_namespace; ///< Provider namespace URI
|
||||
std::wstring m_id; ///< Provider ID
|
||||
std::unique_ptr<credentials> m_cred; ///< Credentials
|
||||
};
|
||||
|
@@ -48,6 +48,17 @@ namespace eapxml
|
||||
inline HRESULT put_element_value(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_ bool bValue);
|
||||
inline HRESULT put_element_base64(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen);
|
||||
inline HRESULT put_element_hex(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen);
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ BSTR *pbstrValue);
|
||||
template<class _Traits, class _Ax> inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue);
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ DWORD *pdwValue);
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ bool *pbValue);
|
||||
template<class _Ty, class _Ax> inline HRESULT get_attrib_base64(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue);
|
||||
template<class _Ty, class _Ax> inline HRESULT get_attrib_hex(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue);
|
||||
inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_z_ const BSTR bstrValue);
|
||||
inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_ DWORD dwValue);
|
||||
inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_ bool bValue);
|
||||
inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen);
|
||||
inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen);
|
||||
inline std::wstring get_xpath(_In_ IXMLDOMNode *pXmlNode);
|
||||
}
|
||||
|
||||
@@ -384,6 +395,144 @@ namespace eapxml
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ BSTR *pbstrValue)
|
||||
{
|
||||
assert(pbstrValue);
|
||||
|
||||
HRESULT hr;
|
||||
winstd::com_obj<IXMLDOMNamedNodeMap> pXmlAttributes;
|
||||
winstd::com_obj<IXMLDOMNode> pXmlAt;
|
||||
VARIANT varValue;
|
||||
V_VT(&varValue) = VT_EMPTY;
|
||||
|
||||
return
|
||||
SUCCEEDED(hr = pXmlParent->get_attributes(&pXmlAttributes)) ?
|
||||
SUCCEEDED(hr = pXmlAttributes->getNamedItem(bstrAttributeName, &pXmlAt)) ?
|
||||
pXmlAt ?
|
||||
SUCCEEDED(hr = pXmlAt->get_nodeValue(&varValue)) ?
|
||||
V_VT(&varValue) == VT_BSTR ? *pbstrValue = V_BSTR(&varValue), S_OK : E_UNEXPECTED : hr : E_NOT_SET : hr : hr;
|
||||
}
|
||||
|
||||
|
||||
template<class _Traits, class _Ax>
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sValue)
|
||||
{
|
||||
winstd::bstr bstr;
|
||||
HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr);
|
||||
if (SUCCEEDED(hr))
|
||||
sValue.assign(bstr, bstr.length());
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ DWORD *pdwValue)
|
||||
{
|
||||
assert(pdwValue);
|
||||
|
||||
winstd::bstr bstr;
|
||||
HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr);
|
||||
if (SUCCEEDED(hr))
|
||||
*pdwValue = wcstoul(bstr, NULL, 10);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ bool *pbValue)
|
||||
{
|
||||
assert(pbValue);
|
||||
|
||||
winstd::bstr bstr;
|
||||
HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr);
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"true" , -1, NULL, NULL, 0) == CSTR_EQUAL ||
|
||||
CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"1" , -1, NULL, NULL, 0) == CSTR_EQUAL)
|
||||
*pbValue = true;
|
||||
else if (
|
||||
CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"false", -1, NULL, NULL, 0) == CSTR_EQUAL ||
|
||||
CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstr, bstr.length(), L"0" , -1, NULL, NULL, 0) == CSTR_EQUAL)
|
||||
*pbValue = false;
|
||||
else
|
||||
hr = E_NOT_VALID_STATE;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
template<class _Ty, class _Ax>
|
||||
inline HRESULT get_attrib_base64(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue)
|
||||
{
|
||||
winstd::bstr bstr;
|
||||
HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr);
|
||||
if (SUCCEEDED(hr)) {
|
||||
winstd::base64_dec dec;
|
||||
bool is_last;
|
||||
dec.decode(aValue, is_last, (BSTR)bstr, bstr.length());
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
template<class _Ty, class _Ax>
|
||||
inline HRESULT get_attrib_hex(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ std::vector<_Ty, _Ax> &aValue)
|
||||
{
|
||||
winstd::bstr bstr;
|
||||
HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, &bstr);
|
||||
if (SUCCEEDED(hr)) {
|
||||
winstd::hex_dec dec;
|
||||
bool is_last;
|
||||
dec.decode(aValue, is_last, (BSTR)bstr, bstr.length());
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_z_ const BSTR bstrValue)
|
||||
{
|
||||
HRESULT hr;
|
||||
winstd::com_obj<IXMLDOMElement> pXmlEl;
|
||||
VARIANT varValue;
|
||||
V_VT(&varValue) = VT_BSTR;
|
||||
V_BSTR(&varValue) = bstrValue;
|
||||
|
||||
return
|
||||
SUCCEEDED(hr = pCurrentDOMNode->QueryInterface(__uuidof(IXMLDOMElement), (void**)&pXmlEl)) &&
|
||||
SUCCEEDED(hr = pXmlEl->setAttribute(bstrAttributeName, varValue)) ? S_OK : hr;
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_ DWORD dwValue)
|
||||
{
|
||||
return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(winstd::wstring_printf(L"%d", dwValue)));
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_ bool bValue)
|
||||
{
|
||||
return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(bValue ? L"true": L"false"));
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen)
|
||||
{
|
||||
std::wstring sBase64;
|
||||
winstd::base64_enc enc;
|
||||
enc.encode(sBase64, pValue, nValueLen);
|
||||
return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(sBase64));
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen)
|
||||
{
|
||||
std::wstring sHex;
|
||||
winstd::hex_enc enc;
|
||||
enc.encode(sHex, pValue, nValueLen);
|
||||
return put_attrib_value(pCurrentDOMNode, bstrAttributeName, winstd::bstr(sHex));
|
||||
}
|
||||
|
||||
|
||||
inline std::wstring get_xpath(_In_ IXMLDOMNode *pXmlNode)
|
||||
{
|
||||
if (pXmlNode) {
|
||||
|
@@ -287,8 +287,9 @@ eap::config_provider::config_provider(_In_ module &mod) :
|
||||
|
||||
|
||||
eap::config_provider::config_provider(_In_ const config_provider &other) :
|
||||
m_read_only (other.m_read_only ),
|
||||
m_namespace (other.m_namespace ),
|
||||
m_id (other.m_id ),
|
||||
m_read_only (other.m_read_only ),
|
||||
m_name (other.m_name ),
|
||||
m_help_email (other.m_help_email ),
|
||||
m_help_web (other.m_help_web ),
|
||||
@@ -305,8 +306,9 @@ eap::config_provider::config_provider(_In_ const config_provider &other) :
|
||||
|
||||
|
||||
eap::config_provider::config_provider(_Inout_ config_provider &&other) :
|
||||
m_read_only (std::move(other.m_read_only )),
|
||||
m_namespace (std::move(other.m_namespace )),
|
||||
m_id (std::move(other.m_id )),
|
||||
m_read_only (std::move(other.m_read_only )),
|
||||
m_name (std::move(other.m_name )),
|
||||
m_help_email (std::move(other.m_help_email )),
|
||||
m_help_web (std::move(other.m_help_web )),
|
||||
@@ -324,8 +326,9 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = other;
|
||||
m_read_only = other.m_read_only;
|
||||
m_namespace = other.m_namespace;
|
||||
m_id = other.m_id;
|
||||
m_read_only = other.m_read_only;
|
||||
m_name = other.m_name;
|
||||
m_help_email = other.m_help_email;
|
||||
m_help_web = other.m_help_web;
|
||||
@@ -348,8 +351,9 @@ eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = std::move(other );
|
||||
m_read_only = std::move(other.m_read_only );
|
||||
m_namespace = std::move(other.m_namespace );
|
||||
m_id = std::move(other.m_id );
|
||||
m_read_only = std::move(other.m_read_only );
|
||||
m_name = std::move(other.m_name );
|
||||
m_help_email = std::move(other.m_help_email );
|
||||
m_help_web = std::move(other.m_help_web );
|
||||
@@ -376,15 +380,20 @@ void eap::config_provider::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pC
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
// namespace
|
||||
if (!m_namespace.empty())
|
||||
if (FAILED(hr = eapxml::put_attrib_value(pConfigRoot, bstr(L"namespace"), bstr(m_namespace))))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating namespace attribute.");
|
||||
|
||||
// ID
|
||||
if (!m_id.empty())
|
||||
if (FAILED(hr = eapxml::put_attrib_value(pConfigRoot, bstr(L"ID"), bstr(m_id))))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating ID attribute.");
|
||||
|
||||
// <read-only>
|
||||
if (FAILED(hr = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"read-only"), namespace_eapmetadata, m_read_only)))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating <read-only> element.");
|
||||
|
||||
// <ID>
|
||||
if (!m_id.empty())
|
||||
if (FAILED(hr = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"ID"), namespace_eapmetadata, bstr(m_id))))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating <ID> element.");
|
||||
|
||||
// <ProviderInfo>
|
||||
com_obj<IXMLDOMElement> pXmlElProviderInfo;
|
||||
if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ProviderInfo"), bstr(L"ProviderInfo"), namespace_eapmetadata, &pXmlElProviderInfo)))
|
||||
@@ -458,16 +467,21 @@ void eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot)
|
||||
|
||||
config::load(pConfigRoot);
|
||||
|
||||
// namespace
|
||||
m_namespace.clear();
|
||||
eapxml::get_attrib_value(pConfigRoot, bstr(L"namespace"), m_namespace);
|
||||
m_module.log_config((xpath + L" namespace").c_str(), m_namespace.c_str());
|
||||
|
||||
// ID
|
||||
m_id.clear();
|
||||
eapxml::get_attrib_value(pConfigRoot, bstr(L"ID"), m_id);
|
||||
m_module.log_config((xpath + L" ID").c_str(), m_id.c_str());
|
||||
|
||||
// <read-only>
|
||||
if (FAILED(hr = eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:read-only"), &m_read_only)))
|
||||
m_read_only = true;
|
||||
m_module.log_config((xpath + L"/read-only").c_str(), m_read_only);
|
||||
|
||||
// <ID>
|
||||
m_id.clear();
|
||||
eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:ID"), m_id);
|
||||
m_module.log_config((xpath + L"/ID").c_str(), m_id.c_str());
|
||||
|
||||
// <ProviderInfo>
|
||||
m_name.clear();
|
||||
m_help_email.clear();
|
||||
@@ -550,8 +564,9 @@ void eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot)
|
||||
void eap::config_provider::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
config::operator<<(cursor);
|
||||
cursor << m_read_only ;
|
||||
cursor << m_namespace ;
|
||||
cursor << m_id ;
|
||||
cursor << m_read_only ;
|
||||
cursor << m_name ;
|
||||
cursor << m_help_email ;
|
||||
cursor << m_help_web ;
|
||||
@@ -567,8 +582,9 @@ size_t eap::config_provider::get_pk_size() const
|
||||
{
|
||||
return
|
||||
config::get_pk_size() +
|
||||
pksizeof(m_read_only ) +
|
||||
pksizeof(m_namespace ) +
|
||||
pksizeof(m_id ) +
|
||||
pksizeof(m_read_only ) +
|
||||
pksizeof(m_name ) +
|
||||
pksizeof(m_help_email ) +
|
||||
pksizeof(m_help_web ) +
|
||||
@@ -583,8 +599,9 @@ size_t eap::config_provider::get_pk_size() const
|
||||
void eap::config_provider::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
config::operator>>(cursor);
|
||||
cursor >> m_read_only ;
|
||||
cursor >> m_namespace ;
|
||||
cursor >> m_id ;
|
||||
cursor >> m_read_only ;
|
||||
cursor >> m_name ;
|
||||
cursor >> m_help_email ;
|
||||
cursor >> m_help_web ;
|
||||
|
@@ -431,19 +431,21 @@ eap::credentials_connection::credentials_connection(_In_ module &mod, _In_ const
|
||||
|
||||
|
||||
eap::credentials_connection::credentials_connection(_In_ const credentials_connection &other) :
|
||||
m_cfg (other.m_cfg ),
|
||||
m_id (other.m_id ),
|
||||
m_cred(other.m_cred ? (credentials*)other.m_cred->clone() : nullptr),
|
||||
config(other )
|
||||
m_cfg (other.m_cfg ),
|
||||
m_namespace(other.m_namespace),
|
||||
m_id (other.m_id ),
|
||||
m_cred (other.m_cred ? (credentials*)other.m_cred->clone() : nullptr),
|
||||
config (other )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_connection::credentials_connection(_Inout_ credentials_connection &&other) :
|
||||
m_cfg ( other.m_cfg ),
|
||||
m_id (std::move(other.m_id )),
|
||||
m_cred(std::move(other.m_cred)),
|
||||
config(std::move(other ))
|
||||
m_cfg ( other.m_cfg ),
|
||||
m_namespace(std::move(other.m_namespace)),
|
||||
m_id (std::move(other.m_id )),
|
||||
m_cred (std::move(other.m_cred )),
|
||||
config (std::move(other ))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -452,6 +454,7 @@ eap::credentials_connection& eap::credentials_connection::operator=(_In_ const c
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = other;
|
||||
m_namespace = other.m_namespace;
|
||||
m_id = other.m_id;
|
||||
m_cred.reset(other.m_cred ? (credentials*)other.m_cred->clone() : nullptr);
|
||||
}
|
||||
@@ -463,9 +466,10 @@ eap::credentials_connection& eap::credentials_connection::operator=(_In_ const c
|
||||
eap::credentials_connection& eap::credentials_connection::operator=(_Inout_ credentials_connection &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = std::move(other );
|
||||
m_id = std::move(other.m_id );
|
||||
m_cred = std::move(other.m_cred);
|
||||
(config&)*this = std::move(other );
|
||||
m_namespace = std::move(other.m_namespace);
|
||||
m_id = std::move(other.m_id );
|
||||
m_cred = std::move(other.m_cred );
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -487,11 +491,22 @@ void eap::credentials_connection::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMN
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
// <IdentityProviderID>
|
||||
if (FAILED(hr = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"IdentityProviderID"), namespace_eapmetadata, bstr(m_id))))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating <IdentityProviderID> element.");
|
||||
// Create <EAPIdentityProvider> node.
|
||||
com_obj<IXMLDOMElement> pXmlElIdentityProvider;
|
||||
if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:EAPIdentityProvider"), bstr(L"EAPIdentityProvider"), namespace_eapmetadata, &pXmlElIdentityProvider)))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating <EAPIdentityProvider> element.");
|
||||
|
||||
m_cred->save(pDoc, pConfigRoot);
|
||||
// namespace
|
||||
if (!m_namespace.empty())
|
||||
if (FAILED(hr = eapxml::put_attrib_value(pXmlElIdentityProvider, bstr(L"namespace"), bstr(m_namespace))))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating namespace attribute.");
|
||||
|
||||
// ID
|
||||
if (!m_id.empty())
|
||||
if (FAILED(hr = eapxml::put_attrib_value(pXmlElIdentityProvider, bstr(L"ID"), bstr(m_id))))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error creating ID attribute.");
|
||||
|
||||
m_cred->save(pDoc, pXmlElIdentityProvider);
|
||||
}
|
||||
|
||||
|
||||
@@ -502,27 +517,37 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot)
|
||||
|
||||
config::load(pConfigRoot);
|
||||
|
||||
std::wstring xpath(eapxml::get_xpath(pConfigRoot));
|
||||
// <EAPIdentityProvider>
|
||||
winstd::com_obj<IXMLDOMElement> pXmlElClientSideCredential;
|
||||
if (FAILED(hr = eapxml::select_element(pConfigRoot, winstd::bstr(L"eap-metadata:EAPIdentityProvider"), &pXmlElClientSideCredential)))
|
||||
throw com_runtime_error(hr, __FUNCTION__ " Error loading <EAPIdentityProvider> element.");
|
||||
|
||||
if (FAILED(hr = eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:IdentityProviderID"), m_id)))
|
||||
m_id.clear();
|
||||
std::wstring xpath(eapxml::get_xpath(pXmlElClientSideCredential));
|
||||
|
||||
m_module.log_config((xpath + L"/IdentityProviderID").c_str(), m_id.c_str());
|
||||
// namespace
|
||||
m_namespace.clear();
|
||||
eapxml::get_attrib_value(pXmlElClientSideCredential, bstr(L"namespace"), m_namespace);
|
||||
m_module.log_config((xpath + L" namespace").c_str(), m_namespace.c_str());
|
||||
|
||||
// ID
|
||||
m_id.clear();
|
||||
eapxml::get_attrib_value(pXmlElClientSideCredential, bstr(L"ID"), m_id);
|
||||
m_module.log_config((xpath + L" ID").c_str(), m_id.c_str());
|
||||
|
||||
// Look-up the provider.
|
||||
for (config_connection::provider_list::const_iterator cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) {
|
||||
if (cfg_prov != cfg_prov_end) {
|
||||
if (_wcsicmp(cfg_prov->m_id.c_str(), m_id.c_str()) == 0) {
|
||||
if (match(*cfg_prov)) {
|
||||
// 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->m_id.c_str()).c_str());
|
||||
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->load(pConfigRoot);
|
||||
m_cred->load(pXmlElClientSideCredential);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider ID within this connection configuration (provider ID: %ls).", m_id.c_str()).c_str());
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str()).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,8 +555,9 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot)
|
||||
void eap::credentials_connection::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
config::operator<<(cursor);
|
||||
cursor << m_id ;
|
||||
cursor << *m_cred;
|
||||
cursor << m_namespace;
|
||||
cursor << m_id ;
|
||||
cursor << *m_cred ;
|
||||
}
|
||||
|
||||
|
||||
@@ -539,29 +565,31 @@ size_t eap::credentials_connection::get_pk_size() const
|
||||
{
|
||||
return
|
||||
config::get_pk_size() +
|
||||
pksizeof( m_id ) +
|
||||
pksizeof(*m_cred);
|
||||
pksizeof( m_namespace) +
|
||||
pksizeof( m_id ) +
|
||||
pksizeof(*m_cred );
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_connection::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
config::operator>>(cursor);
|
||||
cursor >> m_id;
|
||||
cursor >> m_namespace;
|
||||
cursor >> m_id ;
|
||||
|
||||
// Look-up the provider.
|
||||
for (config_connection::provider_list::const_iterator cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) {
|
||||
if (cfg_prov != cfg_prov_end) {
|
||||
if (_wcsicmp(cfg_prov->m_id.c_str(), m_id.c_str()) == 0) {
|
||||
if (match(*cfg_prov)) {
|
||||
// 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->m_id.c_str()).c_str());
|
||||
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());
|
||||
cursor >> *m_cred;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider ID within this connection configuration (provider ID: %ls).", m_id.c_str()).c_str());
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str()).c_str());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user