From c40f71462fc727afbcc270b368d2bb171f67e618 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 4 Feb 2020 11:18:06 +0100 Subject: [PATCH] ui_context: Merge with ui_context_tls_tunnel Signed-off-by: Simon Rozman --- lib/EAPBase/include/UIContext.h | 1 + lib/EAPBase/src/UIContext.cpp | 9 ++- lib/TTLS/build/TTLS.vcxproj | 2 - lib/TTLS/build/TTLS.vcxproj.filters | 6 -- lib/TTLS/include/UIContext.h | 96 ----------------------------- lib/TTLS/src/Module.cpp | 2 +- lib/TTLS/src/StdAfx.h | 2 +- lib/TTLS/src/UIContext.cpp | 92 --------------------------- lib/TTLS_UI/src/Module.cpp | 2 +- lib/TTLS_UI/src/StdAfx.h | 2 +- 10 files changed, 13 insertions(+), 201 deletions(-) delete mode 100644 lib/TTLS/include/UIContext.h delete mode 100644 lib/TTLS/src/UIContext.cpp diff --git a/lib/EAPBase/include/UIContext.h b/lib/EAPBase/include/UIContext.h index 7b26a8e..d876361 100644 --- a/lib/EAPBase/include/UIContext.h +++ b/lib/EAPBase/include/UIContext.h @@ -96,6 +96,7 @@ namespace eap public: config_connection &m_cfg; ///< Connection configuration credentials_connection &m_cred; ///< Connection credentials + sanitizing_blob m_data; ///< Context data }; /// @} diff --git a/lib/EAPBase/src/UIContext.cpp b/lib/EAPBase/src/UIContext.cpp index 0cd76ae..8896347 100644 --- a/lib/EAPBase/src/UIContext.cpp +++ b/lib/EAPBase/src/UIContext.cpp @@ -38,6 +38,7 @@ eap::ui_context::ui_context(_In_ config_connection &cfg, _In_ credentials_connec eap::ui_context::ui_context(_In_ const ui_context &other) : m_cfg (other.m_cfg ), m_cred (other.m_cred), + m_data (other.m_data), packable(other ) { } @@ -46,6 +47,7 @@ eap::ui_context::ui_context(_In_ const ui_context &other) : eap::ui_context::ui_context(_Inout_ ui_context &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), + m_data (std::move(other.m_data)), packable(std::move(other )) { } @@ -57,6 +59,7 @@ eap::ui_context& eap::ui_context::operator=(_In_ const ui_context &other) assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Copy context within same configuration only! assert(std::addressof(m_cred) == std::addressof(other.m_cred)); // Copy context within same credentials only! (packable&)*this = other; + m_data = other.m_data; } return *this; @@ -69,6 +72,7 @@ eap::ui_context& eap::ui_context::operator=(_Inout_ ui_context &&other) noexcept assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move context within same configuration only! assert(std::addressof(m_cred) == std::addressof(other.m_cred)); // Move context within same credentials only! (packable&)*this = std::move(other); + m_data = std::move(other.m_data); } return *this; @@ -80,6 +84,7 @@ void eap::ui_context::operator<<(_Inout_ cursor_out &cursor) const packable::operator<<(cursor); cursor << m_cfg ; cursor << m_cred; + cursor << m_data; } @@ -88,7 +93,8 @@ size_t eap::ui_context::get_pk_size() const return packable::get_pk_size() + pksizeof(m_cfg ) + - pksizeof(m_cred); + pksizeof(m_cred) + + pksizeof(m_data); } @@ -97,4 +103,5 @@ void eap::ui_context::operator>>(_Inout_ cursor_in &cursor) packable::operator>>(cursor); cursor >> m_cfg ; cursor >> m_cred; + cursor >> m_data; } diff --git a/lib/TTLS/build/TTLS.vcxproj b/lib/TTLS/build/TTLS.vcxproj index 4073ae4..602c8b8 100644 --- a/lib/TTLS/build/TTLS.vcxproj +++ b/lib/TTLS/build/TTLS.vcxproj @@ -106,7 +106,6 @@ - @@ -117,7 +116,6 @@ Create - diff --git a/lib/TTLS/build/TTLS.vcxproj.filters b/lib/TTLS/build/TTLS.vcxproj.filters index 443c939..22a5158 100644 --- a/lib/TTLS/build/TTLS.vcxproj.filters +++ b/lib/TTLS/build/TTLS.vcxproj.filters @@ -26,9 +26,6 @@ Header Files - - Header Files - Header Files @@ -49,8 +46,5 @@ Source Files - - Source Files - \ No newline at end of file diff --git a/lib/TTLS/include/UIContext.h b/lib/TTLS/include/UIContext.h deleted file mode 100644 index a6ab234..0000000 --- a/lib/TTLS/include/UIContext.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright 2015-2020 Amebis - Copyright 2016-2017 GÉANT - - This file is part of GÉANTLink. - - GÉANTLink is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GÉANTLink is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GÉANTLink. If not, see . -*/ - -namespace eap -{ - class ui_context_tls_tunnel; -} - -#pragma once - -#include "TTLS.h" - -#include "../../EAPBase/include/UIContext.h" - - -namespace eap -{ - /// \addtogroup EAPBaseUICtx - /// @{ - - /// - /// TLS tunnel UI context - /// - class ui_context_tls_tunnel : public ui_context - { - public: - /// - /// Constructs context - /// - /// \param[in] cfg Connection configuration - /// \param[in] cred Connection credentials - /// - ui_context_tls_tunnel(_In_ config_connection &cfg, _In_ credentials_connection &cred); - - /// - /// Copies context - /// - /// \param[in] other Credentials to copy from - /// - ui_context_tls_tunnel(_In_ const ui_context_tls_tunnel &other); - - /// - /// Moves context - /// - /// \param[in] other Credentials to move from - /// - ui_context_tls_tunnel(_Inout_ ui_context_tls_tunnel &&other) noexcept; - - /// - /// Copies context - /// - /// \param[in] other Credentials to copy from - /// - /// \returns Reference to this object - /// - ui_context_tls_tunnel& operator=(_In_ const ui_context_tls_tunnel &other); - - /// - /// Moves context - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - ui_context_tls_tunnel& operator=(_Inout_ ui_context_tls_tunnel &&other) noexcept; - - /// \name BLOB management - /// @{ - virtual void operator<<(_Inout_ cursor_out &cursor) const; - virtual size_t get_pk_size() const; - virtual void operator>>(_Inout_ cursor_in &cursor); - /// @} - - public: - sanitizing_blob m_data; ///< Context data - }; - - /// @} -} diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index 245f76e..e152024 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -334,7 +334,7 @@ void eap::peer_tls_tunnel::get_ui_context( auto s = static_cast(hSession); // Get context data from method. - ui_context_tls_tunnel ctx(s->m_cfg, s->m_cred); + ui_context ctx(s->m_cfg, s->m_cred); s->m_method->get_ui_context(ctx.m_data); // Pack context data. diff --git a/lib/TTLS/src/StdAfx.h b/lib/TTLS/src/StdAfx.h index cc502ad..7e028eb 100644 --- a/lib/TTLS/src/StdAfx.h +++ b/lib/TTLS/src/StdAfx.h @@ -26,7 +26,6 @@ #include "../include/Credentials.h" #include "../include/Method.h" #include "../include/Module.h" -#include "../include/UIContext.h" #include "../../PAP/include/Config.h" #include "../../PAP/include/Method.h" @@ -42,6 +41,7 @@ #include "../../EapHost/include/Method.h" #include "../../EAPBase/include/EAPXML.h" +#include "../../EAPBase/include/UIContext.h" #include diff --git a/lib/TTLS/src/UIContext.cpp b/lib/TTLS/src/UIContext.cpp deleted file mode 100644 index d182009..0000000 --- a/lib/TTLS/src/UIContext.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright 2015-2020 Amebis - Copyright 2016 GÉANT - - This file is part of GÉANTLink. - - GÉANTLink is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - GÉANTLink is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GÉANTLink. If not, see . -*/ - -#include "StdAfx.h" - -using namespace std; -using namespace winstd; - - -////////////////////////////////////////////////////////////////////// -// eap::ui_context_tls_tunnel -////////////////////////////////////////////////////////////////////// - -eap::ui_context_tls_tunnel::ui_context_tls_tunnel(_In_ config_connection &cfg, _In_ credentials_connection &cred) : - ui_context(cfg, cred) -{ -} - - -eap::ui_context_tls_tunnel::ui_context_tls_tunnel(_In_ const ui_context_tls_tunnel &other) : - m_data (other.m_data), - ui_context(other ) -{ -} - - -eap::ui_context_tls_tunnel::ui_context_tls_tunnel(_Inout_ ui_context_tls_tunnel &&other) noexcept : - m_data (std::move(other.m_data)), - ui_context(std::move(other )) -{ -} - - -eap::ui_context_tls_tunnel& eap::ui_context_tls_tunnel::operator=(_In_ const ui_context_tls_tunnel &other) -{ - if (this != &other) { - (ui_context&)*this = other; - m_data = other.m_data; - } - - return *this; -} - - -eap::ui_context_tls_tunnel& eap::ui_context_tls_tunnel::operator=(_Inout_ ui_context_tls_tunnel &&other) noexcept -{ - if (this != &other) { - (ui_context&)*this = std::move(other ); - m_data = std::move(other.m_data); - } - - return *this; -} - - -void eap::ui_context_tls_tunnel::operator<<(_Inout_ cursor_out &cursor) const -{ - ui_context::operator<<(cursor); - cursor << m_data; -} - - -size_t eap::ui_context_tls_tunnel::get_pk_size() const -{ - return - ui_context::get_pk_size() + - pksizeof(m_data); -} - - -void eap::ui_context_tls_tunnel::operator>>(_Inout_ cursor_in &cursor) -{ - ui_context::operator>>(cursor); - cursor >> m_data; -} diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index e1c6e06..627c3da 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -352,7 +352,7 @@ void eap::peer_ttls_ui::invoke_interactive_ui( // Unpack context data. config_connection cfg(*this); credentials_connection cred(*this, cfg); - ui_context_tls_tunnel ctx(cfg, cred); + ui_context ctx(cfg, cred); unpack(ctx, pUIContextData, dwUIContextDataSize); // Look-up the provider. diff --git a/lib/TTLS_UI/src/StdAfx.h b/lib/TTLS_UI/src/StdAfx.h index a52ad1c..6151e37 100644 --- a/lib/TTLS_UI/src/StdAfx.h +++ b/lib/TTLS_UI/src/StdAfx.h @@ -32,6 +32,6 @@ #include "../../GTC_UI/include/GTC_UI.h" #include "../../EapHost/include/Credentials.h" -#include "../../TTLS/include/UIContext.h" +#include "../../EapBase/include/UIContext.h" #include