Compare commits
45 Commits
1.0-alpha3
...
1.0-alpha5
Author | SHA1 | Date | |
---|---|---|---|
d792520f51 | |||
9f4c4514cb | |||
de94d27380 | |||
ded87eb18c | |||
0639169d9a | |||
fa141fc525 | |||
1fc77fc63d | |||
d15b7066cd | |||
922d0ac3d0 | |||
f3cb90d1c3 | |||
a7e0e5ebd8 | |||
3238881af8 | |||
9d0d3418b0 | |||
81a268df1b | |||
d1a4487503 | |||
24008000a9 | |||
bdd3fc616c | |||
e31fc08a64 | |||
a2ca2fd850 | |||
e98856f934 | |||
b634956901 | |||
0c8492ccd1 | |||
768e0a5a36 | |||
ac23d5f04f | |||
e52b9a636f | |||
2f0948b4fd | |||
33a72acac7 | |||
d430b63829 | |||
cda81dd696 | |||
6e15d3535d | |||
ec0b283540 | |||
03358170f4 | |||
a9fdd1d71d | |||
ef9fa750a0 | |||
fed1e6052a | |||
2f0252a33f | |||
11c28326aa | |||
df2fee4cef | |||
9cf80108b5 | |||
e0460fa15b | |||
8bff2d3060 | |||
822852c8b4 | |||
155671a4da | |||
f675083891 | |||
cf7ca9c8e9 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/*.opensdf
|
||||
/*.suo
|
||||
/*.sdf
|
||||
/doc
|
||||
/ipch
|
||||
|
@@ -7,8 +7,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\EAPMethods\EAPMethodEvents\temp\EAPMethodEvents.$(Platform).$(Configuration).$(PlatformToolset);..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>EAPMETHOD_TYPE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\lib\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
|
Binary file not shown.
@@ -86,8 +86,6 @@
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\EAPMethods\src\EAP.cpp" />
|
||||
<ClCompile Include="..\EAPMethods\src\PAP.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
@@ -100,9 +98,15 @@
|
||||
<ResourceCompile Include="CredWrite.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EAPMethods\EAPMethodEvents\EAPMethodEvents.vcxproj">
|
||||
<ProjectReference Include="..\lib\EAPBase\build\EAPBase.vcxproj">
|
||||
<Project>{ad6816a0-9600-4e01-8c49-39d03d1e791f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\PAP\build\PAP.vcxproj">
|
||||
<Project>{36b0cf8a-7794-46c3-8099-825ba962b4c7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
|
@@ -26,12 +26,6 @@
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\EAPMethods\src\EAP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\EAPMethods\src\PAP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="CredWrite.rc">
|
||||
|
@@ -20,12 +20,10 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#pragma comment(lib, "Crypt32.lib")
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
eap::module g_module;
|
||||
eap::module g_module(eap::type_undefined);
|
||||
|
||||
|
||||
static int CredWrite()
|
||||
@@ -83,14 +81,27 @@ static int CredWrite()
|
||||
}
|
||||
|
||||
// Write credentials.
|
||||
EAP_ERROR *pEapError;
|
||||
DWORD dwResult;
|
||||
if ((dwResult = cred.store(target_name.c_str(), &pEapError)) != ERROR_SUCCESS) {
|
||||
EAP_ERROR *pEapError = NULL;
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
eap::credentials_pap cred_stored(g_module);
|
||||
if (!cred_stored.retrieve(target_name.c_str(), &pEapError)) {
|
||||
if (pEapError) {
|
||||
OutputDebugStr(_T("%ls (error %u)\n"), pEapError->pRootCauseString, pEapError->dwWinError);
|
||||
g_module.free_error_memory(pEapError);
|
||||
pEapError = NULL;
|
||||
} else
|
||||
OutputDebugStr(_T("Reading credentials failed.\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!cred.store(target_name.c_str(), &pEapError)) {
|
||||
if (pEapError) {
|
||||
OutputDebugStr(_T("%ls (error %u)\n"), pEapError->pRootCauseString, pEapError->dwWinError);
|
||||
g_module.free_error_memory(pEapError);
|
||||
pEapError = NULL;
|
||||
} else
|
||||
OutputDebugStr(_T("Writing credentials failed (error %u).\n"), dwResult);
|
||||
OutputDebugStr(_T("Writing credentials failed.\n"));
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
@@ -20,17 +20,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/Version.h"
|
||||
|
||||
#include "../EAPMethods/include/EAP.h"
|
||||
#include "../EAPMethods/include/PAP.h"
|
||||
#include "../lib/PAP/include/Credentials.h"
|
||||
#include "../lib/EAPBase/include/Module.h"
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
#include <WinStd/Base64.h>
|
||||
#include <WinStd/Cred.h>
|
||||
#include <WinStd/Crypt.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <Windows.h>
|
||||
#include <eaptypes.h> // Must include after <Windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <memory>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.8.7
|
||||
# Doxyfile 1.8.7
|
||||
|
||||
# This file describes the settings to be used by the documentation system
|
||||
# doxygen (www.doxygen.org) for a project.
|
||||
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
|
||||
# title of most generated pages and in a few other places.
|
||||
# The default value is: My Project.
|
||||
|
||||
PROJECT_NAME = "EAPModules"
|
||||
PROJECT_NAME = "GÉANTLink"
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
@@ -44,7 +44,7 @@ PROJECT_NUMBER =
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
# quick idea about the purpose of the project. Keep the description short.
|
||||
|
||||
PROJECT_BRIEF = "EAP Modules"
|
||||
PROJECT_BRIEF = "EAP Supplicant for Windows"
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
|
||||
# the documentation. The maximum height of the logo should not exceed 55 pixels
|
||||
@@ -718,7 +718,7 @@ WARN_IF_UNDOCUMENTED = YES
|
||||
# markup commands wrongly.
|
||||
# The default value is: YES.
|
||||
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_IF_DOC_ERROR = NO
|
||||
|
||||
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
|
||||
# are documented, but have no documentation for their parameters or return
|
||||
@@ -726,7 +726,7 @@ WARN_IF_DOC_ERROR = YES
|
||||
# documentation, but not about the absence of documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_NO_PARAMDOC = YES
|
||||
|
||||
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
|
||||
# can produce. The string should contain the $file, $line, and $text tags, which
|
||||
@@ -789,7 +789,11 @@ RECURSIVE = YES
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE = res
|
||||
EXCLUDE = \
|
||||
lib\EAPBase_UI\res \
|
||||
lib\TLS_UI\res \
|
||||
lib\TTLS_UI\res \
|
||||
lib\WinStd
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
1
EAPMethods/.gitignore
vendored
1
EAPMethods/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/doc
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="..\..\include\ResourceDLL.props" />
|
||||
<Import Project="..\build\Common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup />
|
||||
<ItemGroup />
|
||||
</Project>
|
Binary file not shown.
@@ -79,20 +79,10 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\EAP.h" />
|
||||
<ClInclude Include="..\include\EAPSerial.h" />
|
||||
<ClInclude Include="..\include\TLS.h" />
|
||||
<ClInclude Include="..\include\TTLS.h" />
|
||||
<ClInclude Include="..\include\EAPXML.h" />
|
||||
<ClInclude Include="..\include\PAP.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\EAP.cpp" />
|
||||
<ClCompile Include="..\src\TLS.cpp" />
|
||||
<ClCompile Include="..\src\TTLS.cpp" />
|
||||
<ClCompile Include="..\src\Main.cpp" />
|
||||
<ClCompile Include="..\src\PAP.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
@@ -104,12 +94,24 @@
|
||||
<ResourceCompile Include="EAPTTLS.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\EAPBase\build\EAPBase.vcxproj">
|
||||
<Project>{ad6816a0-9600-4e01-8c49-39d03d1e791f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\PAP\build\PAP.vcxproj">
|
||||
<Project>{36b0cf8a-7794-46c3-8099-825ba962b4c7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\TLS\build\TLS.vcxproj">
|
||||
<Project>{4d40cb8a-812e-4f12-b23a-31af743878e8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\TTLS\build\TTLS.vcxproj">
|
||||
<Project>{ee0ef0d9-a475-4038-8637-5754724f65b0}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\EAPMethodEvents\EAPMethodEvents.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\build\EAPMethod.def" />
|
||||
|
@@ -18,24 +18,6 @@
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\TTLS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\PAP.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAPXML.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\TLS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAP.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAPSerial.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
@@ -44,18 +26,6 @@
|
||||
<ClCompile Include="..\src\Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\PAP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\EAP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TLS.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TTLS.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EAPTTLS.rc">
|
||||
|
@@ -20,31 +20,5 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../include/Version.h"
|
||||
|
||||
#include "../include/EAP.h"
|
||||
#include "../include/EAPSerial.h"
|
||||
#include "../include/TLS.h"
|
||||
#include "../include/TTLS.h"
|
||||
#include "../include/EAPXML.h"
|
||||
#include "../include/PAP.h"
|
||||
|
||||
#include <WinStd/Base64.h>
|
||||
#include <WinStd/Cred.h>
|
||||
#include <WinStd/Crypt.h>
|
||||
#include <WinStd/ETW.h>
|
||||
#include <WinStd/Hex.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <eaptypes.h>
|
||||
#include <eapmethodpeerapis.h>
|
||||
|
||||
#include <Commctrl.h>
|
||||
#include <Msi.h>
|
||||
#include <tchar.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <EAPMethodETW.h>
|
||||
|
||||
#pragma comment(lib, "Crypt32.lib")
|
||||
#include "../../lib/TTLS/include/Module.h"
|
||||
#include "../../lib/TTLS/include/Session.h"
|
||||
|
Binary file not shown.
@@ -79,33 +79,10 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\EAP.h" />
|
||||
<ClInclude Include="..\include\EAPXML.h" />
|
||||
<ClInclude Include="..\include\EAP_UI.h" />
|
||||
<ClInclude Include="..\include\PAP_UI.h" />
|
||||
<ClInclude Include="..\include\TLS.h" />
|
||||
<ClInclude Include="..\include\TTLS.h" />
|
||||
<ClInclude Include="..\include\TTLS_UI.h" />
|
||||
<ClInclude Include="..\include\PAP.h" />
|
||||
<ClInclude Include="..\include\TLS_UI.h" />
|
||||
<ClInclude Include="..\res\wxEAP_UI.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
<ClInclude Include="..\res\wxTLS_UI.h" />
|
||||
<ClInclude Include="..\res\wxTTLS_UI.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\res\wxEAP_UI.cpp" />
|
||||
<ClCompile Include="..\res\wxTLS_UI.cpp" />
|
||||
<ClCompile Include="..\res\wxTTLS_UI.cpp" />
|
||||
<ClCompile Include="..\src\EAP.cpp" />
|
||||
<ClCompile Include="..\src\PAP_UI.cpp" />
|
||||
<ClCompile Include="..\src\TLS.cpp" />
|
||||
<ClCompile Include="..\src\TTLS.cpp" />
|
||||
<ClCompile Include="..\src\TTLS_UI.cpp" />
|
||||
<ClCompile Include="..\src\Main_UI.cpp" />
|
||||
<ClCompile Include="..\src\PAP.cpp" />
|
||||
<ClCompile Include="..\src\EAP_UI.cpp" />
|
||||
<ClCompile Include="..\src\TLS_UI.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
@@ -117,18 +94,39 @@
|
||||
<ResourceCompile Include="EAPTTLSUI.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\EAPBase\build\EAPBase.vcxproj">
|
||||
<Project>{ad6816a0-9600-4e01-8c49-39d03d1e791f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\EAPBase_UI\build\EAPBase_UI.vcxproj">
|
||||
<Project>{d4b54856-be1f-4937-a8f7-495125be76be}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\PAP\build\PAP.vcxproj">
|
||||
<Project>{36b0cf8a-7794-46c3-8099-825ba962b4c7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\PAP_UI\build\PAP_UI.vcxproj">
|
||||
<Project>{3d309c2e-64ab-4bc4-a16d-468571a2bc1a}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\TLS\build\TLS.vcxproj">
|
||||
<Project>{4d40cb8a-812e-4f12-b23a-31af743878e8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\TLS_UI\build\TLS_UI.vcxproj">
|
||||
<Project>{9a25c261-8ade-4938-8393-e857ef0e37e9}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\TTLS\build\TTLS.vcxproj">
|
||||
<Project>{ee0ef0d9-a475-4038-8637-5754724f65b0}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\TTLS_UI\build\TTLS_UI.vcxproj">
|
||||
<Project>{42f0f0f4-c928-4860-a4e4-94991c2c3d90}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\EAPMethodEvents\EAPMethodEvents.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\build\EAPMethodUI.def" />
|
||||
<None Include="..\res\wxEAP_UI.fbp" />
|
||||
<None Include="..\res\wxTLS_UI.fbp" />
|
||||
<None Include="..\res\wxTTLS_UI.fbp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@@ -13,97 +13,19 @@
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\wx">
|
||||
<UniqueIdentifier>{51f0404d-9280-4fcc-8138-5d1f815ce568}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\wx">
|
||||
<UniqueIdentifier>{9befee7a-5dff-41dd-b080-4e26ccb19a7f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files\wx">
|
||||
<UniqueIdentifier>{0ec1840b-101c-415a-91c6-2c7eb4530c15}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\TTLS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\PAP.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\TLS_UI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\TLS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\res\wxEAP_UI.h">
|
||||
<Filter>Header Files\wx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\res\wxTLS_UI.h">
|
||||
<Filter>Header Files\wx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\res\wxTTLS_UI.h">
|
||||
<Filter>Header Files\wx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAP.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAP_UI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\TTLS_UI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAPXML.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\PAP_UI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\PAP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\res\wxEAP_UI.cpp">
|
||||
<Filter>Source Files\wx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\res\wxTLS_UI.cpp">
|
||||
<Filter>Source Files\wx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\res\wxTTLS_UI.cpp">
|
||||
<Filter>Source Files\wx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\EAP.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\EAP_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TLS.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TLS_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TTLS.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\TTLS_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Main_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\PAP_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EAPTTLSUI.rc">
|
||||
@@ -114,14 +36,5 @@
|
||||
<None Include="..\build\EAPMethodUI.def">
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
<None Include="..\res\wxEAP_UI.fbp">
|
||||
<Filter>Resource Files\wx</Filter>
|
||||
</None>
|
||||
<None Include="..\res\wxTTLS_UI.fbp">
|
||||
<Filter>Resource Files\wx</Filter>
|
||||
</None>
|
||||
<None Include="..\res\wxTLS_UI.fbp">
|
||||
<Filter>Resource Files\wx</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -18,48 +18,6 @@
|
||||
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../include/Version.h"
|
||||
|
||||
#include "../include/EAP.h"
|
||||
#include "../include/EAP_UI.h"
|
||||
#include "../include/EAPSerial.h"
|
||||
#include "../include/EAPXML.h"
|
||||
#include "../include/TLS.h"
|
||||
#include "../include/TLS_UI.h"
|
||||
#include "../include/TTLS.h"
|
||||
#include "../include/TTLS_UI.h"
|
||||
#include "../include/PAP.h"
|
||||
#include "../include/PAP_UI.h"
|
||||
|
||||
#include "../res/wxTLS_UI.h"
|
||||
#include "../res/wxTTLS_UI.h"
|
||||
|
||||
#include <WinStd/Base64.h>
|
||||
#include <WinStd/Cred.h>
|
||||
#include <WinStd/Crypt.h>
|
||||
#include <WinStd/ETW.h>
|
||||
#include <WinStd/Hex.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/init.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <eaptypes.h>
|
||||
#include <eapmethodpeerapis.h>
|
||||
|
||||
#include <Commctrl.h>
|
||||
#include <cryptuiapi.h>
|
||||
#include <Msi.h>
|
||||
#include <tchar.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <EAPMethodETW.h>
|
||||
|
||||
#pragma comment(lib, "Crypt32.lib")
|
||||
#include "../../lib/TTLS_UI/include/Module.h"
|
||||
|
Binary file not shown.
@@ -8,11 +8,8 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);..\EAPMethodEvents\temp\EAPMethodEvents.$(Platform).$(Configuration).$(PlatformToolset);..\include;..\..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);..\..\lib\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\include;..\..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>temp\EAPMethodEvents.$(Platform).$(Configuration).$(PlatformToolset);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
@@ -1,444 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "EAP.h"
|
||||
#include "../res/wxEAP_UI.h"
|
||||
|
||||
#include <WinStd/Cred.h>
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/log.h>
|
||||
#include <CommCtrl.h>
|
||||
|
||||
namespace eap
|
||||
{
|
||||
template <class _Tmeth, class _Tid, class _Tint, class _Tintres> class peer_ui;
|
||||
}
|
||||
|
||||
template <class _Tcfg, class _wxT> class wxEAPConfigDialog;
|
||||
class wxEAPCredentialsDialog;
|
||||
class wxEAPBannerPanel;
|
||||
template <class _Tcfg, class _Tcred, class _Tpanel> class wxEAPCredentialsConfigPanel;
|
||||
template <class _Tbase, class _Tcred> class wxCredentialsPanel;
|
||||
class wxPasswordCredentialsPanel;
|
||||
|
||||
inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName);
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// EAP UI peer base abstract class template
|
||||
///
|
||||
/// A group of methods all EAP UI peers must or should implement.
|
||||
///
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres>
|
||||
class peer_ui : public peer_base<_Tcfg, _Tid, _Tint, _Tintres>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
peer_ui() : peer_base<_Tcfg, _Tid, _Tint, _Tintres>() {}
|
||||
|
||||
///
|
||||
/// Raises the EAP method's specific connection configuration user interface dialog on the client.
|
||||
///
|
||||
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
|
||||
///
|
||||
/// \param[in] hwndParent Parent window
|
||||
/// \param[inout] cfg Configuration to edit
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD invoke_config_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_Inout_ config_type &cfg,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client.
|
||||
///
|
||||
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
|
||||
///
|
||||
/// \param[in] hwndParent Parent window
|
||||
/// \param[in] dwFlags Flags passed to `EapPeerInvokeIdentityUI()` call
|
||||
/// \param[inout] cfg Configuration
|
||||
/// \param[inout] usr User data to edit
|
||||
/// \param[out] ppwszIdentity Pointer to user identity. Free using `module::free_memory()`.
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD invoke_identity_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_In_ DWORD dwFlags,
|
||||
_Inout_ config_type &cfg,
|
||||
_Inout_ identity_type &usr,
|
||||
_Out_ LPWSTR *ppwszIdentity,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Raises a custom interactive user interface dialog for the EAP method on the client.
|
||||
///
|
||||
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
|
||||
///
|
||||
/// \param[in] hwndParent Parent window
|
||||
/// \param[in] req Interactive request
|
||||
/// \param[out] res Interactive response
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD invoke_interactive_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_In_ const interactive_request_type &req,
|
||||
_Out_ interactive_response_type &res,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// EAP configuration dialog
|
||||
///
|
||||
template <class _Tmeth, class _wxT>
|
||||
class wxEAPConfigDialog : public wxEAPConfigDialogBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Configuration provider data type
|
||||
///
|
||||
typedef eap::config_provider<_Tmeth> _Tprov;
|
||||
|
||||
///
|
||||
/// Configuration data type
|
||||
///
|
||||
typedef eap::config_providers<_Tprov> config_type;
|
||||
|
||||
///
|
||||
/// This data type
|
||||
///
|
||||
typedef wxEAPConfigDialog<_Tmeth, _wxT> _T;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration dialog
|
||||
///
|
||||
wxEAPConfigDialog(config_type &cfg, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
wxEAPConfigDialogBase(parent)
|
||||
{
|
||||
// Set extra style here, as wxFormBuilder overrides all default flags.
|
||||
this->SetExtraStyle(this->GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
|
||||
|
||||
for (std::list<_Tprov>::iterator provider = m_cfg.m_providers.begin(), provider_end = m_cfg.m_providers.end(); provider != provider_end; ++provider) {
|
||||
bool is_single = provider->m_methods.size() == 1;
|
||||
std::list<_Tmeth>::size_type count = 0;
|
||||
std::list<_Tmeth>::iterator method = provider->m_methods.begin(), method_end = provider->m_methods.end();
|
||||
for (; method != method_end; ++method, count++)
|
||||
m_providers->AddPage(
|
||||
new _wxT(
|
||||
provider->m_methods.front(),
|
||||
provider->m_id.c_str(),
|
||||
m_providers),
|
||||
is_single ? provider->m_id : winstd::tstring_printf(_T("%s (%u)"), provider->m_id.c_str(), count));
|
||||
}
|
||||
|
||||
this->Layout();
|
||||
this->GetSizer()->Fit(this);
|
||||
|
||||
m_buttonsOK->SetDefault();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
for (wxWindowList::compatibility_iterator provider = m_providers->GetChildren().GetFirst(); provider; provider = provider->GetNext()) {
|
||||
_wxT *prov = wxDynamicCast(provider->GetData(), _wxT);
|
||||
if (prov)
|
||||
prov->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
|
||||
protected:
|
||||
config_type &m_cfg; ///< EAP providers configuration
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// EAP credentials dialog
|
||||
///
|
||||
class wxEAPCredentialsDialog : public wxEAPCredentialsDialogBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credential dialog
|
||||
///
|
||||
wxEAPCredentialsDialog(wxWindow* parent);
|
||||
|
||||
///
|
||||
/// Adds panels to the dialog
|
||||
///
|
||||
void AddContents(wxPanel **contents, size_t content_count);
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event);
|
||||
/// \endcond
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// EAP dialog banner
|
||||
///
|
||||
class wxEAPBannerPanel : public wxEAPBannerPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a banner pannel and set the title text to product name
|
||||
///
|
||||
wxEAPBannerPanel(wxWindow* parent);
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool AcceptsFocusFromKeyboard() const { return false; }
|
||||
/// \endcond
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Base template for credentials configuration panel
|
||||
///
|
||||
template <class _Tcfg, class _Tcred, class _Tpanel>
|
||||
class wxEAPCredentialsConfigPanel : public wxEAPCredentialsConfigPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credential configuration panel
|
||||
///
|
||||
/// \param[inout] cfg Configuration data
|
||||
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
|
||||
/// \param[in] parent Parent window
|
||||
///
|
||||
wxEAPCredentialsConfigPanel(_Tcfg &cfg, LPCTSTR pszCredTarget, wxWindow *parent) :
|
||||
m_cfg(cfg),
|
||||
m_target(pszCredTarget),
|
||||
m_cred(m_cfg.m_module),
|
||||
wxEAPCredentialsConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(48));
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnUpdateUI(wxUpdateUIEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
DWORD dwResult;
|
||||
|
||||
std::unique_ptr<CREDENTIAL, winstd::CredFree_delete<CREDENTIAL> > cred;
|
||||
if (CredRead(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
m_clear->Enable(true);
|
||||
m_identity->SetValue(cred->UserName && cred->UserName[0] != 0 ? cred->UserName : _("<blank>"));
|
||||
} else if ((dwResult = GetLastError()) == ERROR_NOT_FOUND) {
|
||||
m_clear->Enable(false);
|
||||
m_identity->Clear();
|
||||
} else {
|
||||
m_clear->Enable(true);
|
||||
m_identity->SetValue(wxString::Format(_("<error %u>"), dwResult));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnSet(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
wxEAPCredentialsDialog dlg(this);
|
||||
|
||||
_Tpanel *panel = new _Tpanel(m_cred, m_target.c_str(), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
virtual void OnClear(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
if (!CredDelete(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0))
|
||||
wxLogError(_("Deleting credentials failed (error %u)."), GetLastError());
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tcfg &m_cfg; ///< EAP configuration
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
|
||||
private:
|
||||
_Tcred m_cred; ///< Temporary credential data
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Base template for all credential panels
|
||||
///
|
||||
template <class _Tbase, class _Tcred>
|
||||
class wxCredentialsPanel : public _Tbase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credentials panel
|
||||
///
|
||||
/// \param[inout] cred Credentials data
|
||||
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
|
||||
/// \param[in] parent Parent window
|
||||
/// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled.
|
||||
///
|
||||
wxCredentialsPanel(_Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) :
|
||||
m_cred(cred),
|
||||
m_target(pszCredTarget),
|
||||
_Tbase(parent)
|
||||
{
|
||||
if (is_config) {
|
||||
// User is setting credentials via configuration UI.
|
||||
// => Pointless if not stored to Credential Manager
|
||||
m_remember->SetValue(true);
|
||||
m_remember->Enable(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(_Tbase::TransferDataToWindow(), false);
|
||||
|
||||
// Read credentials from Credential Manager
|
||||
EAP_ERROR *pEapError;
|
||||
DWORD dwResult;
|
||||
if ((dwResult = m_cred.retrieve(m_target.c_str(), &pEapError)) == ERROR_SUCCESS) {
|
||||
m_remember->SetValue(true);
|
||||
} else if (dwResult != ERROR_NOT_FOUND) {
|
||||
if (pEapError) {
|
||||
wxLogError(winstd::tstring_printf(_("Error reading credentials from Credential Manager: %ls (error %u)"), pEapError->pRootCauseString, pEapError->dwWinError).c_str());
|
||||
m_cred.m_module.free_error_memory(pEapError);
|
||||
} else
|
||||
wxLogError(_("Reading credentials failed (error %u)."), dwResult);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
// Write credentials to credential manager.
|
||||
if (m_remember->GetValue()) {
|
||||
EAP_ERROR *pEapError;
|
||||
DWORD dwResult;
|
||||
if ((dwResult = m_cred.store(m_target.c_str(), &pEapError)) != ERROR_SUCCESS) {
|
||||
if (pEapError) {
|
||||
wxLogError(winstd::tstring_printf(_("Error writing credentials to Credential Manager: %ls (error %u)"), pEapError->pRootCauseString, pEapError->dwWinError).c_str());
|
||||
m_cred.m_module.free_error_memory(pEapError);
|
||||
} else
|
||||
wxLogError(_("Writing credentials failed (error %u)."), dwResult);
|
||||
}
|
||||
}
|
||||
|
||||
return _Tbase::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tcred &m_cred; ///< Password credentials
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Password credentials panel
|
||||
///
|
||||
class wxPasswordCredentialsPanel : public wxCredentialsPanel<wxPasswordCredentialsPanelBase, eap::credentials_pass>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a password credentials panel
|
||||
///
|
||||
/// \param[inout] cred Credentials data
|
||||
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
|
||||
/// \param[in] parent Parent window
|
||||
/// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled.
|
||||
///
|
||||
wxPasswordCredentialsPanel(eap::credentials_pass &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false);
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
|
||||
private:
|
||||
static const wxStringCharType *s_dummy_password;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Sets icon from resource
|
||||
///
|
||||
inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName)
|
||||
{
|
||||
wxASSERT(bmp);
|
||||
|
||||
HICON hIcon;
|
||||
if (SUCCEEDED(LoadIconWithScaleDown(hinst, pszName, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), &hIcon))) {
|
||||
icon.CreateFromHICON(hIcon);
|
||||
bmp->SetIcon(icon);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PAP.h"
|
||||
|
||||
typedef wxEAPCredentialsConfigPanel<eap::config_pap, eap::credentials_pap, wxPasswordCredentialsPanel> wxPAPCredentialsConfigPanel;
|
||||
class wxPAPConfigPanel;
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///
|
||||
/// PAP configuration panel
|
||||
///
|
||||
class wxPAPConfigPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxPAPConfigPanel(eap::config_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent);
|
||||
|
||||
///
|
||||
/// Destructs the configuration panel
|
||||
///
|
||||
virtual ~wxPAPConfigPanel();
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event);
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
wxPAPCredentialsConfigPanel *m_credentials; ///< Credentials configuration panel
|
||||
wxStaticText *m_label; ///< No-configuration notice
|
||||
};
|
@@ -1,352 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "EAP.h"
|
||||
#include "EAPSerial.h"
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class config_tls;
|
||||
class credentials_tls;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val);
|
||||
inline size_t get_pk_size(const eap::config_tls &val);
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_tls &val);
|
||||
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_tls &val);
|
||||
inline size_t get_pk_size(const eap::credentials_tls &val);
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// TLS configuration
|
||||
///
|
||||
class config_tls : public config_method
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs configuration
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
config_tls(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
///
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
config_tls(_In_ const config_tls &other);
|
||||
|
||||
///
|
||||
/// Moves configuration
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
config_tls(_Inout_ config_tls &&other);
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
///
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
config_tls& operator=(_In_ const config_tls &other);
|
||||
|
||||
///
|
||||
/// Moves configuration
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
config_tls& operator=(_Inout_ config_tls &&other);
|
||||
|
||||
///
|
||||
/// Clones configuration
|
||||
///
|
||||
/// \returns Pointer to cloned configuration
|
||||
///
|
||||
virtual config* clone() const { return new config_tls(*this); }
|
||||
|
||||
/// \name XML configuration management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save configuration to XML document
|
||||
///
|
||||
/// \param[in] pDoc XML document
|
||||
/// \param[in] pConfigRoot Suggested root element for saving configuration
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Load configuration from XML document
|
||||
///
|
||||
/// \param[in] pConfigRoot Root element for loading configuration
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
///
|
||||
/// \returns `eap::type_tls`
|
||||
///
|
||||
virtual eap::type_t get_method_id() { return eap::type_tls; }
|
||||
|
||||
///
|
||||
/// Adds CA to the list of trusted root CA's
|
||||
///
|
||||
/// \sa [CertCreateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376033.aspx)
|
||||
///
|
||||
bool add_trusted_ca(_In_ DWORD dwCertEncodingType, _In_ const BYTE *pbCertEncoded, _In_ DWORD cbCertEncoded);
|
||||
|
||||
public:
|
||||
std::list<winstd::cert_context> m_trusted_root_ca; ///< Trusted root CAs
|
||||
std::list<std::string> m_server_names; ///< Acceptable authenticating server names
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TLS credentials
|
||||
///
|
||||
class credentials_tls : public credentials
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs credentials
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
credentials_tls(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
credentials_tls(_In_ const credentials_tls &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
credentials_tls(_Inout_ credentials_tls &&other);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_tls& operator=(_In_ const credentials_tls &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_tls& operator=(_Inout_ credentials_tls &&other);
|
||||
|
||||
///
|
||||
/// Clones credentials
|
||||
///
|
||||
/// \returns Pointer to cloned credentials
|
||||
///
|
||||
virtual config* clone() const { return new credentials_tls(*this); }
|
||||
|
||||
///
|
||||
/// Resets credentials
|
||||
///
|
||||
virtual void clear();
|
||||
|
||||
///
|
||||
/// Test credentials if blank
|
||||
///
|
||||
virtual bool empty() const;
|
||||
|
||||
/// \name XML credentials management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Load credentials from XML document
|
||||
///
|
||||
/// \param[in] pConfigRoot Root element for loading credentials
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save credentials to Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Retrieve credentials from Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
///
|
||||
/// Return target suffix for Windows Credential Manager credential name
|
||||
///
|
||||
virtual LPCTSTR target_suffix() const { return _T("TLS"); }
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
std::vector<unsigned char> m_cert_hash; ///< Client certificate hash (certificates are kept in Personal Certificate Storage)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a TLS method configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val)
|
||||
{
|
||||
pack(cursor, (const eap::config_method&)val);
|
||||
pack(cursor, val.m_trusted_root_ca );
|
||||
pack(cursor, val.m_server_names );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a TLS method configuration
|
||||
///
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::config_tls &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::config_method&)val) +
|
||||
get_pk_size(val.m_trusted_root_ca ) +
|
||||
get_pk_size(val.m_server_names );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a TLS method configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_tls &val)
|
||||
{
|
||||
unpack(cursor, (eap::config_method&)val );
|
||||
unpack(cursor, val.m_trusted_root_ca);
|
||||
unpack(cursor, val.m_server_names );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs a TLS method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_tls &val)
|
||||
{
|
||||
pack(cursor, (const eap::credentials&)val);
|
||||
pack(cursor, val.m_cert_hash );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a TLS method credentials
|
||||
///
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::credentials_tls &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::credentials&)val) +
|
||||
get_pk_size(val.m_cert_hash );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a TLS method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Credentials to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val)
|
||||
{
|
||||
unpack(cursor, (eap::credentials&)val);
|
||||
unpack(cursor, val.m_cert_hash );
|
||||
}
|
||||
}
|
@@ -1,346 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "TLS.h"
|
||||
#include "../res/wxTLS_UI.h"
|
||||
|
||||
#include <wx/icon.h>
|
||||
#include <wx/validate.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class wxCertificateClientData;
|
||||
class wxCertificateSelectionClientData;
|
||||
class wxHostNameValidator;
|
||||
class wxFQDNValidator;
|
||||
class wxFQDNListValidator;
|
||||
|
||||
class wxEAPTLSCredentialsPanel;
|
||||
class wxEAPTLSServerTrustPanel;
|
||||
typedef wxEAPCredentialsConfigPanel<eap::config_tls, eap::credentials_tls, wxEAPTLSCredentialsPanel> wxEAPTLSCredentialsConfigPanel;
|
||||
class wxEAPTLSConfigPanel;
|
||||
|
||||
namespace eap
|
||||
{
|
||||
void get_cert_title(PCCERT_CONTEXT cert, winstd::tstring &title);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///
|
||||
/// Helper class for auto-destroyable certificates used in wxWidget's item containers
|
||||
///
|
||||
class wxCertificateClientData : public wxClientData
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs client data object with existing handle
|
||||
///
|
||||
wxCertificateClientData(PCCERT_CONTEXT cert);
|
||||
|
||||
///
|
||||
/// Releases certificate handle and destructs the object
|
||||
///
|
||||
virtual ~wxCertificateClientData();
|
||||
|
||||
public:
|
||||
PCCERT_CONTEXT m_cert; ///< Certificate
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Helper class for auto-destroyable certificates used in wxWidget's item containers
|
||||
///
|
||||
class wxCertificateSelectionClientData : public wxClientData
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Default constructor
|
||||
///
|
||||
wxCertificateSelectionClientData();
|
||||
|
||||
///
|
||||
/// Constructs client data object
|
||||
///
|
||||
wxCertificateSelectionClientData(const wchar_t *identity, unsigned char *hash, size_t hash_size);
|
||||
|
||||
///
|
||||
/// Constructs client data object with copy
|
||||
///
|
||||
wxCertificateSelectionClientData(const std::wstring &identity, const std::vector<unsigned char> &hash);
|
||||
|
||||
///
|
||||
/// Constructs client data object with move
|
||||
///
|
||||
wxCertificateSelectionClientData(std::wstring &&identity, std::vector<unsigned char> &&hash);
|
||||
|
||||
///
|
||||
/// Constructs client data object with copy
|
||||
///
|
||||
wxCertificateSelectionClientData(const wxCertificateSelectionClientData &other);
|
||||
|
||||
///
|
||||
/// Constructs client data object with move
|
||||
///
|
||||
wxCertificateSelectionClientData(wxCertificateSelectionClientData &&other);
|
||||
|
||||
public:
|
||||
std::wstring m_identity; ///< Client identity
|
||||
std::vector<unsigned char> m_hash; ///< Client certificate hash (certificates are kept in Personal Certificate Storage)
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Validator for host name
|
||||
///
|
||||
class wxHostNameValidator : public wxValidator
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxHostNameValidator);
|
||||
wxDECLARE_NO_ASSIGN_CLASS(wxHostNameValidator);
|
||||
|
||||
public:
|
||||
///
|
||||
/// Construct the validator with a value to store data
|
||||
///
|
||||
wxHostNameValidator(std::string *val = NULL);
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
wxHostNameValidator(const wxHostNameValidator &other);
|
||||
|
||||
///
|
||||
/// Copies this validator
|
||||
///
|
||||
virtual wxObject* Clone() const;
|
||||
|
||||
///
|
||||
/// Validates the value
|
||||
///
|
||||
virtual bool Validate(wxWindow *parent);
|
||||
|
||||
///
|
||||
/// Transfers the value to the window
|
||||
///
|
||||
virtual bool TransferToWindow();
|
||||
|
||||
///
|
||||
/// Transfers the value from the window
|
||||
///
|
||||
virtual bool TransferFromWindow();
|
||||
|
||||
///
|
||||
/// Parses FQDN value
|
||||
///
|
||||
static bool Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, std::string *val_out = NULL);
|
||||
|
||||
protected:
|
||||
std::string *m_val; ///< Pointer to variable to receive control's parsed value
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Validator for FQDN
|
||||
///
|
||||
class wxFQDNValidator : public wxValidator
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxFQDNValidator);
|
||||
wxDECLARE_NO_ASSIGN_CLASS(wxFQDNValidator);
|
||||
|
||||
public:
|
||||
///
|
||||
/// Construct the validator with a value to store data
|
||||
///
|
||||
wxFQDNValidator(std::string *val = NULL);
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
wxFQDNValidator(const wxFQDNValidator &other);
|
||||
|
||||
///
|
||||
/// Copies this validator
|
||||
///
|
||||
virtual wxObject* Clone() const;
|
||||
|
||||
///
|
||||
/// Validates the value
|
||||
///
|
||||
virtual bool Validate(wxWindow *parent);
|
||||
|
||||
///
|
||||
/// Transfers the value to the window
|
||||
///
|
||||
virtual bool TransferToWindow();
|
||||
|
||||
///
|
||||
/// Transfers the value from the window
|
||||
///
|
||||
virtual bool TransferFromWindow();
|
||||
|
||||
///
|
||||
/// Parses FQDN value
|
||||
///
|
||||
static bool Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, std::string *val_out = NULL);
|
||||
|
||||
protected:
|
||||
std::string *m_val; ///< Pointer to variable to receive control's parsed value
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Validator for FQDN lists
|
||||
///
|
||||
class wxFQDNListValidator : public wxValidator
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wxFQDNListValidator);
|
||||
wxDECLARE_NO_ASSIGN_CLASS(wxFQDNListValidator);
|
||||
|
||||
public:
|
||||
///
|
||||
/// Construct the validator with a value to store data
|
||||
///
|
||||
wxFQDNListValidator(std::list<std::string> *val = NULL);
|
||||
|
||||
///
|
||||
/// Copy constructor
|
||||
///
|
||||
wxFQDNListValidator(const wxFQDNListValidator &other);
|
||||
|
||||
///
|
||||
/// Copies this validator
|
||||
///
|
||||
virtual wxObject* Clone() const;
|
||||
|
||||
///
|
||||
/// Validates the value
|
||||
///
|
||||
virtual bool Validate(wxWindow *parent);
|
||||
|
||||
///
|
||||
/// Transfers the value to the window
|
||||
///
|
||||
virtual bool TransferToWindow();
|
||||
|
||||
///
|
||||
/// Transfers the value from the window
|
||||
///
|
||||
virtual bool TransferFromWindow();
|
||||
|
||||
///
|
||||
/// Parses FQDN list value
|
||||
///
|
||||
static bool Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, std::list<std::string> *val_out = NULL);
|
||||
|
||||
protected:
|
||||
std::list<std::string> *m_val; ///< Pointer to variable to receive control's parsed value
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// EAPTLS credential panel
|
||||
///
|
||||
class wxEAPTLSCredentialsPanel : public wxCredentialsPanel<wxEAPTLSCredentialsPanelBase, eap::credentials_tls>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxEAPTLSCredentialsPanel(eap::credentials_tls &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false);
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
virtual void OnCertSelect(wxCommandEvent& event);
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// EAPTLS server trust configuration panel
|
||||
///
|
||||
class wxEAPTLSServerTrustPanel : public wxEAPTLSServerTrustConfigPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxEAPTLSServerTrustPanel(eap::config_tls &cfg, wxWindow* parent);
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
virtual void OnRootCA(wxCommandEvent& event);
|
||||
virtual void OnRootCADClick(wxCommandEvent& event);
|
||||
virtual void OnRootCAAddStore(wxCommandEvent& event);
|
||||
virtual void OnRootCAAddFile(wxCommandEvent& event);
|
||||
virtual void OnRootCARemove(wxCommandEvent& event);
|
||||
/// \endcond
|
||||
|
||||
///
|
||||
/// Adds a certificate to the list of trusted root CA list
|
||||
///
|
||||
/// \param[in] cert Certificate
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if certificate was added;
|
||||
/// - \c false if duplicate found or an error occured.
|
||||
///
|
||||
bool AddRootCA(PCCERT_CONTEXT cert);
|
||||
|
||||
protected:
|
||||
eap::config_tls &m_cfg; ///< TLS configuration
|
||||
winstd::library m_certmgr; ///< certmgr.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// EAPTLS configuration panel
|
||||
///
|
||||
class wxEAPTLSConfigPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration panel
|
||||
///
|
||||
wxEAPTLSConfigPanel(eap::config_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent);
|
||||
|
||||
///
|
||||
/// Destructs the configuration panel
|
||||
///
|
||||
virtual ~wxEAPTLSConfigPanel();
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event);
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
wxEAPTLSServerTrustPanel *m_server_trust; ///< Server trust configuration panel
|
||||
wxEAPTLSCredentialsConfigPanel *m_credentials; ///< Credentials configuration panel
|
||||
};
|
@@ -1,405 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "EAP.h"
|
||||
#include "EAPSerial.h"
|
||||
#include "TLS.h"
|
||||
#include "PAP.h"
|
||||
|
||||
#include <WinStd/Crypt.h>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class config_ttls;
|
||||
class credentials_ttls;
|
||||
class session_ttls;
|
||||
class peer_ttls;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_ttls &val);
|
||||
inline size_t get_pk_size(const eap::config_ttls &val);
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_ttls &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// TTLS configuration
|
||||
///
|
||||
class config_ttls : public config_tls
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs configuration
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
config_ttls(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
///
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
config_ttls(const _In_ config_ttls &other);
|
||||
|
||||
///
|
||||
/// Moves configuration
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
config_ttls(_Inout_ config_ttls &&other);
|
||||
|
||||
///
|
||||
/// Destructs configuration
|
||||
///
|
||||
virtual ~config_ttls();
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
///
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
config_ttls& operator=(const _In_ config_ttls &other);
|
||||
|
||||
///
|
||||
/// Moves configuration
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
config_ttls& operator=(_Inout_ config_ttls &&other);
|
||||
|
||||
///
|
||||
/// Clones configuration
|
||||
///
|
||||
/// \returns Pointer to cloned configuration
|
||||
///
|
||||
virtual config* clone() const { return new config_ttls(*this); }
|
||||
|
||||
/// \name XML configuration management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save configuration to XML document
|
||||
///
|
||||
/// \param[in] pDoc XML document
|
||||
/// \param[in] pConfigRoot Suggested root element for saving configuration
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Load configuration from XML document
|
||||
///
|
||||
/// \param[in] pConfigRoot Root element for loading configuration
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
///
|
||||
/// \returns `eap::type_ttls`
|
||||
///
|
||||
virtual eap::type_t get_method_id() { return eap::type_ttls; }
|
||||
|
||||
public:
|
||||
config_method *m_inner; ///< Inner authentication configuration
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TTLS credentials
|
||||
///
|
||||
class credentials_ttls : public credentials_tls
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs credentials
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
credentials_ttls(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
credentials_ttls(_In_ const credentials_ttls &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
credentials_ttls(_Inout_ credentials_ttls &&other);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_ttls& operator=(_In_ const credentials_ttls &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_ttls& operator=(_Inout_ credentials_ttls &&other);
|
||||
|
||||
///
|
||||
/// Clones credentials
|
||||
///
|
||||
/// \returns Pointer to cloned credentials
|
||||
///
|
||||
virtual config* clone() const { return new credentials_ttls(*this); }
|
||||
|
||||
///
|
||||
/// Resets credentials
|
||||
///
|
||||
virtual void clear();
|
||||
|
||||
///
|
||||
/// Test credentials if blank
|
||||
///
|
||||
virtual bool empty() const;
|
||||
|
||||
/// \name XML credentials management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Load credentials from XML document
|
||||
///
|
||||
/// \param[in] pConfigRoot Root element for loading credentials
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save credentials to Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Retrieve credentials from Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c ERROR_SUCCESS if succeeded
|
||||
/// - error code otherwise
|
||||
///
|
||||
virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
credentials *m_inner; ///< Inner credentials
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TTLS session
|
||||
///
|
||||
class session_ttls : public session
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
session_ttls();
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TTLS peer
|
||||
///
|
||||
class peer_ttls : public peer<eap::config_ttls, eap::credentials_ttls, int, int>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
peer_ttls();
|
||||
|
||||
///
|
||||
/// Initializes an EAP peer method for EAPHost.
|
||||
///
|
||||
/// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx)
|
||||
///
|
||||
virtual DWORD initialize(_Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
///
|
||||
/// Shuts down the EAP method and prepares to unload its corresponding DLL.
|
||||
///
|
||||
/// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx)
|
||||
///
|
||||
virtual DWORD shutdown(_Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
///
|
||||
/// Returns the user data and user identity after being called by EAPHost.
|
||||
///
|
||||
/// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx)
|
||||
///
|
||||
virtual DWORD get_identity(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwConnectionDataSize,
|
||||
_In_count_(dwConnectionDataSize) const BYTE *pConnectionData,
|
||||
_In_ DWORD dwUserDataSize,
|
||||
_In_count_(dwUserDataSize) const BYTE *pUserData,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_Out_ BOOL *pfInvokeUI,
|
||||
_Out_ DWORD *pdwUserDataOutSize,
|
||||
_Out_ BYTE **ppUserDataOut,
|
||||
_Out_ WCHAR **ppwszIdentity,
|
||||
_Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
///
|
||||
/// Defines the implementation of an EAP method-specific function that retrieves the properties of an EAP method given the connection and user data.
|
||||
///
|
||||
/// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx)
|
||||
///
|
||||
virtual DWORD get_method_properties(
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ HANDLE hUserImpersonationToken,
|
||||
_In_ DWORD dwEapConnDataSize,
|
||||
_In_count_(dwEapConnDataSize) const BYTE *pEapConnData,
|
||||
_In_ DWORD dwUserDataSize,
|
||||
_In_count_(dwUserDataSize) const BYTE *pUserData,
|
||||
_Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray,
|
||||
_Out_ EAP_ERROR **ppEapError) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a TTLS based method configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_ttls &val)
|
||||
{
|
||||
pack(cursor, (const eap::config_tls&)val);
|
||||
if (val.m_inner) {
|
||||
if (dynamic_cast<eap::config_pap*>(val.m_inner)) {
|
||||
pack(cursor, (unsigned char)eap::type_pap);
|
||||
pack(cursor, (const eap::config_pap&)*val.m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
pack(cursor, (unsigned char)0);
|
||||
}
|
||||
} else
|
||||
pack(cursor, (unsigned char)0);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a TTLS based method configuration
|
||||
///
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::config_ttls &val)
|
||||
{
|
||||
size_t size_inner = sizeof(unsigned char);
|
||||
if (val.m_inner) {
|
||||
if (dynamic_cast<eap::config_pap*>(val.m_inner))
|
||||
size_inner += get_pk_size((const eap::config_pap&)*val.m_inner);
|
||||
else
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
}
|
||||
|
||||
return
|
||||
get_pk_size((const eap::config_tls&)val) +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a TTLS based method configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_ttls &val)
|
||||
{
|
||||
unpack(cursor, (eap::config_tls&)val);
|
||||
|
||||
assert(!val.m_inner);
|
||||
unsigned char eap_type;
|
||||
unpack(cursor, eap_type);
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
val.m_inner = new eap::config_pap(val.m_module);
|
||||
unpack(cursor, (eap::config_pap&)*val.m_inner);
|
||||
break;
|
||||
case 0 : break;
|
||||
default : assert(0); // Unsupported inner authentication method type.
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: EAPMethods\n"
|
||||
"POT-Creation-Date: 2016-06-09 15:19+0200\n"
|
||||
"POT-Creation-Date: 2016-06-10 12:06+0200\n"
|
||||
"PO-Revision-Date: 2016-06-02 12:27+0200\n"
|
||||
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
|
||||
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
|
||||
@@ -10,295 +10,332 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.8\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-Basepath: ../..\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: en_US\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: _\n"
|
||||
"X-Poedit-SearchPath-0: res\n"
|
||||
"X-Poedit-SearchPath-1: MSIBuild\n"
|
||||
"X-Poedit-SearchPath-2: src\n"
|
||||
"X-Poedit-SearchPath-3: include\n"
|
||||
"X-Poedit-SearchPath-0: lib/EAPBase_UI\n"
|
||||
"X-Poedit-SearchPath-1: lib/PAP_UI\n"
|
||||
"X-Poedit-SearchPath-2: lib/TLS_UI\n"
|
||||
"X-Poedit-SearchPath-3: lib/TTLS_UI\n"
|
||||
"X-Poedit-SearchPath-4: EAPMethods\n"
|
||||
|
||||
#: res/wxEAP_UI.cpp:123 res/wxEAP_UI.cpp:200
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:123 lib/EAPBase_UI/res/wxEAP_UI.cpp:200
|
||||
msgid "Client Credentials"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:134
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:134
|
||||
msgid "Manage your credentials stored in Windows Credential Manager."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:144
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:144
|
||||
msgid "Identity:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:149
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:149
|
||||
msgid "Enter your user name here (user@domain.org, DOMAINUser, etc.)"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:159
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:159
|
||||
msgid "&Set Credentials..."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:160
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:160
|
||||
msgid "Click here to set or modify your credentials"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:164
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:164
|
||||
msgid "&Clear Credentials"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:165
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:165
|
||||
msgid ""
|
||||
"Click to clear your credentials from Credential Manager.\n"
|
||||
"Note: You will be prompted to enter credentials when connecting."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:211
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:211
|
||||
msgid "Please provide your user ID and password."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:221
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:221
|
||||
msgid "User ID:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:226
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:226
|
||||
msgid "Enter your user name here (user@domain.org, DOMAIN\\User, etc.)"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:230
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:230
|
||||
msgid "Password:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:235
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:235
|
||||
msgid "Enter your password here"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:242 res/wxTLS_UI.cpp:164
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:242 lib/TLS_UI/res/wxTLS_UI.cpp:164
|
||||
msgid "&Remember"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.cpp:243
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.cpp:243
|
||||
msgid "Check if you would like to save username and password"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:17
|
||||
msgid "Server Trust"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:28
|
||||
msgid "Describe the servers you trust to prevent credential interception in case of man-in-the-middle attacks."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:35
|
||||
msgid "Acceptable Certificate Authorities:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:40
|
||||
msgid "List of certificate authorities server's certificate must be issued by"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:47
|
||||
msgid "Add CA from Store..."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:48
|
||||
msgid "Adds a new certificate authority from the certificate store to the list"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:52
|
||||
msgid "Add CA from File..."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:53
|
||||
msgid "Adds a new certificate authority from the file to the list"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:57
|
||||
msgid "&Remove CA"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:59
|
||||
msgid "Removes selected certificate authorities from the list"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:72
|
||||
msgid "Acceptable server &names:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:77
|
||||
msgid "A semicolon delimited list of acceptable server FQDN names; blank to skip name check; \"*\" wildchar allowed"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:81
|
||||
msgid "(Example: foo.bar.com;*.domain.org)"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:120
|
||||
msgid "TLS Client Certificate"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:131
|
||||
msgid "Please select your client certificate to use for authentication."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:138
|
||||
msgid "Co&nnect without providing a client certificate"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:139
|
||||
msgid "Select if your server does not require you to provide a client certificate"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:146
|
||||
msgid "Use the following &certificate:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:147
|
||||
msgid "Select if you need to provide a client certificate when connecting"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:154
|
||||
msgid "Client certificate to use for authentication"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTLS_UI.cpp:165
|
||||
msgid "Check if you would like to save certificate selection"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:17
|
||||
msgid "Outer Identity"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:28
|
||||
msgid "Select the user ID supplicant introduces itself as to authenticator:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:35
|
||||
msgid "&Same as inner identity"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:36
|
||||
msgid "Use my true user name"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:40
|
||||
msgid "Use &empty outer identity (RFC 4822)"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:41
|
||||
msgid "Ommit my user name and use @mydomain.org only"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:48
|
||||
msgid "&Custom outer identity:"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:49
|
||||
msgid "Specify custom outer identity"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxTTLS_UI.cpp:54
|
||||
msgid "Custom outer identity to use"
|
||||
msgstr ""
|
||||
|
||||
#: src/PAP_UI.cpp:41
|
||||
#: lib/PAP_UI/src/PAP_UI.cpp:41
|
||||
msgid "This method requires no additional settings."
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:198
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:17
|
||||
msgid "Server Trust"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:28
|
||||
msgid "Describe the servers you trust to prevent credential interception in case of man-in-the-middle attacks."
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:35
|
||||
msgid "Acceptable Certificate Authorities:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:40
|
||||
msgid "List of certificate authorities server's certificate must be issued by"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:47
|
||||
msgid "Add CA from Store..."
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:48
|
||||
msgid "Adds a new certificate authority from the certificate store to the list"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:52
|
||||
msgid "Add CA from File..."
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:53
|
||||
msgid "Adds a new certificate authority from the file to the list"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:57
|
||||
msgid "&Remove CA"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:59
|
||||
msgid "Removes selected certificate authorities from the list"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:72
|
||||
msgid "Acceptable server &names:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:77
|
||||
msgid "A semicolon delimited list of acceptable server FQDN names; blank to skip name check; \"*\" wildchar allowed"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:81
|
||||
msgid "(Example: foo.bar.com;*.domain.org)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:120
|
||||
msgid "TLS Client Certificate"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:131
|
||||
msgid "Please select your client certificate to use for authentication."
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:138
|
||||
msgid "Co&nnect without providing a client certificate"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:139
|
||||
msgid "Select if your server does not require you to provide a client certificate"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:146
|
||||
msgid "Use the following &certificate:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:147
|
||||
msgid "Select if you need to provide a client certificate when connecting"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:154
|
||||
msgid "Client certificate to use for authentication"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/res/wxTLS_UI.cpp:165
|
||||
msgid "Check if you would like to save certificate selection"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:199
|
||||
#, c-format
|
||||
msgid "Invalid character in host name found: %c"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:198
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:199
|
||||
msgid "Validation conflict"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:550
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:551
|
||||
msgid "Add Certificate"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:551
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:552
|
||||
msgid "Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:552
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:553
|
||||
msgid "X.509 Certificate Files (*.cer;*.crt;*.der;*.pem)"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:553
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:554
|
||||
msgid "PKCS #7 Certificate Files (*.p7b)"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:554
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:555
|
||||
msgid "All Files (*.*)"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:570
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:571
|
||||
#, c-format
|
||||
msgid "Invalid or unsupported certificate file %s"
|
||||
msgstr ""
|
||||
|
||||
#: src/TLS_UI.cpp:570
|
||||
#: lib/TLS_UI/src/TLS_UI.cpp:571
|
||||
#, fuzzy
|
||||
msgid "Error"
|
||||
msgstr "Napaka pri nalaganju knjižnice MSI.DLL (%1!ld!)."
|
||||
|
||||
#: src/TTLS_UI.cpp:172
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:17
|
||||
msgid "Outer Identity"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:28
|
||||
msgid "Select the user ID supplicant introduces itself as to authenticator:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:35
|
||||
msgid "&Same as inner identity"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:36
|
||||
msgid "Use my true user name"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:40
|
||||
msgid "Use &empty outer identity (RFC 4822)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:41
|
||||
msgid "Ommit my user name and use @mydomain.org only"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:48
|
||||
msgid "&Custom outer identity:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:49
|
||||
msgid "Specify custom outer identity"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/res/wxTTLS_UI.cpp:54
|
||||
msgid "Custom outer identity to use"
|
||||
msgstr ""
|
||||
|
||||
#: lib/TTLS_UI/src/TTLS_UI.cpp:92
|
||||
msgid "Outer Authentication"
|
||||
msgstr ""
|
||||
|
||||
#: src/TTLS_UI.cpp:185
|
||||
#: lib/TTLS_UI/src/TTLS_UI.cpp:105
|
||||
msgid "Inner Authentication"
|
||||
msgstr ""
|
||||
|
||||
#: src/TTLS_UI.cpp:191
|
||||
#: lib/TTLS_UI/src/TTLS_UI.cpp:111
|
||||
msgid "Select inner authentication method from the list"
|
||||
msgstr ""
|
||||
|
||||
#: src/TTLS_UI.cpp:192
|
||||
#: lib/TTLS_UI/src/TTLS_UI.cpp:112
|
||||
msgid "PAP"
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:272
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:217
|
||||
msgid "<blank>"
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:278
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:223
|
||||
#, c-format
|
||||
msgid "<error %u>"
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:301
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:246
|
||||
#, c-format
|
||||
msgid "Deleting credentials failed (error %u)."
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:358
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:300
|
||||
#, c-format
|
||||
msgid "Error reading credentials from Credential Manager: %ls (error %u)"
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:361
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:303
|
||||
#, c-format
|
||||
msgid "Reading credentials failed (error %u)."
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:376
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:318
|
||||
#, c-format
|
||||
msgid "Error writing credentials to Credential Manager: %ls (error %u)"
|
||||
msgstr ""
|
||||
|
||||
#: include/EAP_UI.h:379
|
||||
#: lib/EAPBase_UI/include/EAP_UI.h:321
|
||||
#, c-format
|
||||
msgid "Writing credentials failed (error %u)."
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.h:56
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.h:56
|
||||
msgid "EAP Method Configuration"
|
||||
msgstr ""
|
||||
|
||||
#: res/wxEAP_UI.h:81
|
||||
#: lib/EAPBase_UI/res/wxEAP_UI.h:81
|
||||
msgid "EAP Credentials"
|
||||
msgstr ""
|
||||
|
||||
#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:3
|
||||
#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:3
|
||||
#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:3
|
||||
#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:3
|
||||
#, fuzzy
|
||||
msgid "1252"
|
||||
msgstr "1250"
|
||||
|
||||
#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:4
|
||||
#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:4
|
||||
#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:4
|
||||
#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:4
|
||||
msgid "EAP Peer Methods"
|
||||
msgstr ""
|
||||
|
||||
#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:4
|
||||
#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:4
|
||||
#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:4
|
||||
#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:4
|
||||
msgid "Modules to support individual EAP methods"
|
||||
msgstr ""
|
||||
|
||||
#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:5
|
||||
#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:5
|
||||
#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:5
|
||||
#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:5
|
||||
msgid "TTLS"
|
||||
msgstr ""
|
||||
|
||||
#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:5
|
||||
#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:5
|
||||
#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:5
|
||||
#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:5
|
||||
msgid "Tunneled Transport Layer Security"
|
||||
msgstr ""
|
||||
|
@@ -1,727 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::session
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::session::session()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::session::~session()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::begin(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ const EapAttributes *pAttributeArray,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_In_ DWORD dwConnectionDataSize,
|
||||
_In_count_(dwConnectionDataSize) const BYTE *pConnectionData,
|
||||
_In_ DWORD dwUserDataSize,
|
||||
_In_count_(dwUserDataSize) const BYTE *pUserData,
|
||||
_In_ DWORD dwMaxSendPacketSize,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(pAttributeArray);
|
||||
UNREFERENCED_PARAMETER(hTokenImpersonateUser);
|
||||
UNREFERENCED_PARAMETER(dwConnectionDataSize);
|
||||
UNREFERENCED_PARAMETER(pConnectionData);
|
||||
UNREFERENCED_PARAMETER(dwUserDataSize);
|
||||
UNREFERENCED_PARAMETER(pUserData);
|
||||
UNREFERENCED_PARAMETER(dwMaxSendPacketSize);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::end(_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::process_request_packet(
|
||||
_In_ DWORD dwReceivedPacketSize,
|
||||
_In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket,
|
||||
_Out_ EapPeerMethodOutput *pEapOutput,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwReceivedPacketSize);
|
||||
UNREFERENCED_PARAMETER(pReceivedPacket);
|
||||
UNREFERENCED_PARAMETER(pEapOutput);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::get_response_packet(
|
||||
_Inout_ DWORD *pdwSendPacketSize,
|
||||
_Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pdwSendPacketSize);
|
||||
UNREFERENCED_PARAMETER(pSendPacket);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::get_result(_In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(reason);
|
||||
UNREFERENCED_PARAMETER(ppResult);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::get_ui_context(
|
||||
_Out_ DWORD *pdwUIContextDataSize,
|
||||
_Out_ BYTE **ppUIContextData,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pdwUIContextDataSize);
|
||||
UNREFERENCED_PARAMETER(ppUIContextData);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::set_ui_context(
|
||||
_In_ DWORD dwUIContextDataSize,
|
||||
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
|
||||
_In_ const EapPeerMethodOutput *pEapOutput,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwUIContextDataSize);
|
||||
UNREFERENCED_PARAMETER(pUIContextData);
|
||||
UNREFERENCED_PARAMETER(pEapOutput);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::get_response_attributes(_Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pAttribs);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::session::set_response_attributes(const _In_ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pAttribs);
|
||||
UNREFERENCED_PARAMETER(pEapOutput);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::config
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config::config(_In_ module &mod) :
|
||||
m_module(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config::config(_In_ const config &other) :
|
||||
m_module(other.m_module)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config::config(_Inout_ config &&other) :
|
||||
m_module(other.m_module)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config::~config()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config& eap::config::operator=(_In_ const config &other)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(other);
|
||||
assert(&m_module == &other.m_module); // Copy configuration within same module only!
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config& eap::config::operator=(_Inout_ config &&other)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(other);
|
||||
assert(&m_module == &other.m_module); // Copy configuration within same module only!
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::config_method
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config_method::config_method(_In_ module &mod) :
|
||||
m_allow_save(true),
|
||||
config(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_method::config_method(_In_ const config_method &other) :
|
||||
m_allow_save(other.m_allow_save),
|
||||
m_anonymous_identity(other.m_anonymous_identity),
|
||||
config(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_method::config_method(_Inout_ config_method &&other) :
|
||||
m_allow_save(std::move(other.m_allow_save)),
|
||||
m_anonymous_identity(std::move(other.m_anonymous_identity)),
|
||||
config(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_method& eap::config_method::operator=(_In_ const config_method &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = other;
|
||||
m_allow_save = other.m_allow_save;
|
||||
m_anonymous_identity = other.m_anonymous_identity;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = std::move(other);
|
||||
m_allow_save = std::move(other.m_allow_save);
|
||||
m_anonymous_identity = std::move(other.m_anonymous_identity);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::config_method::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
|
||||
DWORD dwResult;
|
||||
|
||||
// <ClientSideCredential>
|
||||
com_obj<IXMLDOMElement> pXmlElClientSideCredential;
|
||||
if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ClientSideCredential"), bstr(L"ClientSideCredential"), bstrNamespace, &pXmlElClientSideCredential)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <ClientSideCredential> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// <ClientSideCredential>/<allow-save>
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"allow-save"), bstrNamespace, m_allow_save)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <allow-save> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// <ClientSideCredential>/<AnonymousIdentity>
|
||||
if (!m_anonymous_identity.empty())
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"AnonymousIdentity"), bstrNamespace, bstr(m_anonymous_identity))) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <AnonymousIdentity> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
m_allow_save = true;
|
||||
m_anonymous_identity.clear();
|
||||
|
||||
// <ClientSideCredential>
|
||||
com_obj<IXMLDOMElement> pXmlElClientSideCredential;
|
||||
if (eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:ClientSideCredential"), &pXmlElClientSideCredential) == ERROR_SUCCESS) {
|
||||
// <allow-save>
|
||||
eapxml::get_element_value(pXmlElClientSideCredential, bstr(L"eap-metadata:allow-save"), &m_allow_save);
|
||||
|
||||
// <AnonymousIdentity>
|
||||
eapxml::get_element_value(pXmlElClientSideCredential, bstr(L"eap-metadata:AnonymousIdentity"), m_anonymous_identity);
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials::credentials(_In_ module &mod) : config(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials::credentials(_In_ const credentials &other) :
|
||||
m_identity(other.m_identity),
|
||||
config(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials::credentials(_Inout_ credentials &&other) :
|
||||
m_identity(std::move(other.m_identity)),
|
||||
config(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials& eap::credentials::operator=(_In_ const credentials &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = other;
|
||||
m_identity = other.m_identity;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = std::move(other);
|
||||
m_identity = std::move(other.m_identity);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials::clear()
|
||||
{
|
||||
m_identity.clear();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials::empty() const
|
||||
{
|
||||
return m_identity.empty();
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pDoc);
|
||||
UNREFERENCED_PARAMETER(pConfigRoot);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
// Yeah, right!? Credentials are non-exportable!
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials_pass
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials_pass::credentials_pass(_In_ module &mod) : credentials(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass::credentials_pass(_In_ const credentials_pass &other) :
|
||||
m_password(other.m_password),
|
||||
credentials(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) :
|
||||
m_password(std::move(other.m_password)),
|
||||
credentials(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass& eap::credentials_pass::operator=(_In_ const credentials_pass &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = other;
|
||||
m_password = other.m_password;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = std::move(other);
|
||||
m_password = std::move(other.m_password);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_pass::clear()
|
||||
{
|
||||
credentials::clear();
|
||||
m_password.clear();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::empty() const
|
||||
{
|
||||
return credentials::empty() && m_password.empty();
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pConfigRoot);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:UserName"), m_identity);
|
||||
|
||||
bstr pass;
|
||||
if ((eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:Password"), &pass)) == ERROR_SUCCESS)
|
||||
m_password = pass;
|
||||
SecureZeroMemory((BSTR)pass, sizeof(OLECHAR)*pass.length());
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_pass::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
assert(pszTargetName);
|
||||
assert(ppEapError);
|
||||
DWORD dwResult;
|
||||
string password_enc;
|
||||
|
||||
// Prepare cryptographics provider.
|
||||
crypt_prov cp;
|
||||
if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptAcquireContext failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Import the public key.
|
||||
HRSRC res = FindResource(m_module.m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA);
|
||||
assert(res);
|
||||
HGLOBAL res_handle = LoadResource(m_module.m_instance, res);
|
||||
assert(res_handle);
|
||||
crypt_key key;
|
||||
unique_ptr<CERT_PUBLIC_KEY_INFO, LocalFree_delete<CERT_PUBLIC_KEY_INFO> > keyinfo_data;
|
||||
DWORD keyinfo_size = 0;
|
||||
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_module.m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
if (!key.import_public(cp, X509_ASN_ENCODING, keyinfo_data.get())) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Public key import failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Convert password to UTF-8.
|
||||
sanitizing_string password_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, m_password.c_str(), (int)m_password.length(), password_utf8, NULL, NULL);
|
||||
|
||||
// Pre-allocate memory to allow space, as encryption will grow the data, and we need additional 16B at the end for MD5 hash.
|
||||
DWORD dwBlockLen;
|
||||
vector<char, sanitizing_allocator<char> > password(password_utf8.length());
|
||||
memcpy(password.data(), password_utf8.c_str(), sizeof(char)*password_utf8.length());
|
||||
if (!CryptGetKeyParam(key, KP_BLOCKLEN, dwBlockLen, 0)) dwBlockLen = 0;
|
||||
password.reserve((password.size() + dwBlockLen - 1) / dwBlockLen * dwBlockLen + 16);
|
||||
|
||||
// Encrypt the password using our public key. Calculate MD5 hash and append it.
|
||||
crypt_hash hash;
|
||||
if (!hash.create(cp, CALG_MD5)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Creating MD5 hash failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
if (!CryptEncrypt(key, hash, TRUE, 0, password)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Encrypting password failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
vector<char> hash_bin;
|
||||
CryptGetHashParam(hash, HP_HASHVAL, hash_bin, 0);
|
||||
password.insert(password.end(), hash_bin.begin(), hash_bin.end());
|
||||
|
||||
// Convert encrypted password to Base64, since CredProtectA() fail for binary strings.
|
||||
string password_base64;
|
||||
base64_enc enc;
|
||||
enc.encode(password_base64, password.data(), password.size());
|
||||
|
||||
// Encrypt the password using user's key.
|
||||
CRED_PROTECTION_TYPE cpt;
|
||||
if (!CredProtectA(TRUE, password_base64.c_str(), (DWORD)password_base64.length(), password_enc, &cpt)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredProtect failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
tstring target(target_name(pszTargetName));
|
||||
|
||||
// Write credentials.
|
||||
assert(password_enc.size()*sizeof(char) < CRED_MAX_CREDENTIAL_BLOB_SIZE);
|
||||
assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH );
|
||||
CREDENTIAL cred = {
|
||||
0, // Flags
|
||||
CRED_TYPE_GENERIC, // Type
|
||||
(LPTSTR)target.c_str(), // TargetName
|
||||
_T(""), // Comment
|
||||
{ 0, 0 }, // LastWritten
|
||||
(DWORD)password_enc.size()*sizeof(char), // CredentialBlobSize
|
||||
(LPBYTE)password_enc.data(), // CredentialBlob
|
||||
CRED_PERSIST_ENTERPRISE, // Persist
|
||||
0, // AttributeCount
|
||||
NULL, // Attributes
|
||||
NULL, // TargetAlias
|
||||
(LPTSTR)m_identity.c_str() // UserName
|
||||
};
|
||||
if (!CredWrite(&cred, 0)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredWrite failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_pass::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pszTargetName);
|
||||
DWORD dwResult;
|
||||
|
||||
// Read credentials.
|
||||
unique_ptr<CREDENTIAL, CredFree_delete<CREDENTIAL> > cred;
|
||||
if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredRead failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
m_identity = cred->UserName;
|
||||
|
||||
// Decrypt the password using user's key.
|
||||
string password_base64;
|
||||
if (!CredUnprotectA(TRUE, (LPCSTR)(cred->CredentialBlob), cred->CredentialBlobSize/sizeof(char), password_base64)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredUnprotect failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Convert Base64 to binary encrypted password, since CredProtectA() fail for binary strings.
|
||||
vector<char, sanitizing_allocator<char> > password;
|
||||
base64_dec dec;
|
||||
bool is_last;
|
||||
dec.decode(password, is_last, password_base64.c_str(), password_base64.length());
|
||||
|
||||
// Prepare cryptographics provider.
|
||||
crypt_prov cp;
|
||||
if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptAcquireContext failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Create hash.
|
||||
crypt_hash hash;
|
||||
if (!hash.create(cp, CALG_MD5)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Creating MD5 hash failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
DWORD dwHashSize, dwHashSizeSize = sizeof(dwHashSize);
|
||||
CryptGetHashParam(hash, HP_HASHSIZE, (LPBYTE)&dwHashSize, &dwHashSizeSize, 0);
|
||||
if (password.size() < dwHashSize) {
|
||||
*ppEapError = m_module.make_error(dwResult = ERROR_INVALID_DATA, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Encrypted password too short."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Truncate hash from encrypted password.
|
||||
vector<char> hash_bin;
|
||||
size_t enc_size = password.size() - dwHashSize;
|
||||
hash_bin.assign(password.begin() + enc_size, password.end());
|
||||
password.resize(enc_size);
|
||||
|
||||
// Import the private key.
|
||||
HRSRC res = FindResource(m_module.m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PRIVATE), RT_RCDATA);
|
||||
assert(res);
|
||||
HGLOBAL res_handle = LoadResource(m_module.m_instance, res);
|
||||
assert(res_handle);
|
||||
crypt_key key;
|
||||
unique_ptr<unsigned char[], LocalFree_delete<unsigned char[]> > keyinfo_data;
|
||||
DWORD keyinfo_size = 0;
|
||||
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, PKCS_RSA_PRIVATE_KEY, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_module.m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
if (!key.import(cp, keyinfo_data.get(), keyinfo_size, NULL, 0)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Private key import failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Decrypt the password using our private key. Calculate MD5 hash and verify it.
|
||||
if (!CryptDecrypt(key, hash, TRUE, 0, password)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Decrypting password failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
vector<char> hash2_bin;
|
||||
CryptGetHashParam(hash, HP_HASHVAL, hash2_bin, 0);
|
||||
if (hash_bin != hash2_bin) {
|
||||
*ppEapError = m_module.make_error(dwResult = ERROR_INVALID_DATA, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Invalid password data."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Convert password from UTF-8.
|
||||
MultiByteToWideChar(CP_UTF8, 0, password.data(), (int)password.size(), m_password);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::module
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::module::module() :
|
||||
m_instance(NULL)
|
||||
{
|
||||
m_ep.create(&EAPMETHOD_TRACE_EVENT_PROVIDER);
|
||||
m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_LOAD, event_data((BYTE)EAPMETHOD_TYPE), event_data::blank);
|
||||
|
||||
m_heap.create(0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
eap::module::~module()
|
||||
{
|
||||
m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_UNLOAD, event_data((BYTE)EAPMETHOD_TYPE), event_data::blank);
|
||||
}
|
||||
|
||||
|
||||
EAP_ERROR* eap::module::make_error(_In_ DWORD dwErrorCode, _In_ DWORD dwReasonCode, _In_ LPCGUID pRootCauseGuid, _In_ LPCGUID pRepairGuid, _In_ LPCGUID pHelpLinkGuid, _In_z_ LPCWSTR pszRootCauseString, _In_z_ LPCWSTR pszRepairString) const
|
||||
{
|
||||
// Calculate memory size requirement.
|
||||
SIZE_T
|
||||
nRootCauseSize = pszRootCauseString != NULL && pszRootCauseString[0] ? (wcslen(pszRootCauseString) + 1)*sizeof(WCHAR) : 0,
|
||||
nRepairStringSize = pszRepairString != NULL && pszRepairString [0] ? (wcslen(pszRepairString ) + 1)*sizeof(WCHAR) : 0,
|
||||
nEapErrorSize = sizeof(EAP_ERROR) + nRootCauseSize + nRepairStringSize;
|
||||
|
||||
EAP_ERROR *pError = (EAP_ERROR*)HeapAlloc(m_heap, 0, nEapErrorSize);
|
||||
if (!pError)
|
||||
return NULL;
|
||||
BYTE *p = (BYTE*)(pError + 1);
|
||||
|
||||
// Fill the error descriptor.
|
||||
pError->dwWinError = dwErrorCode;
|
||||
pError->type.eapType.type = EAPMETHOD_TYPE;
|
||||
pError->type.eapType.dwVendorId = 0;
|
||||
pError->type.eapType.dwVendorType = 0;
|
||||
pError->type.dwAuthorId = 67532;
|
||||
pError->dwReasonCode = dwReasonCode;
|
||||
pError->rootCauseGuid = pRootCauseGuid != NULL ? *pRootCauseGuid : GUID_NULL;
|
||||
pError->repairGuid = pRepairGuid != NULL ? *pRepairGuid : GUID_NULL;
|
||||
pError->helpLinkGuid = pHelpLinkGuid != NULL ? *pHelpLinkGuid : GUID_NULL;
|
||||
if (nRootCauseSize) {
|
||||
pError->pRootCauseString = (LPWSTR)p;
|
||||
memcpy(pError->pRootCauseString, pszRootCauseString, nRootCauseSize);
|
||||
p += nRootCauseSize;
|
||||
} else
|
||||
pError->pRootCauseString = NULL;
|
||||
if (nRepairStringSize) {
|
||||
pError->pRepairString = (LPWSTR)p;
|
||||
memcpy(pError->pRepairString, pszRepairString, nRepairStringSize);
|
||||
p += nRepairStringSize;
|
||||
} else
|
||||
pError->pRepairString = NULL;
|
||||
|
||||
// Write trace event.
|
||||
vector<EVENT_DATA_DESCRIPTOR> evt_desc;
|
||||
evt_desc.reserve(8);
|
||||
evt_desc.push_back(event_data(pError->dwWinError));
|
||||
evt_desc.push_back(event_data(pError->type.eapType.type));
|
||||
evt_desc.push_back(event_data(pError->dwReasonCode));
|
||||
evt_desc.push_back(event_data(&(pError->rootCauseGuid), sizeof(GUID)));
|
||||
evt_desc.push_back(event_data(&(pError->repairGuid), sizeof(GUID)));
|
||||
evt_desc.push_back(event_data(&(pError->helpLinkGuid), sizeof(GUID)));
|
||||
evt_desc.push_back(event_data(pError->pRootCauseString));
|
||||
evt_desc.push_back(event_data(pError->pRepairString));
|
||||
m_ep.write(&EAPMETHOD_TRACE_EAP_ERROR, (ULONG)evt_desc.size(), evt_desc.data());
|
||||
|
||||
return pError;
|
||||
}
|
||||
|
||||
|
||||
BYTE* eap::module::alloc_memory(_In_ size_t size)
|
||||
{
|
||||
return (BYTE*)HeapAlloc(m_heap, 0, size);
|
||||
}
|
||||
|
||||
|
||||
void eap::module::free_memory(_In_ BYTE *ptr)
|
||||
{
|
||||
ETW_FN_VOID;
|
||||
|
||||
// Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing.
|
||||
SecureZeroMemory(ptr, HeapSize(m_heap, 0, ptr));
|
||||
HeapFree(m_heap, 0, ptr);
|
||||
}
|
||||
|
||||
|
||||
void eap::module::free_error_memory(_In_ EAP_ERROR *err)
|
||||
{
|
||||
ETW_FN_VOID;
|
||||
|
||||
// pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations.
|
||||
HeapFree(m_heap, 0, err);
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPCredentialsDialog
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPCredentialsDialog::wxEAPCredentialsDialog(wxWindow* parent) : wxEAPCredentialsDialogBase(parent)
|
||||
{
|
||||
// Set extra style here, as wxFormBuilder overrides all default flags.
|
||||
this->SetExtraStyle(this->GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
|
||||
|
||||
m_buttonsOK->SetDefault();
|
||||
}
|
||||
|
||||
|
||||
void wxEAPCredentialsDialog::AddContents(wxPanel **contents, size_t content_count)
|
||||
{
|
||||
if (content_count) {
|
||||
for (size_t i = 0; i < content_count; i++)
|
||||
m_panels->Add(contents[i], 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
this->Layout();
|
||||
this->GetSizer()->Fit(this);
|
||||
contents[0]->SetFocusFromKbd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxEAPCredentialsDialog::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
for (wxSizerItemList::compatibility_iterator panel = m_panels->GetChildren().GetFirst(); panel; panel = panel->GetNext())
|
||||
panel->GetData()->GetWindow()->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPBannerPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPBannerPanel::wxEAPBannerPanel(wxWindow* parent) : wxEAPBannerPanelBase(parent)
|
||||
{
|
||||
m_title->SetLabelText(wxT(PRODUCT_NAME_STR));
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxPasswordCredentialsPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const wxStringCharType *wxPasswordCredentialsPanel::s_dummy_password = wxT("dummypass");
|
||||
|
||||
|
||||
wxPasswordCredentialsPanel::wxPasswordCredentialsPanel(eap::credentials_pass &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
|
||||
wxCredentialsPanel<wxPasswordCredentialsPanelBase, eap::credentials_pass>(cred, pszCredTarget, parent, is_config)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(269));
|
||||
}
|
||||
|
||||
|
||||
bool wxPasswordCredentialsPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(__super::TransferDataToWindow(), false);
|
||||
|
||||
m_identity->SetValue(m_cred.m_identity);
|
||||
m_identity->SetSelection(0, -1);
|
||||
m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxPasswordCredentialsPanel::TransferDataFromWindow()
|
||||
{
|
||||
m_cred.m_identity = m_identity->GetValue();
|
||||
|
||||
wxString pass = m_password->GetValue();
|
||||
if (pass.compare(s_dummy_password) != 0) {
|
||||
m_cred.m_password = pass;
|
||||
pass.assign(pass.length(), wxT('*'));
|
||||
}
|
||||
|
||||
return __super::TransferDataFromWindow();
|
||||
}
|
@@ -20,6 +20,9 @@
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
#if EAPMETHOD_TYPE==21
|
||||
#define _EAPMETHOD_PEER eap::peer_ttls
|
||||
@@ -59,6 +62,8 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l
|
||||
///
|
||||
VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData)
|
||||
{
|
||||
event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__));
|
||||
|
||||
if (pUIContextData)
|
||||
g_peer.free_memory((BYTE*)pUIContextData);
|
||||
}
|
||||
@@ -71,6 +76,8 @@ VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData)
|
||||
///
|
||||
VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError)
|
||||
{
|
||||
event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__));
|
||||
|
||||
if (ppEapError)
|
||||
g_peer.free_error_memory(ppEapError);
|
||||
}
|
||||
@@ -84,19 +91,23 @@ VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError)
|
||||
DWORD WINAPI EapPeerGetInfo(_In_ EAP_TYPE* pEapType, _Out_ EAP_PEER_METHOD_ROUTINES* pEapPeerMethodRoutines, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pEapType)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pEapType)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL.")));
|
||||
else if (pEapType->type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (!pEapPeerMethodRoutines)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapPeerMethodRoutines is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapPeerMethodRoutines is NULL.")));
|
||||
else {
|
||||
pEapPeerMethodRoutines->dwVersion = PRODUCT_VERSION;
|
||||
pEapPeerMethodRoutines->pEapType = NULL;
|
||||
@@ -128,15 +139,24 @@ DWORD WINAPI EapPeerGetInfo(_In_ EAP_TYPE* pEapType, _Out_ EAP_PEER_METHOD_ROUTI
|
||||
DWORD APIENTRY EapPeerInitialize(_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else
|
||||
dwResult = g_peer.initialize(ppEapError);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!g_peer.initialize(ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -150,15 +170,24 @@ DWORD APIENTRY EapPeerInitialize(_Out_ EAP_ERROR **ppEapError)
|
||||
DWORD APIENTRY EapPeerShutdown(_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else
|
||||
dwResult = g_peer.shutdown(ppEapError);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!g_peer.shutdown(ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -183,38 +212,44 @@ DWORD APIENTRY EapPeerGetIdentity(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pConnectionData && dwConnectionDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConnectionData is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pConnectionData && dwConnectionDataSize)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL.")));
|
||||
else if (!pUserData && dwUserDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUserData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL.")));
|
||||
else if (!pfInvokeUI)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pfInvokeUI is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pfInvokeUI is NULL.")));
|
||||
else if (!pdwUserDataOutSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwUserDataOutSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUserDataOutSize is NULL.")));
|
||||
else if (!ppUserDataOut)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppUserDataOut is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUserDataOut is NULL.")));
|
||||
else if (!ppwszIdentity)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppwszIdentity is NULL."), NULL);
|
||||
else
|
||||
dwResult = g_peer.get_identity(
|
||||
dwFlags,
|
||||
dwConnectionDataSize,
|
||||
pConnectionData,
|
||||
dwUserDataSize,
|
||||
pUserData,
|
||||
hTokenImpersonateUser,
|
||||
pfInvokeUI,
|
||||
pdwUserDataOutSize,
|
||||
ppUserDataOut,
|
||||
ppwszIdentity,
|
||||
ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppwszIdentity is NULL.")));
|
||||
else {
|
||||
_EAPMETHOD_PEER::config_type cfg(g_peer);
|
||||
_EAPMETHOD_PEER::identity_type usr(g_peer);
|
||||
if (!g_peer.unpack(cfg, pConnectionData, dwConnectionDataSize, ppEapError) ||
|
||||
!g_peer.unpack(usr, pUserData, dwUserDataSize, ppEapError) ||
|
||||
!g_peer.get_identity(dwFlags, cfg, usr, hTokenImpersonateUser, pfInvokeUI, ppwszIdentity, ppEapError) ||
|
||||
!g_peer.pack(usr, ppUserDataOut, pdwUserDataOutSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -238,36 +273,46 @@ DWORD APIENTRY EapPeerBeginSession(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pConnectionData && dwConnectionDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConnectionData is NULL."), NULL);
|
||||
else if (!pUserData && dwUserDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUserData is NULL."), NULL);
|
||||
else if (!phSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" phSession is NULL."), NULL);
|
||||
else {
|
||||
// Allocate new session.
|
||||
eap::session *session = new _EAPMETHOD_SESSION();
|
||||
if (!session)
|
||||
return dwResult = ERROR_OUTOFMEMORY;
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
// Begin the session.
|
||||
dwResult = session->begin(dwFlags, pAttributeArray, hTokenImpersonateUser, dwConnectionDataSize, pConnectionData, dwUserDataSize, pUserData, dwMaxSendPacketSize, ppEapError);
|
||||
if (dwResult != ERROR_SUCCESS) {
|
||||
// Cleanup.
|
||||
delete session;
|
||||
*phSession = NULL;
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pConnectionData && dwConnectionDataSize)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL.")));
|
||||
else if (!pUserData && dwUserDataSize)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL.")));
|
||||
else if (!phSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" phSession is NULL.")));
|
||||
else {
|
||||
*phSession = NULL;
|
||||
|
||||
// Allocate new session.
|
||||
unique_ptr<_EAPMETHOD_SESSION> session(new _EAPMETHOD_SESSION(g_peer));
|
||||
if (!session) {
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, _T(" Error allocating memory for EAP session.")));
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
assert(phSession);
|
||||
*phSession = session;
|
||||
// Begin the session.
|
||||
if (!g_peer.unpack(session->m_cfg, pConnectionData, dwConnectionDataSize, ppEapError) ||
|
||||
!g_peer.unpack(session->m_id, pUserData, dwUserDataSize, ppEapError) ||
|
||||
!session->begin(dwFlags, pAttributeArray, hTokenImpersonateUser, dwMaxSendPacketSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
*phSession = session.release();
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
@@ -282,18 +327,22 @@ DWORD APIENTRY EapPeerBeginSession(
|
||||
DWORD APIENTRY EapPeerEndSession(_In_ EAP_SESSION_HANDLE hSession, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else {
|
||||
dwResult = static_cast<eap::session*>(hSession)->end(ppEapError);
|
||||
delete static_cast<eap::session*>(hSession);
|
||||
static_cast<_EAPMETHOD_SESSION*>(hSession)->end(ppEapError);
|
||||
delete static_cast<_EAPMETHOD_SESSION*>(hSession);
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
@@ -313,21 +362,32 @@ DWORD APIENTRY EapPeerProcessRequestPacket(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!pReceivedPacket && dwReceivedPacketSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pReceivedPacket is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pReceivedPacket is NULL.")));
|
||||
else if (!pEapOutput)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapOutput is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->process_request_packet(dwReceivedPacketSize, pReceivedPacket, pEapOutput, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL.")));
|
||||
else {
|
||||
if (!static_cast<_EAPMETHOD_SESSION*>(hSession)->process_request_packet(dwReceivedPacketSize, pReceivedPacket, pEapOutput, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -345,21 +405,32 @@ DWORD APIENTRY EapPeerGetResponsePacket(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!pdwSendPacketSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSendPacketSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwSendPacketSize is NULL.")));
|
||||
else if (!pSendPacket && *pdwSendPacketSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pSendPacket is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->get_response_packet(pdwSendPacketSize, pSendPacket, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pSendPacket is NULL.")));
|
||||
else {
|
||||
if (!static_cast<_EAPMETHOD_SESSION*>(hSession)->get_response_packet(pdwSendPacketSize, pSendPacket, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -373,19 +444,30 @@ DWORD APIENTRY EapPeerGetResponsePacket(
|
||||
DWORD APIENTRY EapPeerGetResult(_In_ EAP_SESSION_HANDLE hSession, _In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!ppResult)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppResult is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->get_result(reason, ppResult, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppResult is NULL.")));
|
||||
else {
|
||||
if (!static_cast<_EAPMETHOD_SESSION*>(hSession)->get_result(reason, ppResult, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -405,21 +487,35 @@ DWORD APIENTRY EapPeerGetUIContext(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!pdwUIContextDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwUIContextDataSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUIContextDataSize is NULL.")));
|
||||
else if (!ppUIContextData)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppUIContextData is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->get_ui_context(pdwUIContextDataSize, ppUIContextData, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUIContextData is NULL.")));
|
||||
else {
|
||||
_EAPMETHOD_SESSION::interactive_request_type req;
|
||||
if (!static_cast<_EAPMETHOD_SESSION*>(hSession)->get_ui_context(req, ppEapError) ||
|
||||
!g_peer.pack(req, ppUIContextData, pdwUIContextDataSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -440,21 +536,35 @@ DWORD APIENTRY EapPeerSetUIContext(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!pUIContextData && dwUIContextDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUIContextData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL.")));
|
||||
else if (!pEapOutput)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapOutput is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->set_ui_context(dwUIContextDataSize, pUIContextData, pEapOutput, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL.")));
|
||||
else {
|
||||
_EAPMETHOD_SESSION::interactive_response_type res;
|
||||
if (!g_peer.unpack(res, pUIContextData, dwUIContextDataSize, ppEapError) ||
|
||||
!static_cast<_EAPMETHOD_SESSION*>(hSession)->set_ui_context(res, pEapOutput, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -468,19 +578,30 @@ DWORD APIENTRY EapPeerSetUIContext(
|
||||
DWORD APIENTRY EapPeerGetResponseAttributes(_In_ EAP_SESSION_HANDLE hSession, _Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!pAttribs)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pAttribs is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->get_response_attributes(pAttribs, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pAttribs is NULL.")));
|
||||
else {
|
||||
if (!static_cast<_EAPMETHOD_SESSION*>(hSession)->get_response_attributes(pAttribs, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -494,19 +615,30 @@ DWORD APIENTRY EapPeerGetResponseAttributes(_In_ EAP_SESSION_HANDLE hSession, _O
|
||||
DWORD APIENTRY EapPeerSetResponseAttributes(_In_ EAP_SESSION_HANDLE hSession, _In_ /*const*/ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!hSession)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" hSession is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!hSession)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL.")));
|
||||
else if (!pEapOutput)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapOutput is NULL."), NULL);
|
||||
else
|
||||
dwResult = static_cast<eap::session*>(hSession)->set_response_attributes(pAttribs, pEapOutput, ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL.")));
|
||||
else {
|
||||
if (!static_cast<_EAPMETHOD_SESSION*>(hSession)->set_response_attributes(pAttribs, pEapOutput, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -530,34 +662,48 @@ DWORD WINAPI EapPeerGetMethodProperties(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (eapMethodType.dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pEapConnData && dwEapConnDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapConnData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConnData is NULL.")));
|
||||
else if (!pUserData && dwUserDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUserData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL.")));
|
||||
else if (!pMethodPropertyArray)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pMethodPropertyArray is NULL."), NULL);
|
||||
else
|
||||
dwResult = g_peer.get_method_properties(
|
||||
dwVersion,
|
||||
dwFlags,
|
||||
hUserImpersonationToken,
|
||||
dwEapConnDataSize,
|
||||
pEapConnData,
|
||||
dwUserDataSize,
|
||||
pUserData,
|
||||
pMethodPropertyArray,
|
||||
ppEapError);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pMethodPropertyArray is NULL.")));
|
||||
else {
|
||||
_EAPMETHOD_PEER::config_type cfg(g_peer);
|
||||
_EAPMETHOD_PEER::identity_type usr(g_peer);
|
||||
if (!g_peer.unpack(cfg, pEapConnData, dwEapConnDataSize, ppEapError) ||
|
||||
!g_peer.unpack(usr, pUserData, dwUserDataSize, ppEapError) ||
|
||||
!g_peer.get_method_properties(
|
||||
dwVersion,
|
||||
dwFlags,
|
||||
hUserImpersonationToken,
|
||||
cfg,
|
||||
usr,
|
||||
pMethodPropertyArray,
|
||||
ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -579,58 +725,53 @@ DWORD WINAPI EapPeerCredentialsXml2Blob(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (eapMethodType.dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pCredentialsDoc)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pCredentialsDoc is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pCredentialsDoc is NULL.")));
|
||||
else if (!pConfigIn && dwConfigInSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConfigIn is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConfigIn is NULL.")));
|
||||
else if (!ppCredentialsOut)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppCredentialsOut is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppCredentialsOut is NULL.")));
|
||||
else if (!pdwCredentialsOutSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwCredentialsOutSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwCredentialsOutSize is NULL.")));
|
||||
else {
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(pConfigIn);
|
||||
UNREFERENCED_PARAMETER(dwConfigInSize);
|
||||
|
||||
// <Credentials>
|
||||
winstd::com_obj<IXMLDOMNode> pXmlElCredentials;
|
||||
if ((dwResult = eapxml::select_node(pCredentialsDoc, winstd::bstr(L"//EapHostUserCredentials/Credentials"), &pXmlElCredentials)) != ERROR_SUCCESS) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting <EapHostUserCredentials><Credentials> element."), NULL);
|
||||
com_obj<IXMLDOMNode> pXmlElCredentials;
|
||||
if ((dwResult = eapxml::select_node(pCredentialsDoc, bstr(L"//EapHostUserCredentials/Credentials"), &pXmlElCredentials)) != ERROR_SUCCESS) {
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting <EapHostUserCredentials><Credentials> element."), _T("Please make sure credential XML is a valid ") _T(PRODUCT_NAME_STR) _T(" credential XML document.")));
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Load credentials.
|
||||
pCredentialsDoc->setProperty(winstd::bstr(L"SelectionNamespaces"), winstd::variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
|
||||
_EAPMETHOD_PEER::identity_type cred(g_peer);
|
||||
dwResult = cred.load(pXmlElCredentials, ppEapError);
|
||||
if (dwResult != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// Allocate BLOB for credentials.
|
||||
assert(ppCredentialsOut);
|
||||
assert(pdwCredentialsOutSize);
|
||||
*pdwCredentialsOutSize = (DWORD)eapserial::get_pk_size(cred);
|
||||
*ppCredentialsOut = g_peer.alloc_memory(*pdwCredentialsOutSize);
|
||||
if (!*ppCredentialsOut) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, 0, NULL, NULL, NULL, winstd::tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for configuration BLOB (%uB)."), *pdwCredentialsOutSize).c_str(), NULL);
|
||||
return dwResult;
|
||||
pCredentialsDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
|
||||
_EAPMETHOD_PEER::identity_type usr(g_peer);
|
||||
if (!usr.load(pXmlElCredentials, ppEapError) ||
|
||||
!g_peer.pack(usr, ppCredentialsOut, pdwCredentialsOutSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
// Pack BLOB to output.
|
||||
unsigned char *cursor = *ppCredentialsOut;
|
||||
eapserial::pack(cursor, cred);
|
||||
assert(cursor - *ppCredentialsOut <= (ptrdiff_t)*pdwCredentialsOutSize);
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
@@ -652,29 +793,41 @@ DWORD WINAPI EapPeerQueryCredentialInputFields(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (eapMethodType.dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pEapConnData && dwEapConnDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapConnData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConnData is NULL.")));
|
||||
else if (!pEapConfigInputFieldsArray)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapConfigInputFieldsArray is NULL."), NULL);
|
||||
else
|
||||
dwResult = g_peer.query_credential_input_fields(
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConfigInputFieldsArray is NULL.")));
|
||||
else {
|
||||
if (!g_peer.query_credential_input_fields(
|
||||
hUserImpersonationToken,
|
||||
dwFlags,
|
||||
dwEapConnDataSize,
|
||||
pEapConnData,
|
||||
pEapConfigInputFieldsArray,
|
||||
ppEapError);
|
||||
ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -697,27 +850,31 @@ DWORD WINAPI EapPeerQueryUserBlobFromCredentialInputFields(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (eapMethodType.dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pEapConnData && dwEapConnDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapConnData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConnData is NULL.")));
|
||||
else if (!pEapConfigInputFieldArray)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapConfigInputFieldArray is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConfigInputFieldArray is NULL.")));
|
||||
else if (!pdwUsersBlobSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwUsersBlobSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUsersBlobSize is NULL.")));
|
||||
else if (!ppUserBlob)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppUserBlob is NULL."), NULL);
|
||||
else
|
||||
dwResult = g_peer.query_user_blob_from_credential_input_fields(
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUserBlob is NULL.")));
|
||||
else {
|
||||
if (!g_peer.query_user_blob_from_credential_input_fields(
|
||||
hUserImpersonationToken,
|
||||
dwFlags,
|
||||
dwEapConnDataSize,
|
||||
@@ -725,7 +882,15 @@ DWORD WINAPI EapPeerQueryUserBlobFromCredentialInputFields(
|
||||
pEapConfigInputFieldArray,
|
||||
pdwUsersBlobSize,
|
||||
ppUserBlob,
|
||||
ppEapError);
|
||||
ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -746,28 +911,40 @@ DWORD WINAPI EapPeerQueryInteractiveUIInputFields(
|
||||
_Inout_ LPVOID *pvReserved)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pUIContextData && dwUIContextDataSize)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL.")));
|
||||
else if (!pUIContextData && dwUIContextDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUIContextData is NULL."), NULL);
|
||||
else if (!pUIContextData && dwUIContextDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUIContextData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL.")));
|
||||
else if (!pEapInteractiveUIData)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapInteractiveUIData is NULL."), NULL);
|
||||
else
|
||||
dwResult = g_peer.query_interactive_ui_input_fields(
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapInteractiveUIData is NULL.")));
|
||||
else {
|
||||
if (!g_peer.query_interactive_ui_input_fields(
|
||||
dwVersion,
|
||||
dwFlags,
|
||||
dwUIContextDataSize,
|
||||
pUIContextData,
|
||||
pEapInteractiveUIData,
|
||||
ppEapError,
|
||||
pvReserved);
|
||||
pvReserved))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
@@ -790,23 +967,27 @@ DWORD WINAPI EapPeerQueryUIBlobFromInteractiveUIInputFields(
|
||||
_Inout_ LPVOID *ppvReserved)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pUIContextData && dwUIContextDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapConfigInputFieldArray is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pUIContextData && dwUIContextDataSize)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConfigInputFieldArray is NULL.")));
|
||||
else if (!pEapInteractiveUIData)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapInteractiveUIData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapInteractiveUIData is NULL.")));
|
||||
else if (!pdwDataFromInteractiveUISize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwDataFromInteractiveUISize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwDataFromInteractiveUISize is NULL.")));
|
||||
else if (!ppDataFromInteractiveUI)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL."), NULL);
|
||||
else
|
||||
dwResult = g_peer.query_ui_blob_from_interactive_ui_input_fields(
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL.")));
|
||||
else {
|
||||
if (!g_peer.query_ui_blob_from_interactive_ui_input_fields(
|
||||
dwVersion,
|
||||
dwFlags,
|
||||
dwUIContextDataSize,
|
||||
@@ -815,7 +996,15 @@ DWORD WINAPI EapPeerQueryUIBlobFromInteractiveUIInputFields(
|
||||
pdwDataFromInteractiveUISize,
|
||||
ppDataFromInteractiveUI,
|
||||
ppEapError,
|
||||
ppvReserved);
|
||||
ppvReserved))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
}
|
||||
|
@@ -20,6 +20,11 @@
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
#pragma comment(lib, "msxml6.lib")
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
#if EAPMETHOD_TYPE==21
|
||||
#define _EAPMETHOD_PEER_UI eap::peer_ttls_ui
|
||||
@@ -68,6 +73,8 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l
|
||||
///
|
||||
VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData)
|
||||
{
|
||||
event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__));
|
||||
|
||||
if (pUIContextData)
|
||||
g_peer.free_memory((BYTE*)pUIContextData);
|
||||
}
|
||||
@@ -80,6 +87,8 @@ VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData)
|
||||
///
|
||||
VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError)
|
||||
{
|
||||
event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__));
|
||||
|
||||
if (ppEapError)
|
||||
g_peer.free_error_memory(ppEapError);
|
||||
}
|
||||
@@ -99,53 +108,50 @@ DWORD WINAPI EapPeerConfigXml2Blob(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (eapMethodType.dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pConfigDoc)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConfigDoc is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConfigDoc is NULL.")));
|
||||
else if (!ppConfigOut)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppConfigOut is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppConfigOut is NULL.")));
|
||||
else if (!pdwConfigOutSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwConfigOutSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwConfigOutSize is NULL.")));
|
||||
else {
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
|
||||
// <Config>
|
||||
pConfigDoc->setProperty(winstd::bstr(L"SelectionNamespaces"), winstd::variant(L"xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\""));
|
||||
winstd::com_obj<IXMLDOMElement> pXmlElConfig;
|
||||
if ((dwResult = eapxml::select_element(pConfigDoc, winstd::bstr(L"//eaphostconfig:Config"), &pXmlElConfig)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// Load configuration.
|
||||
pConfigDoc->setProperty(winstd::bstr(L"SelectionNamespaces"), winstd::variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
|
||||
_EAPMETHOD_PEER_UI::config_type cfg(g_peer);
|
||||
dwResult = cfg.load(pXmlElConfig, ppEapError);
|
||||
if (dwResult != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// Allocate BLOB for configuration.
|
||||
assert(ppConfigOut);
|
||||
assert(pdwConfigOutSize);
|
||||
*pdwConfigOutSize = (DWORD)eapserial::get_pk_size(cfg);
|
||||
*ppConfigOut = g_peer.alloc_memory(*pdwConfigOutSize);
|
||||
if (!*ppConfigOut) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, 0, NULL, NULL, NULL, winstd::tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for configuration BLOB (%uB)."), *pdwConfigOutSize).c_str(), NULL);
|
||||
pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\""));
|
||||
com_obj<IXMLDOMElement> pXmlElConfig;
|
||||
if ((dwResult = eapxml::select_element(pConfigDoc, bstr(L"//eaphostconfig:Config"), &pXmlElConfig)) != ERROR_SUCCESS) {
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult, _T(__FUNCTION__) _T(" Error reading <Config> element."), _T("Please make sure profile XML is a valid ") _T(PRODUCT_NAME_STR) _T(" profile XML document.")));
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Pack BLOB to output.
|
||||
unsigned char *cursor = *ppConfigOut;
|
||||
eapserial::pack(cursor, cfg);
|
||||
assert(cursor - *ppConfigOut <= (ptrdiff_t)*pdwConfigOutSize);
|
||||
// Load configuration.
|
||||
pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
|
||||
_EAPMETHOD_PEER_UI::config_type cfg(g_peer);
|
||||
if (!cfg.load(pXmlElConfig, ppEapError) ||
|
||||
!g_peer.pack(cfg, ppConfigOut, pdwConfigOutSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
@@ -168,37 +174,43 @@ DWORD WINAPI EapPeerConfigBlob2Xml(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (eapMethodType.eapType.type != EAPMETHOD_TYPE)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (eapMethodType.dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pConfigIn && dwConfigInSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConfigIn is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConfigIn is NULL.")));
|
||||
else if (!ppConfigDoc)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppConfigDoc is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppConfigDoc is NULL.")));
|
||||
else {
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
HRESULT hr;
|
||||
|
||||
// Unpack configuration.
|
||||
_EAPMETHOD_PEER_UI::config_type cfg(g_peer);
|
||||
if (pConfigIn || !dwConfigInSize) {
|
||||
const unsigned char *cursor = pConfigIn;
|
||||
eapserial::unpack(cursor, cfg);
|
||||
assert(cursor - pConfigIn <= (ptrdiff_t)dwConfigInSize);
|
||||
if (!g_peer.unpack(cfg, pConfigIn, dwConfigInSize, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
// Create configuration XML document.
|
||||
winstd::com_obj<IXMLDOMDocument2> pDoc;
|
||||
com_obj<IXMLDOMDocument2> pDoc;
|
||||
if (FAILED(hr = pDoc.create(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER))) {
|
||||
*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating XML document."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error creating XML document.")));
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
@@ -206,25 +218,32 @@ DWORD WINAPI EapPeerConfigBlob2Xml(
|
||||
|
||||
// Load empty XML configuration.
|
||||
VARIANT_BOOL isSuccess = VARIANT_FALSE;
|
||||
if (FAILED((hr = pDoc->loadXML(L"<Config xmlns=\"http://www.microsoft.com/provisioning/EapHostConfig\"><EAPIdentityProviderList xmlns=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"></EAPIdentityProviderList></Config>", &isSuccess))))
|
||||
return dwResult = HRESULT_CODE(hr);
|
||||
if (FAILED((hr = pDoc->loadXML(L"<Config xmlns=\"http://www.microsoft.com/provisioning/EapHostConfig\"><EAPIdentityProviderList xmlns=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"></EAPIdentityProviderList></Config>", &isSuccess)))) {
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error loading XML document template.")));
|
||||
return dwResult;
|
||||
}
|
||||
if (!isSuccess) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_XML_PARSE_ERROR, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Loading XML template failed."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_XML_PARSE_ERROR, _T(__FUNCTION__) _T(" Loading XML template failed.")));
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Select <Config> node.
|
||||
winstd::com_obj<IXMLDOMNode> pXmlElConfig;
|
||||
pDoc->setProperty(winstd::bstr(L"SelectionNamespaces"), winstd::variant(L"xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\""));
|
||||
if ((dwResult = eapxml::select_node(pDoc, winstd::bstr(L"eaphostconfig:Config"), &pXmlElConfig)) != ERROR_SUCCESS) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting <Config> element."), NULL);
|
||||
com_obj<IXMLDOMNode> pXmlElConfig;
|
||||
pDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\""));
|
||||
if ((dwResult = eapxml::select_node(pDoc, bstr(L"eaphostconfig:Config"), &pXmlElConfig)) != ERROR_SUCCESS) {
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting <Config> element."), _T("Please make sure profile XML is a valid ") _T(PRODUCT_NAME_STR) _T(" profile XML document.")));
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Save all providers.
|
||||
pDoc->setProperty(winstd::bstr(L"SelectionNamespaces"), winstd::variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
|
||||
if ((dwResult = cfg.save(pDoc, pXmlElConfig, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
pDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
|
||||
if (!cfg.save(pDoc, pXmlElConfig, ppEapError)) {
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
*ppConfigDoc = pDoc.detach();
|
||||
}
|
||||
@@ -250,52 +269,42 @@ DWORD WINAPI EapPeerInvokeConfigUI(
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
winstd::actctx_activator actctx(g_act_ctx);
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
actctx_activator actctx(g_act_ctx);
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pEapType)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pEapType)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL.")));
|
||||
else if (pEapType->eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (pEapType->dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pConnectionDataIn && dwConnectionDataInSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConnectionDataIn is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionDataIn is NULL.")));
|
||||
else if (!pdwConnectionDataOutSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwConnectionDataOutSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwConnectionDataOutSize is NULL.")));
|
||||
else if (!ppConnectionDataOut)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppConnectionDataOut is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppConnectionDataOut is NULL.")));
|
||||
else {
|
||||
// Unpack configuration.
|
||||
_EAPMETHOD_PEER_UI::config_type cfg(g_peer);
|
||||
if (pConnectionDataIn || !dwConnectionDataInSize) {
|
||||
const unsigned char *cursor = pConnectionDataIn;
|
||||
eapserial::unpack(cursor, cfg);
|
||||
assert(cursor - pConnectionDataIn <= (ptrdiff_t)dwConnectionDataInSize);
|
||||
if (!g_peer.unpack(cfg, pConnectionDataIn, dwConnectionDataInSize, ppEapError) ||
|
||||
!g_peer.invoke_config_ui(hwndParent, cfg, ppEapError) ||
|
||||
!g_peer.pack(cfg, ppConnectionDataOut, pdwConnectionDataOutSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if ((dwResult = g_peer.invoke_config_ui(hwndParent, cfg, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// Allocate BLOB for configuration.
|
||||
assert(ppConnectionDataOut);
|
||||
assert(pdwConnectionDataOutSize);
|
||||
*pdwConnectionDataOutSize = (DWORD)eapserial::get_pk_size(cfg);
|
||||
*ppConnectionDataOut = g_peer.alloc_memory(*pdwConnectionDataOutSize);
|
||||
if (!*ppConnectionDataOut) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, 0, NULL, NULL, NULL, winstd::tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for configuration BLOB (%uB)."), *pdwConnectionDataOutSize).c_str(), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Pack BLOB to output.
|
||||
unsigned char *cursor = *ppConnectionDataOut;
|
||||
eapserial::pack(cursor, cfg);
|
||||
assert(cursor - *ppConnectionDataOut <= (ptrdiff_t)*pdwConnectionDataOutSize);
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
@@ -321,7 +330,8 @@ DWORD WINAPI EapPeerInvokeIdentityUI(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
winstd::actctx_activator actctx(g_act_ctx);
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
actctx_activator actctx(g_act_ctx);
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
@@ -329,56 +339,39 @@ DWORD WINAPI EapPeerInvokeIdentityUI(
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pEapType)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pEapType)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL.")));
|
||||
else if (pEapType->eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (pEapType->dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pConnectionData && dwConnectionDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pConnectionData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL.")));
|
||||
else if (!pUserData && dwUserDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUserData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL.")));
|
||||
else if (!pdwUserDataOutSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwUserDataOutSize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUserDataOutSize is NULL.")));
|
||||
else if (!ppUserDataOut)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppUserDataOut is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUserDataOut is NULL.")));
|
||||
else if (!ppwszIdentity)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppwszIdentity is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppwszIdentity is NULL.")));
|
||||
else {
|
||||
// Unpack configuration.
|
||||
_EAPMETHOD_PEER_UI::config_type cfg(g_peer);
|
||||
if (pConnectionData || !dwConnectionDataSize) {
|
||||
const unsigned char *cursor = pConnectionData;
|
||||
eapserial::unpack(cursor, cfg);
|
||||
assert(cursor - pConnectionData <= (ptrdiff_t)dwConnectionDataSize);
|
||||
}
|
||||
|
||||
// Unpack configuration.
|
||||
_EAPMETHOD_PEER_UI::identity_type usr(g_peer);
|
||||
if (pUserData || !dwUserDataSize) {
|
||||
const unsigned char *cursor = pUserData;
|
||||
eapserial::unpack(cursor, usr);
|
||||
assert(cursor - pUserData <= (ptrdiff_t)dwUserDataSize);
|
||||
if (!g_peer.unpack(cfg, pConnectionData, dwConnectionDataSize, ppEapError) ||
|
||||
!g_peer.unpack(usr, pUserData, dwUserDataSize, ppEapError) ||
|
||||
!g_peer.invoke_identity_ui(hwndParent, dwFlags, cfg, usr, ppwszIdentity, ppEapError) ||
|
||||
!g_peer.pack(usr, ppUserDataOut, pdwUserDataOutSize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if ((dwResult = g_peer.invoke_identity_ui(hwndParent, dwFlags, cfg, usr, ppwszIdentity, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// Allocate BLOB for user data.
|
||||
assert(ppUserDataOut);
|
||||
assert(pdwUserDataOutSize);
|
||||
*pdwUserDataOutSize = (DWORD)eapserial::get_pk_size(usr);
|
||||
*ppUserDataOut = g_peer.alloc_memory(*pdwUserDataOutSize);
|
||||
if (!*ppUserDataOut) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, 0, NULL, NULL, NULL, winstd::tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for configuration BLOB (%uB)."), *pdwUserDataOutSize).c_str(), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Pack BLOB to output.
|
||||
unsigned char *cursor = *ppUserDataOut;
|
||||
eapserial::pack(cursor, usr);
|
||||
assert(cursor - *ppUserDataOut <= (ptrdiff_t)*pdwUserDataOutSize);
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
@@ -400,53 +393,43 @@ DWORD WINAPI EapPeerInvokeInteractiveUI(
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult = ERROR_SUCCESS;
|
||||
winstd::actctx_activator actctx(g_act_ctx);
|
||||
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
|
||||
actctx_activator actctx(g_act_ctx);
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
#endif
|
||||
|
||||
// Parameter check
|
||||
if (!ppEapError)
|
||||
dwResult = ERROR_INVALID_PARAMETER;
|
||||
else if (!pEapType)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
|
||||
return dwResult = ERROR_INVALID_PARAMETER;
|
||||
|
||||
assert(!*ppEapError);
|
||||
|
||||
if (!pEapType)
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL.")));
|
||||
else if (pEapType->eapType.type != EAPMETHOD_TYPE)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str()));
|
||||
else if (pEapType->dwAuthorId != 67532)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str()));
|
||||
else if (!pUIContextData && dwUIContextDataSize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pUIContextData is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL.")));
|
||||
else if (!pdwDataFromInteractiveUISize)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwDataFromInteractiveUISize is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwDataFromInteractiveUISize is NULL.")));
|
||||
else if (!ppDataFromInteractiveUI)
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL."), NULL);
|
||||
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL.")));
|
||||
else {
|
||||
// Unpack request.
|
||||
_EAPMETHOD_PEER_UI::interactive_request_type req;
|
||||
if (pUIContextData || !dwUIContextDataSize) {
|
||||
const unsigned char *cursor = pUIContextData;
|
||||
eapserial::unpack(cursor, req);
|
||||
assert(cursor - pUIContextData <= (ptrdiff_t)dwUIContextDataSize);
|
||||
}
|
||||
|
||||
_EAPMETHOD_PEER_UI::interactive_response_type res;
|
||||
if ((dwResult = g_peer.invoke_interactive_ui(hwndParent, req, res, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// Allocate BLOB for user data.
|
||||
assert(ppDataFromInteractiveUI);
|
||||
assert(pdwDataFromInteractiveUISize);
|
||||
*pdwDataFromInteractiveUISize = (DWORD)eapserial::get_pk_size(res);
|
||||
*ppDataFromInteractiveUI = g_peer.alloc_memory(*pdwDataFromInteractiveUISize);
|
||||
if (!*ppDataFromInteractiveUI) {
|
||||
*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, 0, NULL, NULL, NULL, winstd::tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for interactive response (%uB)."), *pdwDataFromInteractiveUISize).c_str(), NULL);
|
||||
return dwResult;
|
||||
if (!g_peer.unpack(req, pUIContextData, dwUIContextDataSize, ppEapError) ||
|
||||
!g_peer.invoke_interactive_ui(hwndParent, req, res, ppEapError) ||
|
||||
!g_peer.pack(res, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize, ppEapError))
|
||||
{
|
||||
if (*ppEapError) {
|
||||
g_peer.log_error(*ppEapError);
|
||||
return dwResult = (*ppEapError)->dwWinError;
|
||||
} else
|
||||
return dwResult = ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
// Pack BLOB to output.
|
||||
unsigned char *cursor = *ppDataFromInteractiveUI;
|
||||
eapserial::pack(cursor, res);
|
||||
assert(cursor - *ppDataFromInteractiveUI <= (ptrdiff_t)*pdwDataFromInteractiveUISize);
|
||||
}
|
||||
|
||||
return dwResult;
|
||||
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxPAPConfigPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxPAPConfigPanel::wxPAPConfigPanel(eap::config_pap &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
if (cfg.m_allow_save) {
|
||||
m_credentials = new wxPAPCredentialsConfigPanel(cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_credentials, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_label = NULL;
|
||||
} else {
|
||||
m_credentials = NULL;
|
||||
|
||||
m_label = new wxStaticText(this, wxID_ANY, _("This method requires no additional settings."), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_label->Wrap(-1);
|
||||
sb_content->Add(m_label, 0, wxALL|wxEXPAND, 5);
|
||||
}
|
||||
|
||||
sb_content->Add(10, 10, 1, wxEXPAND, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxPAPConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxPAPConfigPanel::~wxPAPConfigPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxPAPConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
void wxPAPConfigPanel::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
if (m_credentials)
|
||||
m_credentials->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
@@ -1,329 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::config_tls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config_tls::config_tls(_In_ module &mod) : config_method(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_tls::config_tls(_In_ const config_tls &other) :
|
||||
m_trusted_root_ca(other.m_trusted_root_ca),
|
||||
m_server_names(other.m_server_names),
|
||||
config_method(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_tls::config_tls(_Inout_ config_tls &&other) :
|
||||
m_trusted_root_ca(std::move(other.m_trusted_root_ca)),
|
||||
m_server_names(std::move(other.m_server_names)),
|
||||
config_method(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_tls& eap::config_tls::operator=(_In_ const eap::config_tls &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&)*this = other;
|
||||
m_trusted_root_ca = other.m_trusted_root_ca;
|
||||
m_server_names = other.m_server_names;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config_tls& eap::config_tls::operator=(_Inout_ eap::config_tls &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&&)*this = std::move(other);
|
||||
m_trusted_root_ca = std::move(other.m_trusted_root_ca);
|
||||
m_server_names = std::move(other.m_server_names);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::config_tls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
|
||||
DWORD dwResult;
|
||||
HRESULT hr;
|
||||
|
||||
// <ServerSideCredential>
|
||||
com_obj<IXMLDOMElement> pXmlElServerSideCredential;
|
||||
if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ServerSideCredential"), bstr(L"ServerSideCredential"), bstrNamespace, &pXmlElServerSideCredential)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <ServerSideCredential> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
for (list<cert_context>::const_iterator i = m_trusted_root_ca.begin(), i_end = m_trusted_root_ca.end(); i != i_end; ++i) {
|
||||
// <CA>
|
||||
com_obj<IXMLDOMElement> pXmlElCA;
|
||||
if ((dwResult = eapxml::create_element(pDoc, bstr(L"CA"), bstrNamespace, &pXmlElCA))) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <CA> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// <CA>/<format>
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElCA, bstr(L"format"), bstrNamespace, bstr(L"PEM"))) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <format> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// <CA>/<cert-data>
|
||||
const cert_context &cc = *i;
|
||||
if ((dwResult = eapxml::put_element_base64(pDoc, pXmlElCA, bstr(L"cert-data"), bstrNamespace, cc->pbCertEncoded, cc->cbCertEncoded)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <cert-data> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
if (FAILED(hr = pXmlElServerSideCredential->appendChild(pXmlElCA, NULL))) {
|
||||
*ppEapError = m_module.make_error(dwResult = HRESULT_CODE(hr), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error appending <CA> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
}
|
||||
|
||||
// <ServerName>
|
||||
for (list<string>::const_iterator i = m_server_names.begin(), i_end = m_server_names.end(); i != i_end; ++i) {
|
||||
wstring str;
|
||||
MultiByteToWideChar(CP_UTF8, 0, i->c_str(), (int)i->length(), str);
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElServerSideCredential, bstr(L"ServerName"), bstrNamespace, bstr(str))) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <ServerName> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
}
|
||||
|
||||
return config_method::save(pDoc, pConfigRoot, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::config_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
m_trusted_root_ca.clear();
|
||||
m_server_names.clear();
|
||||
|
||||
// <ServerSideCredential>
|
||||
com_obj<IXMLDOMElement> pXmlElServerSideCredential;
|
||||
if (eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:ServerSideCredential"), &pXmlElServerSideCredential) == ERROR_SUCCESS) {
|
||||
// <CA>
|
||||
com_obj<IXMLDOMNodeList> pXmlListCAs;
|
||||
long lCACount = 0;
|
||||
if (eapxml::select_nodes(pXmlElServerSideCredential, bstr(L"eap-metadata:CA"), &pXmlListCAs) == ERROR_SUCCESS && SUCCEEDED(pXmlListCAs->get_length(&lCACount))) {
|
||||
for (long j = 0; j < lCACount; j++) {
|
||||
// Load CA certificate.
|
||||
com_obj<IXMLDOMNode> pXmlElCA;
|
||||
pXmlListCAs->get_item(j, &pXmlElCA);
|
||||
bstr bstrFormat;
|
||||
if (eapxml::get_element_value(pXmlElCA, bstr(L"eap-metadata:format"), &bstrFormat) == ERROR_SUCCESS) {
|
||||
if (CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstrFormat, bstrFormat.length(), L"PEM", -1, NULL, NULL, 0) == CSTR_EQUAL) {
|
||||
vector<unsigned char> aData;
|
||||
if (eapxml::get_element_base64(pXmlElCA, bstr(L"eap-metadata:cert-data"), aData) == ERROR_SUCCESS)
|
||||
add_trusted_ca(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, aData.data(), (DWORD)aData.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <ServerName>
|
||||
com_obj<IXMLDOMNodeList> pXmlListServerIDs;
|
||||
long lServerIDCount = 0;
|
||||
if (eapxml::select_nodes(pXmlElServerSideCredential, bstr(L"eap-metadata:ServerName"), &pXmlListServerIDs) == ERROR_SUCCESS && SUCCEEDED(pXmlListServerIDs->get_length(&lServerIDCount))) {
|
||||
for (long j = 0; j < lServerIDCount; j++) {
|
||||
// Load server name (<ServerName>).
|
||||
com_obj<IXMLDOMNode> pXmlElServerID;
|
||||
pXmlListServerIDs->get_item(j, &pXmlElServerID);
|
||||
bstr bstrServerID;
|
||||
pXmlElServerID->get_text(&bstrServerID);
|
||||
|
||||
// Server names (FQDNs) are always ASCII. Hopefully. Convert them to UTF-8 anyway for consistent comparison. CP_ANSI varies.
|
||||
string str;
|
||||
WideCharToMultiByte(CP_UTF8, 0, bstrServerID, bstrServerID.length(), str, NULL, NULL);
|
||||
|
||||
m_server_names.push_back(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config_method::load(pConfigRoot, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
bool eap::config_tls::add_trusted_ca(_In_ DWORD dwCertEncodingType, _In_ const BYTE *pbCertEncoded, _In_ DWORD cbCertEncoded)
|
||||
{
|
||||
cert_context cert;
|
||||
if (!cert.create(dwCertEncodingType, pbCertEncoded, cbCertEncoded)) {
|
||||
// Invalid or unsupported certificate.
|
||||
return false;
|
||||
}
|
||||
|
||||
for (list<cert_context>::const_iterator i = m_trusted_root_ca.cbegin(), i_end = m_trusted_root_ca.cend();; ++i) {
|
||||
if (i != i_end) {
|
||||
if (*i == cert) {
|
||||
// This certificate is already on the list.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// End of list reached. Append certificate.
|
||||
m_trusted_root_ca.push_back(std::move(cert));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials_tls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials_tls::credentials_tls(_In_ module &mod) : credentials(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_tls::credentials_tls(_In_ const credentials_tls &other) :
|
||||
m_cert_hash(other.m_cert_hash),
|
||||
credentials(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_tls::credentials_tls(_Inout_ credentials_tls &&other) :
|
||||
m_cert_hash(std::move(m_cert_hash)),
|
||||
credentials(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_tls& eap::credentials_tls::operator=(_In_ const credentials_tls &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = other;
|
||||
m_cert_hash = other.m_cert_hash;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_tls& eap::credentials_tls::operator=(_Inout_ credentials_tls &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = std::move(other);
|
||||
m_cert_hash = std::move(other.m_cert_hash);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void eap::credentials_tls::clear()
|
||||
{
|
||||
credentials::clear();
|
||||
m_cert_hash.clear();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_tls::empty() const
|
||||
{
|
||||
return credentials::empty() && m_cert_hash.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DWORD eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pConfigRoot);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
eapxml::get_element_hex(pConfigRoot, bstr(L"CertHash"), m_cert_hash);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_tls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
assert(pszTargetName);
|
||||
assert(ppEapError);
|
||||
DWORD dwResult;
|
||||
|
||||
tstring target(target_name(pszTargetName));
|
||||
|
||||
// Write credentials.
|
||||
assert(m_cert_hash.size()*sizeof(char) < CRED_MAX_CREDENTIAL_BLOB_SIZE);
|
||||
assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH );
|
||||
CREDENTIAL cred = {
|
||||
0, // Flags
|
||||
CRED_TYPE_GENERIC, // Type
|
||||
(LPTSTR)target.c_str(), // TargetName
|
||||
_T(""), // Comment
|
||||
{ 0, 0 }, // LastWritten
|
||||
(DWORD)m_cert_hash.size()*sizeof(char), // CredentialBlobSize
|
||||
(LPBYTE)m_cert_hash.data(), // CredentialBlob
|
||||
CRED_PERSIST_ENTERPRISE, // Persist
|
||||
0, // AttributeCount
|
||||
NULL, // Attributes
|
||||
NULL, // TargetAlias
|
||||
(LPTSTR)m_identity.c_str() // UserName
|
||||
};
|
||||
if (!CredWrite(&cred, 0)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredWrite failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_tls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pszTargetName && _tcslen(pszTargetName) < CRED_MAX_GENERIC_TARGET_NAME_LENGTH);
|
||||
DWORD dwResult;
|
||||
|
||||
// Read credentials.
|
||||
unique_ptr<CREDENTIAL, CredFree_delete<CREDENTIAL> > cred;
|
||||
if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
*ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredRead failed."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
if (cred->UserName)
|
||||
m_identity = cred->UserName;
|
||||
else
|
||||
m_identity.clear();
|
||||
|
||||
m_cert_hash.assign(cred->CredentialBlob, cred->CredentialBlob + cred->CredentialBlobSize);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
@@ -1,658 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
#pragma comment(lib, "Cryptui.lib")
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::get_cert_title
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void eap::get_cert_title(PCCERT_CONTEXT cert, winstd::tstring &title)
|
||||
{
|
||||
winstd::tstring name, str, issuer;
|
||||
FILETIME ft;
|
||||
SYSTEMTIME st;
|
||||
|
||||
title.clear();
|
||||
|
||||
// Prepare certificate information
|
||||
CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name);
|
||||
title += name;
|
||||
|
||||
FileTimeToLocalFileTime(&(cert->pCertInfo->NotBefore), &ft);
|
||||
FileTimeToSystemTime(&ft, &st);
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, str);
|
||||
title += _T(", ");
|
||||
title += str;
|
||||
|
||||
FileTimeToLocalFileTime(&(cert->pCertInfo->NotAfter ), &ft);
|
||||
FileTimeToSystemTime(&ft, &st);
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, str);
|
||||
title += _T('-');
|
||||
title += str;
|
||||
|
||||
CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, issuer);
|
||||
if (name != issuer) {
|
||||
title += _T(", ");
|
||||
title += issuer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxCertificateClientData
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxCertificateClientData::wxCertificateClientData(PCCERT_CONTEXT cert) : m_cert(cert)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxCertificateClientData::~wxCertificateClientData()
|
||||
{
|
||||
if (m_cert)
|
||||
CertFreeCertificateContext(m_cert);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxCertificateSelectionClientData
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxCertificateSelectionClientData::wxCertificateSelectionClientData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxCertificateSelectionClientData::wxCertificateSelectionClientData(const wchar_t *identity, unsigned char *hash, size_t hash_size) :
|
||||
m_identity(identity),
|
||||
m_hash(hash, hash + hash_size)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxCertificateSelectionClientData::wxCertificateSelectionClientData(const std::wstring &identity, const std::vector<unsigned char> &hash) :
|
||||
m_identity(identity),
|
||||
m_hash(hash)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxCertificateSelectionClientData::wxCertificateSelectionClientData(std::wstring &&identity, std::vector<unsigned char> &&hash) :
|
||||
m_identity(std::move(identity)),
|
||||
m_hash(std::move(hash))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxCertificateSelectionClientData::wxCertificateSelectionClientData(const wxCertificateSelectionClientData &other) :
|
||||
m_identity(other.m_identity),
|
||||
m_hash(other.m_hash)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxCertificateSelectionClientData::wxCertificateSelectionClientData(wxCertificateSelectionClientData &&other) :
|
||||
m_identity(std::move(other.m_identity)),
|
||||
m_hash(std::move(other.m_hash))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxHostNameValidator
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxHostNameValidator, wxValidator);
|
||||
|
||||
|
||||
wxHostNameValidator::wxHostNameValidator(std::string *val) :
|
||||
m_val(val),
|
||||
wxValidator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxHostNameValidator::wxHostNameValidator(const wxHostNameValidator &other) :
|
||||
m_val(other.m_val),
|
||||
wxValidator(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxObject* wxHostNameValidator::Clone() const
|
||||
{
|
||||
return new wxHostNameValidator(*this);
|
||||
}
|
||||
|
||||
|
||||
bool wxHostNameValidator::Validate(wxWindow *parent)
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
|
||||
if (!ctrl->IsEnabled()) return true;
|
||||
|
||||
wxString val(ctrl->GetValue());
|
||||
return Parse(val, 0, val.Length(), ctrl, parent);
|
||||
}
|
||||
|
||||
|
||||
bool wxHostNameValidator::TransferToWindow()
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
|
||||
if (m_val)
|
||||
((wxTextCtrl*)GetWindow())->SetValue(*m_val);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxHostNameValidator::TransferFromWindow()
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
|
||||
|
||||
wxString val(ctrl->GetValue());
|
||||
return Parse(val, 0, val.Length(), ctrl, NULL, m_val);
|
||||
}
|
||||
|
||||
|
||||
bool wxHostNameValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, std::string *val_out)
|
||||
{
|
||||
const wxStringCharType *buf = val_in;
|
||||
|
||||
size_t i = i_start;
|
||||
for (;;) {
|
||||
if (i >= i_end) {
|
||||
// End of host name found.
|
||||
if (val_out) val_out->assign(val_in.c_str() + i_start, i - i_start);
|
||||
return true;
|
||||
} else if (_tcschr(wxT("abcdefghijklmnopqrstuvwxyz0123456789-*"), buf[i])) {
|
||||
// Valid character found.
|
||||
i++;
|
||||
} else {
|
||||
// Invalid character found.
|
||||
ctrl->SetFocus();
|
||||
ctrl->SetSelection(i, i + 1);
|
||||
wxMessageBox(wxString::Format(_("Invalid character in host name found: %c"), buf[i]), _("Validation conflict"), wxOK | wxICON_EXCLAMATION, parent);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxFQDNValidator
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxFQDNValidator, wxValidator);
|
||||
|
||||
|
||||
wxFQDNValidator::wxFQDNValidator(std::string *val) :
|
||||
m_val(val),
|
||||
wxValidator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxFQDNValidator::wxFQDNValidator(const wxFQDNValidator &other) :
|
||||
m_val(other.m_val),
|
||||
wxValidator(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxObject* wxFQDNValidator::Clone() const
|
||||
{
|
||||
return new wxFQDNValidator(*this);
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNValidator::Validate(wxWindow *parent)
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
|
||||
if (!ctrl->IsEnabled()) return true;
|
||||
|
||||
wxString val(ctrl->GetValue());
|
||||
return Parse(val, 0, val.Length(), ctrl, parent);
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNValidator::TransferToWindow()
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
|
||||
if (m_val)
|
||||
((wxTextCtrl*)GetWindow())->SetValue(*m_val);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNValidator::TransferFromWindow()
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
|
||||
|
||||
wxString val(ctrl->GetValue());
|
||||
return Parse(val, 0, val.Length(), ctrl, NULL, m_val);
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, std::string *val_out)
|
||||
{
|
||||
const wxStringCharType *buf = val_in;
|
||||
|
||||
size_t i = i_start;
|
||||
for (;;) {
|
||||
const wxStringCharType *buf_next;
|
||||
if ((buf_next = wmemchr(buf + i, L'.', i_end - i)) != NULL) {
|
||||
// FQDN separator found.
|
||||
if (!wxHostNameValidator::Parse(val_in, i, buf_next - buf, ctrl, parent))
|
||||
return false;
|
||||
i = buf_next - buf + 1;
|
||||
} else if (wxHostNameValidator::Parse(val_in, i, i_end, ctrl, parent)) {
|
||||
// The rest of the FQDN parsed succesfully.
|
||||
if (val_out) val_out->assign(val_in.c_str() + i_start, i_end - i_start);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxFQDNListValidator
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxFQDNListValidator, wxValidator);
|
||||
|
||||
|
||||
wxFQDNListValidator::wxFQDNListValidator(std::list<std::string> *val) :
|
||||
m_val(val),
|
||||
wxValidator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxFQDNListValidator::wxFQDNListValidator(const wxFQDNListValidator &other) :
|
||||
m_val(other.m_val),
|
||||
wxValidator(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxObject* wxFQDNListValidator::Clone() const
|
||||
{
|
||||
return new wxFQDNListValidator(*this);
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNListValidator::Validate(wxWindow *parent)
|
||||
{
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
|
||||
if (!ctrl->IsEnabled()) return true;
|
||||
|
||||
wxString val(ctrl->GetValue());
|
||||
return Parse(val, 0, val.Length(), ctrl, parent);
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNListValidator::TransferToWindow()
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
|
||||
if (m_val) {
|
||||
wxString str;
|
||||
for (std::list<std::string>::const_iterator name = m_val->cbegin(), name_end = m_val->cend(); name != name_end; ++name) {
|
||||
if (!str.IsEmpty()) str += wxT("; ");
|
||||
str += *name;
|
||||
}
|
||||
((wxTextCtrl*)GetWindow())->SetValue(str);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNListValidator::TransferFromWindow()
|
||||
{
|
||||
wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxTextCtrl)));
|
||||
wxTextCtrl *ctrl = (wxTextCtrl*)GetWindow();
|
||||
|
||||
wxString val(ctrl->GetValue());
|
||||
return Parse(val, 0, val.Length(), ctrl, NULL, m_val);
|
||||
}
|
||||
|
||||
|
||||
bool wxFQDNListValidator::Parse(const wxString &val_in, size_t i_start, size_t i_end, wxTextCtrl *ctrl, wxWindow *parent, std::list<std::string> *val_out)
|
||||
{
|
||||
const wxStringCharType *buf = val_in;
|
||||
std::string _fqdn, *fqdn = val_out ? &_fqdn : NULL;
|
||||
std::list<std::string> _val_out;
|
||||
|
||||
size_t i = i_start;
|
||||
for (;;) {
|
||||
// Skip initial white-space.
|
||||
for (; i < i_end && _istspace(buf[i]); i++);
|
||||
|
||||
const wxStringCharType *buf_next;
|
||||
if ((buf_next = wmemchr(buf + i, L';', i_end - i)) != NULL) {
|
||||
// FQDN list separator found.
|
||||
|
||||
// Skip trailing white-space.
|
||||
size_t i_next = buf_next - buf;
|
||||
for (; i < i_next && _istspace(buf[i_next - 1]); i_next--);
|
||||
|
||||
if (!wxFQDNValidator::Parse(val_in, i, i_next, ctrl, parent, fqdn))
|
||||
return false;
|
||||
if (fqdn && !fqdn->empty()) _val_out.push_back(std::move(*fqdn));
|
||||
|
||||
i = buf_next - buf + 1;
|
||||
} else {
|
||||
// Skip trailing white-space.
|
||||
for (; i < i_end && _istspace(buf[i_end - 1]); i_end--);
|
||||
|
||||
if (wxHostNameValidator::Parse(val_in, i, i_end, ctrl, parent, fqdn)) {
|
||||
// The rest of the FQDN list parsed succesfully.
|
||||
if (fqdn && !fqdn->empty()) _val_out.push_back(std::move(*fqdn));
|
||||
if (val_out) *val_out = std::move(_val_out);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTLSCredentialsPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTLSCredentialsPanel::wxEAPTLSCredentialsPanel(eap::credentials_tls &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
|
||||
wxCredentialsPanel<wxEAPTLSCredentialsPanelBase, eap::credentials_tls>(cred, pszCredTarget, parent, is_config)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(269));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSCredentialsPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(__super::TransferDataToWindow(), false);
|
||||
|
||||
// Populate certificate list.
|
||||
bool is_found = false;
|
||||
winstd::cert_store store;
|
||||
if (store.create(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, (HCRYPTPROV)NULL, CERT_SYSTEM_STORE_CURRENT_USER, _T("My"))) {
|
||||
for (PCCERT_CONTEXT cert = NULL; (cert = CertEnumCertificatesInStore(store, cert)) != NULL;) {
|
||||
DWORD dwKeySpec = 0, dwSize = sizeof(dwKeySpec);
|
||||
if (!CertGetCertificateContextProperty(cert, CERT_KEY_SPEC_PROP_ID, &dwKeySpec, &dwSize) || !dwKeySpec) {
|
||||
// Skip certificates without private key.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prepare certificate information.
|
||||
std::unique_ptr<wxCertificateSelectionClientData> data(new wxCertificateSelectionClientData);
|
||||
eap::get_cert_title(cert, data->m_identity);
|
||||
|
||||
// Add to list.
|
||||
CertGetCertificateContextProperty(cert, CERT_HASH_PROP_ID, data->m_hash);
|
||||
bool is_selected = data->m_hash == m_cred.m_cert_hash;
|
||||
int i = m_cert_select_val->Append(data->m_identity, data.release());
|
||||
if (is_selected) {
|
||||
m_cert_select_val->SetSelection(i);
|
||||
is_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_found) {
|
||||
m_cert_select ->SetValue(true);
|
||||
m_cert_select_val->Enable(true);
|
||||
} else {
|
||||
m_cert_none ->SetValue(true);
|
||||
m_cert_select_val->Enable(false);
|
||||
if (!m_cert_select_val->IsEmpty())
|
||||
m_cert_select_val->SetSelection(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSCredentialsPanel::TransferDataFromWindow()
|
||||
{
|
||||
if (m_cert_none->GetValue())
|
||||
m_cred.clear();
|
||||
else {
|
||||
const wxCertificateSelectionClientData *data = dynamic_cast<const wxCertificateSelectionClientData*>(m_cert_select_val->GetClientObject(m_cert_select_val->GetSelection()));
|
||||
if (data) {
|
||||
m_cred.m_identity = data->m_identity;
|
||||
m_cred.m_cert_hash = data->m_hash;
|
||||
} else
|
||||
m_cred.clear();
|
||||
}
|
||||
|
||||
return __super::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSCredentialsPanel::OnCertSelect(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
m_cert_select_val->Enable(m_cert_select->GetValue());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTLSServerTrustPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTLSServerTrustPanel::wxEAPTLSServerTrustPanel(eap::config_tls &cfg, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
wxEAPTLSServerTrustConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_certmgr.load(_T("certmgr.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_server_trust_icon, m_icon, m_certmgr, MAKEINTRESOURCE(218));
|
||||
|
||||
m_server_names->SetValidator(wxFQDNListValidator(&(m_cfg.m_server_names)));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSServerTrustPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(wxEAPTLSServerTrustConfigPanelBase::TransferDataToWindow(), false);
|
||||
|
||||
// Populate trusted CA list.
|
||||
for (std::list<winstd::cert_context>::const_iterator cert = m_cfg.m_trusted_root_ca.cbegin(), cert_end = m_cfg.m_trusted_root_ca.cend(); cert != cert_end; ++cert) {
|
||||
winstd::tstring name;
|
||||
if (CertGetNameString(*cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name) > 0)
|
||||
m_root_ca->Append(wxString(name), new wxCertificateClientData(cert->duplicate()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSServerTrustPanel::TransferDataFromWindow()
|
||||
{
|
||||
// Parse trusted CA list.
|
||||
m_cfg.m_trusted_root_ca.clear();
|
||||
for (unsigned int i = 0, i_end = m_root_ca->GetCount(); i < i_end; i++) {
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(m_root_ca->GetClientObject(i));
|
||||
if (cert)
|
||||
m_cfg.add_trusted_ca(cert->m_cert->dwCertEncodingType, cert->m_cert->pbCertEncoded, cert->m_cert->cbCertEncoded);
|
||||
}
|
||||
|
||||
return wxEAPTLSServerTrustConfigPanelBase::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCA(wxCommandEvent& event)
|
||||
{
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(event.GetClientObject());
|
||||
m_root_ca_remove->Enable(cert ? true : false);
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCADClick(wxCommandEvent& event)
|
||||
{
|
||||
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(event.GetClientObject());
|
||||
if (cert)
|
||||
CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, cert->m_cert, this->GetHWND(), NULL, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCAAddStore(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
winstd::cert_store store;
|
||||
if (store.create(NULL, _T("ROOT"))) {
|
||||
winstd::cert_context cert;
|
||||
cert.attach(CryptUIDlgSelectCertificateFromStore(store, this->GetHWND(), NULL, NULL, 0, 0, NULL));
|
||||
if (cert)
|
||||
AddRootCA(cert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCAAddFile(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
const wxString separator(wxT("|"));
|
||||
wxFileDialog open_dialog(this, _("Add Certificate"), wxEmptyString, wxEmptyString,
|
||||
_("Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.p7b;*.pem") + separator +
|
||||
_("X.509 Certificate Files (*.cer;*.crt;*.der;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.pem") + separator +
|
||||
_("PKCS #7 Certificate Files (*.p7b)") + separator + wxT("*.p7b") + separator +
|
||||
_("All Files (*.*)") + separator + wxT("*.*"),
|
||||
wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_MULTIPLE);
|
||||
if (open_dialog.ShowModal() == wxID_CANCEL) {
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
wxArrayString paths;
|
||||
open_dialog.GetPaths(paths);
|
||||
for (size_t i = 0, i_end = paths.GetCount(); i < i_end; i++) {
|
||||
// Load certificate(s) from file.
|
||||
winstd::cert_store cs;
|
||||
if (cs.create(CERT_STORE_PROV_FILENAME, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, NULL, CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, (LPCTSTR)(paths[i]))) {
|
||||
for (PCCERT_CONTEXT cert = NULL; (cert = CertEnumCertificatesInStore(cs, cert)) != NULL;)
|
||||
AddRootCA(cert);
|
||||
} else
|
||||
wxMessageBox(wxString::Format(_("Invalid or unsupported certificate file %s"), paths[i]), _("Error"), wxOK | wxICON_EXCLAMATION, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSServerTrustPanel::OnRootCARemove(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
wxArrayInt selections;
|
||||
for (int i = m_root_ca->GetSelections(selections); i--; )
|
||||
m_root_ca->Delete(selections[i]);
|
||||
|
||||
m_root_ca_remove->Enable(false);
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTLSServerTrustPanel::AddRootCA(PCCERT_CONTEXT cert)
|
||||
{
|
||||
for (unsigned int i = 0, i_end = m_root_ca->GetCount(); i < i_end; i++) {
|
||||
wxCertificateClientData *c = dynamic_cast<wxCertificateClientData*>(m_root_ca->GetClientObject(i));
|
||||
if (c && c->m_cert &&
|
||||
c->m_cert->cbCertEncoded == cert->cbCertEncoded &&
|
||||
memcmp(c->m_cert->pbCertEncoded, cert->pbCertEncoded, cert->cbCertEncoded) == 0)
|
||||
{
|
||||
// This certificate is already on the list.
|
||||
m_root_ca->SetSelection(i);
|
||||
m_root_ca_remove->Enable();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add certificate to the list.
|
||||
winstd::tstring name;
|
||||
if (CertGetNameString(cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, name) > 0) {
|
||||
int i = m_root_ca->Append(wxString(name), new wxCertificateClientData(CertDuplicateCertificateContext(cert)));
|
||||
if (0 <= i) {
|
||||
m_root_ca->SetSelection(i);
|
||||
m_root_ca_remove->Enable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTLSConfigPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTLSConfigPanel::wxEAPTLSConfigPanel(eap::config_tls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_server_trust = new wxEAPTLSServerTrustPanel(cfg, this);
|
||||
sb_content->Add(m_server_trust, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
if (cfg.m_allow_save) {
|
||||
m_credentials = new wxEAPTLSCredentialsConfigPanel(cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_credentials, 0, wxALL|wxEXPAND, 5);
|
||||
} else
|
||||
m_credentials = NULL;
|
||||
|
||||
sb_content->Add(10, 10, 1, wxEXPAND, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTLSConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxEAPTLSConfigPanel::~wxEAPTLSConfigPanel()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTLSConfigPanel::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTLSConfigPanel::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
m_server_trust->GetEventHandler()->ProcessEvent(event);
|
||||
if (m_credentials)
|
||||
m_credentials->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
@@ -1,375 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
#pragma comment(lib, "Msi.lib")
|
||||
#pragma comment(lib, "msxml6.lib")
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::config_ttls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config_ttls::config_ttls(_In_ module &mod) :
|
||||
m_inner(NULL),
|
||||
config_tls(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_ttls::config_ttls(const _In_ config_ttls &other) :
|
||||
m_inner(other.m_inner ? (config_method*)other.m_inner->clone() : NULL),
|
||||
config_tls(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_ttls::config_ttls(_Inout_ config_ttls &&other) :
|
||||
m_inner(other.m_inner),
|
||||
config_tls(std::move(other))
|
||||
{
|
||||
other.m_inner = NULL;
|
||||
}
|
||||
|
||||
|
||||
eap::config_ttls::~config_ttls()
|
||||
{
|
||||
if (m_inner)
|
||||
delete m_inner;
|
||||
}
|
||||
|
||||
|
||||
eap::config_ttls& eap::config_ttls::operator=(const _In_ config_ttls &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_tls&)*this = other;
|
||||
if (m_inner) delete m_inner;
|
||||
m_inner = other.m_inner ? (config_method*)other.m_inner->clone() : NULL;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config_ttls& eap::config_ttls::operator=(_Inout_ config_ttls &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_tls&&)*this = std::move(other);
|
||||
if (m_inner) delete m_inner;
|
||||
m_inner = other.m_inner;
|
||||
other.m_inner = NULL;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::config_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
|
||||
DWORD dwResult;
|
||||
|
||||
// <InnerAuthenticationMethod>
|
||||
com_obj<IXMLDOMElement> pXmlElInnerAuthenticationMethod;
|
||||
if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), bstr(L"InnerAuthenticationMethod"), bstrNamespace, &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <InnerAuthenticationMethod> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
if (dynamic_cast<const config_pap*>(m_inner)) {
|
||||
// <InnerAuthenticationMethod>/<NonEAPAuthMethod>
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pXmlElInnerAuthenticationMethod, bstr(L"NonEAPAuthMethod"), bstrNamespace, bstr(L"PAP"))) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <NonEAPAuthMethod> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// <InnerAuthenticationMethod>/...
|
||||
if ((dwResult = m_inner->save(pDoc, pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
} else
|
||||
return dwResult = ERROR_NOT_SUPPORTED;
|
||||
|
||||
return config_tls::save(pDoc, pConfigRoot, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::config_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(ppEapError);
|
||||
DWORD dwResult;
|
||||
|
||||
// Load inner authentication configuration (<InnerAuthenticationMethod>).
|
||||
com_obj<IXMLDOMElement> pXmlElInnerAuthenticationMethod;
|
||||
if ((dwResult = eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting <InnerAuthenticationMethod> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
// Determine inner authentication type (<EAPMethod> and <NonEAPAuthMethod>).
|
||||
//DWORD dwMethodID;
|
||||
bstr bstrMethod;
|
||||
/*if (eapxml::get_element_value(pXmlElInnerAuthenticationMethod, bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS &&
|
||||
dwMethodID == EAP_TYPE_MSCHAPV2)
|
||||
{
|
||||
// MSCHAPv2
|
||||
// TODO: Add MSCHAPv2 support.
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
} else*/ if (eapxml::get_element_value(pXmlElInnerAuthenticationMethod, bstr(L"eap-metadata:NonEAPAuthMethod"), &bstrMethod) == ERROR_SUCCESS &&
|
||||
CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstrMethod, bstrMethod.length(), L"PAP", -1, NULL, NULL, 0) == CSTR_EQUAL)
|
||||
{
|
||||
// PAP
|
||||
assert(!m_inner);
|
||||
m_inner = new eap::config_pap(m_module);
|
||||
if ((dwResult = m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
} else {
|
||||
*ppEapError = m_module.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Unsupported inner authentication method."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return config_tls::load(pConfigRoot, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials_ttls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials_ttls::credentials_ttls(_In_ module &mod) : credentials_tls(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_ttls::credentials_ttls(_In_ const credentials_ttls &other) :
|
||||
m_inner(other.m_inner ? (credentials*)other.m_inner->clone() : NULL),
|
||||
credentials_tls(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) :
|
||||
m_inner(other.m_inner),
|
||||
credentials_tls(std::move(other))
|
||||
{
|
||||
other.m_inner = NULL;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_ttls &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials_tls&)*this = other;
|
||||
|
||||
if (m_inner) delete m_inner;
|
||||
m_inner = other.m_inner ? (credentials*)other.m_inner->clone() : NULL;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials_tls&)*this = std::move(other);
|
||||
|
||||
if (m_inner) delete m_inner;
|
||||
m_inner = other.m_inner;
|
||||
other.m_inner = NULL;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void eap::credentials_ttls::clear()
|
||||
{
|
||||
credentials_tls::clear();
|
||||
if (m_inner)
|
||||
m_inner->clear();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_ttls::empty() const
|
||||
{
|
||||
return credentials_tls::empty() && (!m_inner || m_inner->empty());
|
||||
}
|
||||
|
||||
|
||||
|
||||
DWORD eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pConfigRoot);
|
||||
DWORD dwResult;
|
||||
|
||||
if ((dwResult = credentials_tls::load(pConfigRoot, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
if (m_inner) {
|
||||
com_obj<IXMLDOMNode> pXmlElInnerAuthenticationMethod;
|
||||
if ((dwResult = eapxml::select_node(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting <InnerAuthenticationMethod> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
if ((dwResult = m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_ttls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
DWORD dwResult;
|
||||
|
||||
if ((dwResult = credentials_tls::store(pszTargetName, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
if (m_inner) {
|
||||
if ((dwResult = m_inner->store(pszTargetName, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::credentials_ttls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
DWORD dwResult;
|
||||
|
||||
if ((dwResult = credentials_tls::retrieve(pszTargetName, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
if (m_inner) {
|
||||
if ((dwResult = m_inner->retrieve(pszTargetName, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::session_ttls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::session_ttls::session_ttls() : session()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::peer_ttls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::peer_ttls::peer_ttls() : peer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls::initialize(_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
// MSI's feature completeness check removed: It might invoke UI (prompt user for missing MSI),
|
||||
// which would be disasterous in EapHost system service.
|
||||
#if 0
|
||||
// Perform the Microsoft Installer's feature completeness check manually.
|
||||
// If execution got this far in the first place (dependent DLLs are present and loadable).
|
||||
// Furthermore, this increments program usage counter.
|
||||
if (MsiQueryFeatureState(_T(PRODUCT_VERSION_GUID), _T("featEAPTTLS")) != INSTALLSTATE_UNKNOWN)
|
||||
MsiUseFeature(_T(PRODUCT_VERSION_GUID), _T("featEAPTTLS"));
|
||||
#endif
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls::shutdown(_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls::get_identity(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwConnectionDataSize,
|
||||
_In_count_(dwConnectionDataSize) const BYTE *pConnectionData,
|
||||
_In_ DWORD dwUserDataSize,
|
||||
_In_count_(dwUserDataSize) const BYTE *pUserData,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_Out_ BOOL *pfInvokeUI,
|
||||
_Out_ DWORD *pdwUserDataOutSize,
|
||||
_Out_ BYTE **ppUserDataOut,
|
||||
_Out_ WCHAR **ppwszIdentity,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(dwConnectionDataSize);
|
||||
UNREFERENCED_PARAMETER(pConnectionData);
|
||||
UNREFERENCED_PARAMETER(dwUserDataSize);
|
||||
UNREFERENCED_PARAMETER(pUserData);
|
||||
UNREFERENCED_PARAMETER(hTokenImpersonateUser);
|
||||
UNREFERENCED_PARAMETER(pfInvokeUI);
|
||||
UNREFERENCED_PARAMETER(pdwUserDataOutSize);
|
||||
UNREFERENCED_PARAMETER(ppUserDataOut);
|
||||
UNREFERENCED_PARAMETER(ppwszIdentity);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
DWORD dwResult = ERROR_NOT_SUPPORTED;
|
||||
ETW_FN_DWORD(dwResult);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls::get_method_properties(
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ HANDLE hUserImpersonationToken,
|
||||
_In_ DWORD dwEapConnDataSize,
|
||||
_In_count_(dwEapConnDataSize) const BYTE *pEapConnData,
|
||||
_In_ DWORD dwUserDataSize,
|
||||
_In_count_(dwUserDataSize) const BYTE *pUserData,
|
||||
_Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray,
|
||||
_Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwVersion);
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(hUserImpersonationToken);
|
||||
UNREFERENCED_PARAMETER(dwEapConnDataSize);
|
||||
UNREFERENCED_PARAMETER(pEapConnData);
|
||||
UNREFERENCED_PARAMETER(dwUserDataSize);
|
||||
UNREFERENCED_PARAMETER(pUserData);
|
||||
UNREFERENCED_PARAMETER(pMethodPropertyArray);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
DWORD dwResult = ERROR_NOT_SUPPORTED;
|
||||
ETW_FN_DWORD(dwResult);
|
||||
return dwResult;
|
||||
}
|
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <StdAfx.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::peer_ttls_ui
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::peer_ttls_ui::peer_ttls_ui() : peer_ui<eap::config_ttls, eap::credentials_ttls, int, int>()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls_ui::invoke_config_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_Inout_ config_type &cfg,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
// Initialize application.
|
||||
new wxApp();
|
||||
wxEntryStart(m_instance);
|
||||
|
||||
int result;
|
||||
{
|
||||
// Create wxWidget-approved parent window.
|
||||
wxWindow parent;
|
||||
parent.SetHWND((WXHWND)hwndParent);
|
||||
parent.AdoptAttributesFromHWND();
|
||||
wxTopLevelWindows.Append(&parent);
|
||||
|
||||
// Create and launch configuration dialog.
|
||||
wxEAPConfigDialog<config_ttls, wxEAPTTLSConfig> dlg(cfg, &parent);
|
||||
result = dlg.ShowModal();
|
||||
|
||||
wxTopLevelWindows.DeleteObject(&parent);
|
||||
parent.SetHWND((WXHWND)NULL);
|
||||
}
|
||||
|
||||
// Clean-up and return.
|
||||
wxEntryCleanup();
|
||||
return result == wxID_OK ? ERROR_SUCCESS : ERROR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls_ui::invoke_identity_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_In_ DWORD dwFlags,
|
||||
_Inout_ config_type &cfg,
|
||||
_Inout_ identity_type &usr,
|
||||
_Out_ LPWSTR *ppwszIdentity,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(cfg);
|
||||
UNREFERENCED_PARAMETER(usr);
|
||||
UNREFERENCED_PARAMETER(ppwszIdentity);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
InitCommonControls();
|
||||
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" credential prompt goes here!"), _T(PRODUCT_NAME_STR) _T(" Credentials"), MB_OK);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
DWORD eap::peer_ttls_ui::invoke_interactive_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_In_ const interactive_request_type &req,
|
||||
_Out_ interactive_response_type &res,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(req);
|
||||
UNREFERENCED_PARAMETER(res);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
InitCommonControls();
|
||||
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" interactive UI goes here!"), _T(PRODUCT_NAME_STR) _T(" Prompt"), MB_OK);
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTTLSConfigPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTTLSConfigPanel::wxEAPTTLSConfigPanel(eap::config_ttls &cfg, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
wxEAPTTLSConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_outer_identity_icon, m_icon, m_shell32, MAKEINTRESOURCE(265));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfigPanel::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK(wxEAPTTLSConfigPanelBase::TransferDataToWindow(), false);
|
||||
|
||||
// Populate identity controls.
|
||||
if (m_cfg.m_anonymous_identity.empty()) {
|
||||
m_outer_identity_same->SetValue(true);
|
||||
m_outer_identity_custom_val->Enable(false);
|
||||
} else if (m_cfg.m_anonymous_identity == L"@") {
|
||||
m_outer_identity_empty->SetValue(true);
|
||||
m_outer_identity_custom_val->Enable(false);
|
||||
} else {
|
||||
m_outer_identity_custom->SetValue(true);
|
||||
m_outer_identity_custom_val->Enable(true);
|
||||
m_outer_identity_custom_val->SetValue(m_cfg.m_anonymous_identity);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfigPanel::TransferDataFromWindow()
|
||||
{
|
||||
if (m_outer_identity_same->GetValue())
|
||||
m_cfg.m_anonymous_identity.clear();
|
||||
else if (m_outer_identity_empty->GetValue())
|
||||
m_cfg.m_anonymous_identity = L"@";
|
||||
else
|
||||
m_cfg.m_anonymous_identity = m_outer_identity_custom_val->GetValue();
|
||||
|
||||
return wxEAPTTLSConfigPanelBase::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTTLSConfigPanel::OnOuterIdentityCustom(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
m_outer_identity_custom_val->Enable(m_outer_identity_custom->GetValue());
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPTTLSConfig
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPTTLSConfig::wxEAPTTLSConfig(eap::config_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
m_cfg_pap(cfg.m_module),
|
||||
wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL)
|
||||
{
|
||||
wxBoxSizer* sb_content;
|
||||
sb_content = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_outer_title = new wxStaticText(this, wxID_ANY, _("Outer Authentication"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_outer_title->SetFont(wxFont(18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
|
||||
m_outer_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
|
||||
sb_content->Add(m_outer_title, 0, wxALL|wxALIGN_RIGHT, 5);
|
||||
|
||||
m_outer_identity = new wxEAPTTLSConfigPanel(m_cfg, this);
|
||||
sb_content->Add(m_outer_identity, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
m_tls = new wxEAPTLSConfigPanel(m_cfg, pszCredTarget, this);
|
||||
sb_content->Add(m_tls, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
sb_content->Add(20, 20, 1, wxEXPAND, 5);
|
||||
|
||||
m_inner_title = new wxStaticText(this, wxID_ANY, _("Inner Authentication"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_inner_title->SetFont(wxFont(18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString));
|
||||
m_inner_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
|
||||
sb_content->Add(m_inner_title, 0, wxALL|wxALIGN_RIGHT, 5);
|
||||
|
||||
m_inner_type = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxCHB_DEFAULT);
|
||||
m_inner_type->SetToolTip( _("Select inner authentication method from the list") );
|
||||
m_inner_type->AddPage(new wxPAPConfigPanel(m_cfg_pap, pszCredTarget, m_inner_type), _("PAP"));
|
||||
sb_content->Add(m_inner_type, 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
wxSize size = sb_content->CalcMin();
|
||||
if (size.y > 500) {
|
||||
// Increase the width to allow space for vertical scroll bar (to prevent horizontal one) and truncate the height.
|
||||
size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this);
|
||||
size.y = 500;
|
||||
}
|
||||
this->SetMinSize(size);
|
||||
this->SetScrollRate(5, 5);
|
||||
|
||||
this->SetSizer(sb_content);
|
||||
this->Layout();
|
||||
|
||||
m_outer_identity->SetFocusFromKbd();
|
||||
|
||||
// Connect Events
|
||||
this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTTLSConfig::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
wxEAPTTLSConfig::~wxEAPTTLSConfig()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPTTLSConfig::OnInitDialog));
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfig::TransferDataToWindow()
|
||||
{
|
||||
eap::config_pap *cfg_pap = dynamic_cast<eap::config_pap*>(m_cfg.m_inner);
|
||||
if (cfg_pap) {
|
||||
m_cfg_pap = *cfg_pap;
|
||||
m_inner_type->SetSelection(0); // 0=PAP
|
||||
} else
|
||||
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
|
||||
|
||||
return wxScrolledWindow::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
bool wxEAPTTLSConfig::TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(wxScrolledWindow::TransferDataFromWindow(), false);
|
||||
|
||||
switch (m_inner_type->GetSelection()) {
|
||||
case 0: // 0=PAP
|
||||
delete m_cfg.m_inner;
|
||||
m_cfg.m_inner = new eap::config_pap(m_cfg_pap);
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void wxEAPTTLSConfig::OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
m_outer_identity->GetEventHandler()->ProcessEvent(event);
|
||||
m_tls->GetEventHandler()->ProcessEvent(event);
|
||||
for (wxWindowList::compatibility_iterator inner = m_inner_type->GetChildren().GetFirst(); inner; inner = inner->GetNext())
|
||||
inner->GetData()->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
19
EventMonitor/EventMonitor.props
Normal file
19
EventMonitor/EventMonitor.props
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir>..\output\$(Platform).$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\lib\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
BIN
EventMonitor/EventMonitor.rc
Normal file
BIN
EventMonitor/EventMonitor.rc
Normal file
Binary file not shown.
114
EventMonitor/EventMonitor.vcxproj
Normal file
114
EventMonitor/EventMonitor.vcxproj
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>EventMonitor</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\Win32.props" />
|
||||
<Import Project="..\include\Debug.props" />
|
||||
<Import Project="EventMonitor.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\x64.props" />
|
||||
<Import Project="..\include\Debug.props" />
|
||||
<Import Project="EventMonitor.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\Win32.props" />
|
||||
<Import Project="..\include\Release.props" />
|
||||
<Import Project="EventMonitor.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\x64.props" />
|
||||
<Import Project="..\include\Release.props" />
|
||||
<Import Project="EventMonitor.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EventMonitor.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\lib\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\WinStd\build\WinStd.vcxproj">
|
||||
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
38
EventMonitor/EventMonitor.vcxproj.filters
Normal file
38
EventMonitor/EventMonitor.vcxproj.filters
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EventMonitor.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
9
EventMonitor/MSIBuild/.gitignore
vendored
Normal file
9
EventMonitor/MSIBuild/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*-1.idt
|
||||
/*-2.idt
|
||||
/*-2.idtx
|
||||
/*.Binary-1
|
||||
/*.Binary-2
|
||||
/*.Icon-1
|
||||
/*.Icon-2
|
||||
/*.lst
|
||||
/*.msm
|
BIN
EventMonitor/MSIBuild/Makefile
Normal file
BIN
EventMonitor/MSIBuild/Makefile
Normal file
Binary file not shown.
562
EventMonitor/Main.cpp
Normal file
562
EventMonitor/Main.cpp
Normal file
@@ -0,0 +1,562 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#pragma comment(lib, "tdh.lib")
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
static vector<TRACEHANDLE> g_traces;
|
||||
|
||||
|
||||
static BOOL WINAPI ConsoleHandler(_In_ DWORD dwCtrlType)
|
||||
{
|
||||
switch(dwCtrlType) {
|
||||
case CTRL_C_EVENT:
|
||||
case CTRL_BREAK_EVENT:
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
for (vector<TRACEHANDLE>::const_iterator trace = g_traces.cbegin(), trace_end = g_traces.cend(); trace != trace_end; ++trace)
|
||||
CloseTrace(*trace);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static tstring MapToString(_In_ const EVENT_MAP_INFO *pMapInfo, _In_ LPCBYTE pData)
|
||||
{
|
||||
if ( (pMapInfo->Flag & EVENTMAP_INFO_FLAG_MANIFEST_VALUEMAP) ||
|
||||
((pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_VALUEMAP ) && (pMapInfo->Flag & ~EVENTMAP_INFO_FLAG_WBEM_VALUEMAP) != EVENTMAP_INFO_FLAG_WBEM_FLAG))
|
||||
{
|
||||
if ((pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_NO_MAP) == EVENTMAP_INFO_FLAG_WBEM_NO_MAP)
|
||||
return tstring_printf(_T("%ls"), (PBYTE)pMapInfo + pMapInfo->MapEntryArray[*(PULONG)pData].OutputOffset);
|
||||
else {
|
||||
for (ULONG i = 0; ; i++) {
|
||||
if (i >= pMapInfo->EntryCount)
|
||||
return tstring_printf(_T("%lu"), *(PULONG)pData);
|
||||
else if (pMapInfo->MapEntryArray[i].Value == *(PULONG)pData)
|
||||
return tstring_printf(_T("%ls"), (PBYTE)pMapInfo + pMapInfo->MapEntryArray[i].OutputOffset);
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
(pMapInfo->Flag & EVENTMAP_INFO_FLAG_MANIFEST_BITMAP) ||
|
||||
(pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_BITMAP ) ||
|
||||
((pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_VALUEMAP ) && (pMapInfo->Flag & ~EVENTMAP_INFO_FLAG_WBEM_VALUEMAP) == EVENTMAP_INFO_FLAG_WBEM_FLAG))
|
||||
{
|
||||
tstring out;
|
||||
|
||||
if (pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_NO_MAP) {
|
||||
for (ULONG i = 0; i < pMapInfo->EntryCount; i++)
|
||||
if (*(PULONG)pData & (1 << i))
|
||||
out.append(tstring_printf(out.empty() ? _T("%ls") : _T(" | %ls"), (PBYTE)pMapInfo + pMapInfo->MapEntryArray[i].OutputOffset));
|
||||
} else {
|
||||
for (ULONG i = 0; i < pMapInfo->EntryCount; i++)
|
||||
if ((pMapInfo->MapEntryArray[i].Value & *(PULONG)pData) == pMapInfo->MapEntryArray[i].Value)
|
||||
out.append(tstring_printf(out.empty() ? _T("%ls") : _T(" | %ls"), (PBYTE)pMapInfo + pMapInfo->MapEntryArray[i].OutputOffset));
|
||||
}
|
||||
|
||||
return out.empty() ? tstring_printf(_T("%lu"), *(PULONG)pData) : out;
|
||||
}
|
||||
|
||||
return _T("<unknown map>");
|
||||
}
|
||||
|
||||
|
||||
static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_(nDataSize) LPCBYTE pData, _In_ SIZE_T nDataSize, _In_ const EVENT_MAP_INFO *pMapInfo, _In_ BYTE nPtrSize)
|
||||
{
|
||||
assert(pData || !nDataSize);
|
||||
|
||||
switch (InType) {
|
||||
case TDH_INTYPE_UNICODESTRING:
|
||||
case TDH_INTYPE_NONNULLTERMINATEDSTRING:
|
||||
case TDH_INTYPE_UNICODECHAR:
|
||||
return tstring_printf(_T("%.*ls"), nDataSize/sizeof(WCHAR), pData);
|
||||
|
||||
case TDH_INTYPE_ANSISTRING:
|
||||
case TDH_INTYPE_NONNULLTERMINATEDANSISTRING:
|
||||
case TDH_INTYPE_ANSICHAR: {
|
||||
// Convert strings from ANSI code page, all others (JSON, XML etc.) from UTF-8
|
||||
wstring str;
|
||||
MultiByteToWideChar(OutType == TDH_OUTTYPE_STRING ? CP_ACP : CP_UTF8, 0, (LPCSTR)pData, (int)nDataSize, str);
|
||||
return tstring_printf(_T("%ls"), str.c_str());
|
||||
}
|
||||
|
||||
case TDH_INTYPE_COUNTEDSTRING:
|
||||
return DataToString(TDH_INTYPE_NONNULLTERMINATEDSTRING, OutType, (LPCBYTE)((PUSHORT)pData + 1), *(PUSHORT)pData, pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_COUNTEDANSISTRING:
|
||||
return DataToString(TDH_INTYPE_NONNULLTERMINATEDANSISTRING, OutType, (LPCBYTE)((PUSHORT)pData + 1), *(PUSHORT)pData, pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_REVERSEDCOUNTEDSTRING:
|
||||
return DataToString(TDH_INTYPE_NONNULLTERMINATEDSTRING, OutType, (LPCBYTE)((PUSHORT)pData + 1), MAKEWORD(HIBYTE(*(PUSHORT)pData), LOBYTE(*(PUSHORT)pData)), pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_REVERSEDCOUNTEDANSISTRING:
|
||||
return DataToString(TDH_INTYPE_NONNULLTERMINATEDANSISTRING, OutType, (LPCBYTE)((PUSHORT)pData + 1), MAKEWORD(HIBYTE(*(PUSHORT)pData), LOBYTE(*(PUSHORT)pData)), pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_INT8:
|
||||
assert(nDataSize >= sizeof(CHAR));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_STRING: return DataToString(TDH_INTYPE_ANSICHAR, TDH_OUTTYPE_NULL, pData, nDataSize, pMapInfo, nPtrSize);
|
||||
default : return tstring_printf(_T("%hd"), *(PCHAR)pData);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_UINT8:
|
||||
assert(nDataSize >= sizeof(BYTE));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_STRING : return DataToString(TDH_INTYPE_ANSICHAR, TDH_OUTTYPE_NULL, pData, nDataSize, pMapInfo, nPtrSize);
|
||||
case TDH_OUTTYPE_HEXINT8: return tstring_printf(_T("0x%x"), *(PBYTE)pData);
|
||||
default : return tstring_printf(_T("%hu" ), *(PBYTE)pData);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_INT16:
|
||||
assert(nDataSize >= sizeof(SHORT));
|
||||
return tstring_printf(_T("%hd"), *(PSHORT)pData);
|
||||
|
||||
case TDH_INTYPE_UINT16:
|
||||
assert(nDataSize >= sizeof(USHORT));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_PORT : return tstring_printf(_T("%hu" ), ntohs(*(PUSHORT)pData));
|
||||
case TDH_OUTTYPE_HEXINT16: return tstring_printf(_T("0x%x"), *(PUSHORT)pData );
|
||||
case TDH_OUTTYPE_STRING : return tstring_printf(_T("%lc" ), *(PUSHORT)pData );
|
||||
default : return tstring_printf(_T("%hu" ), *(PUSHORT)pData );
|
||||
}
|
||||
|
||||
case TDH_INTYPE_INT32:
|
||||
assert(nDataSize >= sizeof(LONG));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_HRESULT: return tstring_printf(_T("0x%x"), *(PLONG)pData);
|
||||
default : return tstring_printf(_T("%ld" ), *(PLONG)pData);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_UINT32:
|
||||
assert(nDataSize >= sizeof(ULONG));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_HRESULT :
|
||||
case TDH_OUTTYPE_WIN32ERROR:
|
||||
case TDH_OUTTYPE_NTSTATUS :
|
||||
case TDH_OUTTYPE_HEXINT32 : return tstring_printf(_T("0x%x" ), *(PULONG)pData);
|
||||
case TDH_OUTTYPE_IPV4 : return tstring_printf(_T("%d.%d.%d.%d"), (*(PULONG)pData >> 0) & 0xff, (*(PULONG)pData >> 8) & 0xff, (*(PULONG)pData >> 16) & 0xff, (*(PULONG)pData >> 24) & 0xff);
|
||||
default: return pMapInfo ? MapToString(pMapInfo, pData) : tstring_printf(_T("%lu"), *(PULONG)pData);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_HEXINT32:
|
||||
return DataToString(TDH_INTYPE_UINT32, TDH_OUTTYPE_HEXINT32, pData, nDataSize, pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_INT64:
|
||||
assert(nDataSize >= sizeof(LONGLONG));
|
||||
return tstring_printf(_T("%I64d"), *(PLONGLONG)pData);
|
||||
|
||||
case TDH_INTYPE_UINT64:
|
||||
assert(nDataSize >= sizeof(ULONGLONG));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_HEXINT64: return tstring_printf(_T("0x%I64x"), *(PULONGLONG)pData);
|
||||
default : return tstring_printf(_T("%I64u" ), *(PULONGLONG)pData);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_HEXINT64:
|
||||
return DataToString(TDH_INTYPE_UINT64, TDH_OUTTYPE_HEXINT64, pData, nDataSize, pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_FLOAT:
|
||||
assert(nDataSize >= sizeof(FLOAT));
|
||||
return tstring_printf(_T("%f"), *(PFLOAT)pData);
|
||||
|
||||
case TDH_INTYPE_DOUBLE:
|
||||
assert(nDataSize >= sizeof(DOUBLE));
|
||||
return tstring_printf(_T("%I64f"), *(DOUBLE*)pData);
|
||||
|
||||
case TDH_INTYPE_BOOLEAN:
|
||||
assert(nDataSize >= sizeof(ULONG)); // Yes, boolean is really 32-bit.
|
||||
return *(PULONG)pData ? _T("true") : _T("false");
|
||||
|
||||
case TDH_INTYPE_BINARY:
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_IPV6: {
|
||||
auto RtlIpv6AddressToString = (LPTSTR(NTAPI*)(const IN6_ADDR*, LPTSTR))GetProcAddress(GetModuleHandle(_T("ntdll.dll")),
|
||||
#ifdef _UNICODE
|
||||
"RtlIpv6AddressToStringW"
|
||||
#else
|
||||
"RtlIpv6AddressToStringA"
|
||||
#endif
|
||||
);
|
||||
if (RtlIpv6AddressToString) {
|
||||
TCHAR szIPv6Addr[47];
|
||||
RtlIpv6AddressToString((IN6_ADDR*)pData, szIPv6Addr);
|
||||
return tstring_printf(_T("%s"), szIPv6Addr);
|
||||
} else
|
||||
return _T("<IPv6 address>");
|
||||
}
|
||||
default: {
|
||||
tstring out;
|
||||
for (SIZE_T i = 0; i < nDataSize; i++)
|
||||
out.append(tstring_printf(i ? _T(" %02x") : _T("%02x"), pData[i]));
|
||||
return out;
|
||||
}}
|
||||
|
||||
case TDH_INTYPE_HEXDUMP:
|
||||
return DataToString(TDH_INTYPE_BINARY, TDH_OUTTYPE_NULL, pData, nDataSize, pMapInfo, nPtrSize);
|
||||
|
||||
case TDH_INTYPE_GUID: {
|
||||
assert(nDataSize >= sizeof(GUID));
|
||||
WCHAR szGuid[39];
|
||||
StringFromGUID2(*(GUID*)pData, szGuid, _countof(szGuid));
|
||||
return tstring_printf(_T("%ls"), szGuid);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_POINTER:
|
||||
assert(nDataSize >= nPtrSize);
|
||||
switch (nPtrSize) {
|
||||
case sizeof(ULONG ): return tstring_printf(_T("0x%08x" ), *(PULONG )pData);
|
||||
case sizeof(ULONGLONG): return tstring_printf(_T("0x%016I64x"), *(PULONGLONG)pData);
|
||||
default: // Unsupported pointer size.
|
||||
assert(0);
|
||||
return _T("<pointer>");
|
||||
}
|
||||
|
||||
case TDH_INTYPE_SIZET:
|
||||
assert(nDataSize >= nPtrSize);
|
||||
switch (nPtrSize) {
|
||||
case sizeof(ULONG ): return tstring_printf(_T("%u" ), *(PULONG )pData);
|
||||
case sizeof(ULONGLONG): return tstring_printf(_T("%I64u"), *(PULONGLONG)pData);
|
||||
default: // Unsupported size_t size.
|
||||
assert(0);
|
||||
return _T("<size_t>");
|
||||
}
|
||||
|
||||
case TDH_INTYPE_FILETIME: {
|
||||
assert(nDataSize >= sizeof(FILETIME));
|
||||
SYSTEMTIME st, st_local;
|
||||
FileTimeToSystemTime((PFILETIME)pData, &st);
|
||||
SystemTimeToTzSpecificLocalTime(NULL, &st, &st_local);
|
||||
return DataToString(TDH_INTYPE_SYSTEMTIME, OutType, (LPCBYTE)&st_local, sizeof(st_local), pMapInfo, nPtrSize);
|
||||
}
|
||||
|
||||
case TDH_INTYPE_SYSTEMTIME:
|
||||
assert(nDataSize >= sizeof(SYSTEMTIME));
|
||||
switch (OutType) {
|
||||
case TDH_OUTTYPE_CULTURE_INSENSITIVE_DATETIME: return tstring_printf(_T("%04d-%02d-%02d %02d:%02d:%02d.%03u"), ((PSYSTEMTIME)pData)->wYear, ((PSYSTEMTIME)pData)->wMonth, ((PSYSTEMTIME)pData)->wDay, ((PSYSTEMTIME)pData)->wHour, ((PSYSTEMTIME)pData)->wMinute, ((PSYSTEMTIME)pData)->wSecond, ((PSYSTEMTIME)pData)->wMilliseconds);
|
||||
default: {
|
||||
tstring out;
|
||||
return GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, (PSYSTEMTIME)pData, NULL, out) ? out : tstring(_T("<time>"));
|
||||
}}
|
||||
|
||||
case TDH_INTYPE_WBEMSID:
|
||||
// A WBEM SID is actually a TOKEN_USER structure followed
|
||||
// by the SID. The size of the TOKEN_USER structure differs
|
||||
// depending on whether the events were generated on a 32-bit
|
||||
// or 64-bit architecture. Also the structure is aligned
|
||||
// on an 8-byte boundary, so its size is 8 bytes on a
|
||||
// 32-bit computer and 16 bytes on a 64-bit computer.
|
||||
// Doubling the pointer size handles both cases.
|
||||
assert(nDataSize >= nPtrSize * 2);
|
||||
return (PULONG)pData > 0 ? DataToString(TDH_INTYPE_SID, OutType, pData + nPtrSize * 2, nDataSize - nPtrSize * 2, pMapInfo, nPtrSize) : _T("<WBEM SID>");
|
||||
|
||||
case TDH_INTYPE_SID: {
|
||||
assert(nDataSize >= sizeof(SID));
|
||||
tstring user_name, domain_name;
|
||||
SID_NAME_USE eNameUse;
|
||||
if (LookupAccountSid(NULL, (PSID)pData, &user_name, &domain_name, &eNameUse))
|
||||
return tstring_printf(_T("%s\\%s"), domain_name.c_str(), user_name.c_str());
|
||||
else {
|
||||
unique_ptr<TCHAR[], LocalFree_delete<TCHAR[]> > sid;
|
||||
if (GetLastError() == ERROR_NONE_MAPPED &&
|
||||
ConvertSidToStringSid((PSID)pData, (LPTSTR*)&sid))
|
||||
return tstring_printf(_T("%s"), sid.get());
|
||||
else
|
||||
return _T("<SID>");
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
// It is not actually an error if we do not understand the given data type.
|
||||
assert(0);
|
||||
return _T("<unknown data type>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static ULONG GetArraySize(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, ULONG i, ULONG *pulArraySize)
|
||||
{
|
||||
if (pInfo->EventPropertyInfoArray[i].Flags & PropertyParamCount) {
|
||||
ULONG ulResult;
|
||||
|
||||
// Get array count property.
|
||||
PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)((LPBYTE)pInfo + pInfo->EventPropertyInfoArray[pInfo->EventPropertyInfoArray[i].countPropertyIndex].NameOffset), ULONG_MAX };
|
||||
vector<unsigned char> count;
|
||||
if ((ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, count)) != ERROR_SUCCESS)
|
||||
return ulResult;
|
||||
|
||||
// Copy count value to output.
|
||||
switch (count.size()) {
|
||||
case sizeof(BYTE ): *pulArraySize = *(const BYTE* )count.data(); break;
|
||||
case sizeof(USHORT): *pulArraySize = *(const USHORT*)count.data(); break;
|
||||
case sizeof(ULONG ): *pulArraySize = *(const ULONG* )count.data(); break;
|
||||
default : return ERROR_MORE_DATA;
|
||||
}
|
||||
} else
|
||||
*pulArraySize = pInfo->EventPropertyInfoArray[i].count;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static tstring PropertyToString(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, ULONG ulPropIndex, LPWSTR pStructureName, ULONG ulStructIndex, BYTE nPtrSize)
|
||||
{
|
||||
ULONG ulResult;
|
||||
|
||||
// Get the size of the array if the property is an array.
|
||||
ULONG ulArraySize = 0;
|
||||
if ((ulResult = GetArraySize(pEvent, pInfo, ulPropIndex, &ulArraySize)) != ERROR_SUCCESS)
|
||||
return tstring_printf(_T("<Error getting array size (error %u)>"), ulResult);;
|
||||
|
||||
tstring out;
|
||||
|
||||
if (ulArraySize > 1)
|
||||
out += tstring_printf(_T("[%u]("), ulArraySize);
|
||||
|
||||
for (ULONG k = 0; k < ulArraySize; k++) {
|
||||
if (pInfo->EventPropertyInfoArray[ulPropIndex].Flags & PropertyStruct) {
|
||||
// The property is a structure: print the members of the structure.
|
||||
tstring out;
|
||||
out += _T('(');
|
||||
for (USHORT j = pInfo->EventPropertyInfoArray[ulPropIndex].structType.StructStartIndex, usLastMember = pInfo->EventPropertyInfoArray[ulPropIndex].structType.StructStartIndex + pInfo->EventPropertyInfoArray[ulPropIndex].structType.NumOfStructMembers; j < usLastMember; j++) {
|
||||
out += tstring_printf(_T("%ls: "), (LPBYTE)pInfo + pInfo->EventPropertyInfoArray[j].NameOffset);
|
||||
out += PropertyToString(pEvent, pInfo, j, (LPWSTR)((LPBYTE)(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k, nPtrSize);
|
||||
}
|
||||
out += _T(')');
|
||||
} else {
|
||||
if (pInfo->EventPropertyInfoArray[ulPropIndex].nonStructType.InType == TDH_INTYPE_BINARY &&
|
||||
pInfo->EventPropertyInfoArray[ulPropIndex].nonStructType.OutType == TDH_OUTTYPE_IPV6)
|
||||
{
|
||||
// The TDH API does not support IPv6 addresses. If the output type is TDH_OUTTYPE_IPV6,
|
||||
// you will not be able to consume the rest of the event. If you try to consume the
|
||||
// remainder of the event, you will get ERROR_EVT_INVALID_EVENT_DATA.
|
||||
return _T("<The event contains an IPv6 address. Skipping.>");
|
||||
} else {
|
||||
vector<BYTE> data;
|
||||
if (pStructureName) {
|
||||
// To retrieve a member of a structure, you need to specify an array of descriptors.
|
||||
// The first descriptor in the array identifies the name of the structure and the second
|
||||
// descriptor defines the member of the structure whose data you want to retrieve.
|
||||
PROPERTY_DATA_DESCRIPTOR data_desc[2] = {
|
||||
{ (ULONGLONG)pStructureName , ulStructIndex },
|
||||
{ (ULONGLONG)((LPBYTE)pInfo + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k }
|
||||
};
|
||||
ulResult = TdhGetProperty(pEvent, 0, NULL, _countof(data_desc), data_desc, data);
|
||||
} else {
|
||||
PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)((LPBYTE)pInfo + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k };
|
||||
ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, data);
|
||||
}
|
||||
if (ulResult == ERROR_EVT_INVALID_EVENT_DATA) {
|
||||
// This happens with empty/NULL data. Not an error actually.
|
||||
assert(data.empty());
|
||||
} else if (ulResult != ERROR_SUCCESS)
|
||||
return tstring_printf(_T("<Error getting property (error %u)>"), ulResult);
|
||||
|
||||
// Get the name/value mapping if the property specifies a value map.
|
||||
unique_ptr<EVENT_MAP_INFO> map_info;
|
||||
ulResult = TdhGetEventMapInformation(pEvent, (LPWSTR)((LPBYTE)pInfo + pInfo->EventPropertyInfoArray[ulPropIndex].nonStructType.MapNameOffset), map_info);
|
||||
if (ulResult == ERROR_NOT_FOUND) {
|
||||
// name/value mapping not found. Not an error actually.
|
||||
assert(!map_info);
|
||||
} else if (ulResult != ERROR_SUCCESS)
|
||||
return tstring_printf(_T("<Error getting map information (error %u)>"), ulResult);
|
||||
else if (pInfo->DecodingSource == DecodingSourceXMLFile) {
|
||||
// The mapped string values defined in a manifest will contain a trailing space
|
||||
// in the EVENT_MAP_ENTRY structure. Replace the trailing space with a null-
|
||||
// terminating character, so that the bit mapped strings are correctly formatted.
|
||||
for (ULONG i = 0; i < map_info->EntryCount; i++) {
|
||||
SIZE_T len = _tcslen((LPCTSTR)((PBYTE)map_info.get() + map_info->MapEntryArray[i].OutputOffset)) - 1;
|
||||
((LPWSTR)((PBYTE)map_info.get() + map_info->MapEntryArray[i].OutputOffset))[len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!out.empty()) out += _T(", ");
|
||||
out += !data.empty() ? DataToString(
|
||||
pInfo->EventPropertyInfoArray[ulPropIndex].nonStructType.InType,
|
||||
pInfo->EventPropertyInfoArray[ulPropIndex].nonStructType.OutType,
|
||||
data.data(),
|
||||
data.size(),
|
||||
map_info.get(),
|
||||
nPtrSize) : _T("<null>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ulArraySize > 1)
|
||||
out += _T(')');
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
static VOID WINAPI EventRecordCallback(_In_ PEVENT_RECORD pEvent)
|
||||
{
|
||||
{
|
||||
// Calculate and print event time-stamp.
|
||||
FILETIME ft;
|
||||
ft.dwHighDateTime = pEvent->EventHeader.TimeStamp.HighPart;
|
||||
ft.dwLowDateTime = pEvent->EventHeader.TimeStamp.LowPart;
|
||||
|
||||
SYSTEMTIME st, st_local;
|
||||
FileTimeToSystemTime(&ft, &st);
|
||||
SystemTimeToTzSpecificLocalTime(NULL, &st, &st_local);
|
||||
|
||||
ULONGLONG
|
||||
ts = pEvent->EventHeader.TimeStamp.QuadPart,
|
||||
nanosec = (ts % 10000000) * 100;
|
||||
|
||||
_ftprintf(stdout, _T("%04d-%02d-%02d %02d:%02d:%02d.%09I64u"),
|
||||
st_local.wYear, st_local.wMonth, st_local.wDay, st_local.wHour, st_local.wMinute, st_local.wSecond, nanosec);
|
||||
}
|
||||
|
||||
{
|
||||
// Get event meta-info.
|
||||
unique_ptr<TRACE_EVENT_INFO> info;
|
||||
ULONG ulResult;
|
||||
if ((ulResult = TdhGetEventInformation(pEvent, 0, NULL, info)) == ERROR_SUCCESS) {
|
||||
if (info->DecodingSource != DecodingSourceWPP) {
|
||||
if (pEvent->EventHeader.Flags & EVENT_HEADER_FLAG_STRING_ONLY) {
|
||||
// This is a string-only event. Print it.
|
||||
_ftprintf(stdout, _T(" %ls"), pEvent->UserData);
|
||||
} else {
|
||||
// This is not a string-only event. Prepare parameters.
|
||||
|
||||
BYTE nPtrSize = (pEvent->EventHeader.Flags & EVENT_HEADER_FLAG_32_BIT_HEADER) ? 4 : 8;
|
||||
vector<tstring> props;
|
||||
vector<DWORD_PTR> props_msg;
|
||||
props.reserve(info->TopLevelPropertyCount);
|
||||
props_msg.reserve(info->TopLevelPropertyCount);
|
||||
for (ULONG i = 0; i < info->TopLevelPropertyCount; i++) {
|
||||
props.push_back(std::move(PropertyToString(pEvent, info.get(), i, NULL, 0, nPtrSize)));
|
||||
props_msg.push_back((DWORD_PTR)props[i].c_str());
|
||||
}
|
||||
|
||||
if (info->EventMessageOffset) {
|
||||
// Format the message.
|
||||
_ftprintf(stdout, _T(" %ls"), wstring_msg(0, (LPCTSTR)((LPCBYTE)info.get() + info->EventMessageOffset), props_msg.data()).c_str());
|
||||
}
|
||||
}
|
||||
} else if (info->EventMessageOffset) {
|
||||
// This is a WPP event.
|
||||
_ftprintf(stdout, _T(" %ls"), (LPCBYTE)info.get() + info->EventMessageOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ftprintf(stdout, _T("\n"));
|
||||
}
|
||||
|
||||
|
||||
#ifdef _UNICODE
|
||||
int wmain(int argc, const wchar_t *argv[])
|
||||
#else
|
||||
int main(int argc, const char *argv[])
|
||||
#endif
|
||||
{
|
||||
UNREFERENCED_PARAMETER(argc);
|
||||
UNREFERENCED_PARAMETER(argv);
|
||||
|
||||
setlocale(LC_ALL, ".OCP");
|
||||
|
||||
// Initialize COM.
|
||||
com_initializer com_init(NULL);
|
||||
|
||||
// Start a new session.
|
||||
ULONG ulResult;
|
||||
event_session session;
|
||||
for (unsigned int i = 0; ; i++) {
|
||||
//tstring log_file(tstring_printf(i ? _T("test.etl") : _T("test %u.etl"), i));
|
||||
tstring name(tstring_printf(i ? _T(PRODUCT_NAME_STR) _T(" Event Monitor Session %u") : _T(PRODUCT_NAME_STR) _T(" Event Monitor Session"), i));
|
||||
|
||||
// Allocate session properties.
|
||||
ULONG
|
||||
ulSizeName = (ULONG)((name .length() + 1)*sizeof(TCHAR)),
|
||||
//ulSizeLogFile = (ULONG)((log_file.length() + 1)*sizeof(TCHAR)),
|
||||
ulSize = sizeof(EVENT_TRACE_PROPERTIES) + ulSizeName /*+ ulSizeLogFile*/;
|
||||
unique_ptr<EVENT_TRACE_PROPERTIES> properties((EVENT_TRACE_PROPERTIES*)new char[ulSize]);
|
||||
if (!properties) {
|
||||
_ftprintf(stderr, _T("Error allocating session properties memory.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize properties.
|
||||
memset(properties.get(), 0, sizeof(EVENT_TRACE_PROPERTIES));
|
||||
properties->Wnode.BufferSize = ulSize;
|
||||
properties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
|
||||
properties->Wnode.ClientContext = 1; //QPC clock resolution
|
||||
CoCreateGuid(&(properties->Wnode.Guid));
|
||||
properties->LogFileMode = /*EVENT_TRACE_FILE_MODE_SEQUENTIAL |*/ EVENT_TRACE_REAL_TIME_MODE;
|
||||
properties->MaximumFileSize = 1; // 1 MB
|
||||
properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
|
||||
//properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + ulSizeName;
|
||||
//memcpy((LPTSTR)((char*)properties.get() + properties->LogFileNameOffset), log_file.c_str(), ulSizeLogFile);
|
||||
|
||||
if ((ulResult = session.create(name.c_str(), properties.get())) == ERROR_SUCCESS) {
|
||||
break;
|
||||
} else if (ulResult == ERROR_ACCESS_DENIED) {
|
||||
_ftprintf(stderr, _T("Access denied creating event session: you need administrative privileges (Run As Administrator) or be a member of Performance Log Users group to start event tracing session.\n"), ulResult);
|
||||
return 1;
|
||||
} else if (ulResult == ERROR_ALREADY_EXISTS) {
|
||||
_ftprintf(stderr, _T("The %s event session already exists.\n"), name.c_str());
|
||||
// Do not despair... Retry with a new session name and ID.
|
||||
continue;
|
||||
} else {
|
||||
_ftprintf(stderr, _T("Error creating event session (error %u).\n"), ulResult);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Enable event provider we are interested in to log events to our session.
|
||||
event_trace_enabler trace_enabler_event(session, &EAPMETHOD_TRACE_EVENT_PROVIDER, TRACE_LEVEL_VERBOSE);
|
||||
if ((ulResult = trace_enabler_event.status()) != ERROR_SUCCESS) {
|
||||
_ftprintf(stderr, _T("Error enabling event provider (error %u).\n"), ulResult);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// {6EB8DB94-FE96-443F-A366-5FE0CEE7FB1C}
|
||||
static const GUID s_provider_eaphost = { 0X6EB8DB94, 0XFE96, 0X443F, { 0XA3, 0X66, 0X5F, 0XE0, 0XCE, 0XE7, 0XFB, 0X1C } };
|
||||
event_trace_enabler trace_enabler_eaphost(session, &s_provider_eaphost, TRACE_LEVEL_INFORMATION);
|
||||
if ((ulResult = trace_enabler_eaphost.status()) != ERROR_SUCCESS) {
|
||||
// If the EAPHost trace provider failed to enable, do not despair.
|
||||
_ftprintf(stderr, _T("Error enabling EAPHost event provider (error %u).\n"), ulResult);
|
||||
}
|
||||
|
||||
// Open trace.
|
||||
EVENT_TRACE_LOGFILE tlf = {};
|
||||
tlf.LoggerName = (LPTSTR)session.name();
|
||||
tlf.ProcessTraceMode = PROCESS_TRACE_MODE_REAL_TIME | PROCESS_TRACE_MODE_EVENT_RECORD;
|
||||
tlf.EventRecordCallback = EventRecordCallback;
|
||||
event_trace trace;
|
||||
if (!trace.create(&tlf)) {
|
||||
_ftprintf(stderr, _T("Error opening event trace (error %u).\n"), GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Process events.
|
||||
g_traces.push_back(trace.detach());
|
||||
SetConsoleCtrlHandler(ConsoleHandler, TRUE);
|
||||
ProcessTrace(g_traces.data(), (ULONG)g_traces.size(), NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
9
EventMonitor/README.md
Normal file
9
EventMonitor/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
#EventMonitor
|
||||
Output real-time G<>ANTLink events to console
|
||||
|
||||
##Usage
|
||||
```
|
||||
EventMonitor
|
||||
```
|
||||
|
||||
Press Ctrl+C to stop the program.
|
21
EventMonitor/StdAfx.cpp
Normal file
21
EventMonitor/StdAfx.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
37
EventMonitor/StdAfx.h
Normal file
37
EventMonitor/StdAfx.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/Version.h"
|
||||
|
||||
#include <WinStd/COM.h>
|
||||
#include <WinStd/ETW.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <in6addr.h>
|
||||
#include <MSTcpIP.h>
|
||||
#include <Sddl.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <EventsETW.h> // Must include after <Windows.h>
|
Binary file not shown.
Submodule MSI/MSIBuild updated: 74c5814a13...16655a6871
2
MsiUseFeature/.gitignore
vendored
Normal file
2
MsiUseFeature/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/temp
|
||||
/*.user
|
69
MsiUseFeature/Main.cpp
Normal file
69
MsiUseFeature/Main.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#pragma comment(lib, "Msi.lib")
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
static int MsiUseFeature()
|
||||
{
|
||||
int nArgs;
|
||||
unique_ptr<LPWSTR[], LocalFree_delete<LPWSTR[]> > pwcArglist(CommandLineToArgvW(GetCommandLineW(), &nArgs));
|
||||
if (pwcArglist == NULL) {
|
||||
OutputDebugStr(_T("CommandLineToArgvW failed (error %u).\n"), GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (nArgs < 2) {
|
||||
OutputDebugStr(_T("Not enough parameters.\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Query the feature state.
|
||||
if (MsiQueryFeatureStateW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) == INSTALLSTATE_UNKNOWN) {
|
||||
OutputDebugStr(_T("The product is not installed or feature state is unknown.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Perform the Microsoft Installer's feature completeness check.
|
||||
if (MsiUseFeatureW(_L(PRODUCT_VERSION_GUID), pwcArglist[1]) != INSTALLSTATE_LOCAL) {
|
||||
OutputDebugStr(_T("The feature is not installed locally.\n"));
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hInstance);
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
UNREFERENCED_PARAMETER(nCmdShow);
|
||||
|
||||
int res = MsiUseFeature();
|
||||
assert(!_CrtDumpMemoryLeaks());
|
||||
return res;
|
||||
}
|
14
MsiUseFeature/MsiUseFeature.props
Normal file
14
MsiUseFeature/MsiUseFeature.props
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir>..\output\$(Platform).$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\lib\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
BIN
MsiUseFeature/MsiUseFeature.rc
Normal file
BIN
MsiUseFeature/MsiUseFeature.rc
Normal file
Binary file not shown.
106
MsiUseFeature/MsiUseFeature.vcxproj
Normal file
106
MsiUseFeature/MsiUseFeature.vcxproj
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{679D03C5-CD70-4FFA-93F8-A4AB3637509B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>MsiUseFeature</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\Win32.props" />
|
||||
<Import Project="..\include\Debug.props" />
|
||||
<Import Project="MsiUseFeature.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\x64.props" />
|
||||
<Import Project="..\include\Debug.props" />
|
||||
<Import Project="MsiUseFeature.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\Win32.props" />
|
||||
<Import Project="..\include\Release.props" />
|
||||
<Import Project="MsiUseFeature.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\include\x64.props" />
|
||||
<Import Project="..\include\Release.props" />
|
||||
<Import Project="MsiUseFeature.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MsiUseFeature.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
38
MsiUseFeature/MsiUseFeature.vcxproj.filters
Normal file
38
MsiUseFeature/MsiUseFeature.vcxproj.filters
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MsiUseFeature.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
17
MsiUseFeature/README.md
Normal file
17
MsiUseFeature/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
#MsiUseFeature
|
||||
Checks the installation state of the given feature of G<>ANTLink product
|
||||
|
||||
##Usage
|
||||
```
|
||||
MsiUseFeature <feature name>
|
||||
```
|
||||
|
||||
- `feature name` - The name of the feature to check (i.e. "featEAPTTLS"; see Feature table of product MSI file)
|
||||
|
||||
Note: The MSI product code changes on every release. Therefore, `MsiUseFeature` utility with identical version should be used.
|
||||
|
||||
Return codes:
|
||||
- -1 = Invalid parameters
|
||||
- 0 = Success
|
||||
- 1 = The product is not installed or feature state is unknown
|
||||
- 2 = The feature is not installed locally
|
21
MsiUseFeature/StdAfx.cpp
Normal file
21
MsiUseFeature/StdAfx.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
32
MsiUseFeature/StdAfx.h
Normal file
32
MsiUseFeature/StdAfx.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/Version.h"
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <Msi.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <memory>
|
114
VS10Solution.sln
114
VS10Solution.sln
@@ -18,10 +18,30 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CredWrite", "CredWrite\CredWrite.vcxproj", "{2D3CE079-7EB1-4F47-B79E-F0310671ECCB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPMethodEvents", "EAPMethods\EAPMethodEvents\EAPMethodEvents.vcxproj", "{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Events", "lib\Events\build\Events.vcxproj", "{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPTTLSUI", "EAPMethods\EAPTTLSUI\EAPTTLSUI.vcxproj", "{DD7A97CA-F18E-43B7-95C4-D06E6A291624}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPBase", "lib\EAPBase\build\EAPBase.vcxproj", "{AD6816A0-9600-4E01-8C49-39D03D1E791F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPBase_UI", "lib\EAPBase_UI\build\EAPBase_UI.vcxproj", "{D4B54856-BE1F-4937-A8F7-495125BE76BE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PAP", "lib\PAP\build\PAP.vcxproj", "{36B0CF8A-7794-46C3-8099-825BA962B4C7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLS", "lib\TLS\build\TLS.vcxproj", "{4D40CB8A-812E-4F12-B23A-31AF743878E8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTLS", "lib\TTLS\build\TTLS.vcxproj", "{EE0EF0D9-A475-4038-8637-5754724F65B0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PAP_UI", "lib\PAP_UI\build\PAP_UI.vcxproj", "{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLS_UI", "lib\TLS_UI\build\TLS_UI.vcxproj", "{9A25C261-8ADE-4938-8393-E857EF0E37E9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTLS_UI", "lib\TTLS_UI\build\TTLS_UI.vcxproj", "{42F0F0F4-C928-4860-A4E4-94991C2C3D90}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MsiUseFeature", "MsiUseFeature\MsiUseFeature.vcxproj", "{679D03C5-CD70-4FFA-93F8-A4AB3637509B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EventMonitor", "EventMonitor\EventMonitor.vcxproj", "{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@@ -70,15 +90,105 @@ Global
|
||||
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|Win32.Build.0 = Release|Win32
|
||||
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|x64.ActiveCfg = Release|x64
|
||||
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|x64.Build.0 = Release|x64
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|x64.Build.0 = Debug|x64
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|Win32.Build.0 = Release|Win32
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|x64.ActiveCfg = Release|x64
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|x64.Build.0 = Release|x64
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|x64.Build.0 = Debug|x64
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|Win32.Build.0 = Release|Win32
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|x64.ActiveCfg = Release|x64
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|x64.Build.0 = Release|x64
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|x64.Build.0 = Debug|x64
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|Win32.Build.0 = Release|Win32
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|x64.ActiveCfg = Release|x64
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|x64.Build.0 = Release|x64
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|x64.Build.0 = Debug|x64
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|Win32.Build.0 = Release|Win32
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|x64.ActiveCfg = Release|x64
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|x64.Build.0 = Release|x64
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|x64.Build.0 = Debug|x64
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|Win32.Build.0 = Release|Win32
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|x64.ActiveCfg = Release|x64
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|x64.Build.0 = Release|x64
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|x64.Build.0 = Debug|x64
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|Win32.Build.0 = Release|Win32
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|x64.ActiveCfg = Release|x64
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|x64.Build.0 = Release|x64
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|x64.Build.0 = Debug|x64
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|Win32.Build.0 = Release|Win32
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|x64.ActiveCfg = Release|x64
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|x64.Build.0 = Release|x64
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|x64.Build.0 = Debug|x64
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|Win32.Build.0 = Release|Win32
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.ActiveCfg = Release|x64
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.Build.0 = Release|x64
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Debug|x64.Build.0 = Debug|x64
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|Win32.Build.0 = Release|Win32
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|x64.ActiveCfg = Release|x64
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B}.Release|x64.Build.0 = Release|x64
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Debug|x64.Build.0 = Debug|x64
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Release|Win32.Build.0 = Release|Win32
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Release|x64.ActiveCfg = Release|x64
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{331B6077-E3E2-4867-B93E-9D3F57280DE7} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C}
|
||||
{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C}
|
||||
{DD7A97CA-F18E-43B7-95C4-D06E6A291624} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C}
|
||||
{47399D91-7EB9-41DE-B521-514BA5DB0C43} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{AD6816A0-9600-4E01-8C49-39D03D1E791F} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{D4B54856-BE1F-4937-A8F7-495125BE76BE} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{36B0CF8A-7794-46C3-8099-825BA962B4C7} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{4D40CB8A-812E-4F12-B23A-31AF743878E8} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{EE0EF0D9-A475-4038-8637-5754724F65B0} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{3D309C2E-64AB-4BC4-A16D-468571A2BC1A} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{9A25C261-8ADE-4938-8393-E857EF0E37E9} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{42F0F0F4-C928-4860-A4E4-94991C2C3D90} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
|
||||
{2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
|
||||
{679D03C5-CD70-4FFA-93F8-A4AB3637509B} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
|
||||
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Binary file not shown.
@@ -29,7 +29,7 @@
|
||||
// Product version as a single DWORD
|
||||
// Note: Used for version comparison within C/C++ code.
|
||||
//
|
||||
#define PRODUCT_VERSION 0x00ff0300
|
||||
#define PRODUCT_VERSION 0x00ff0500
|
||||
|
||||
//
|
||||
// Product version by components
|
||||
@@ -39,26 +39,26 @@
|
||||
//
|
||||
#define PRODUCT_VERSION_MAJ 0
|
||||
#define PRODUCT_VERSION_MIN 255
|
||||
#define PRODUCT_VERSION_REV 3
|
||||
#define PRODUCT_VERSION_REV 5
|
||||
#define PRODUCT_VERSION_BUILD 0
|
||||
|
||||
//
|
||||
// Human readable product version and build year for UI
|
||||
//
|
||||
#define PRODUCT_VERSION_STR "1.0-alpha3"
|
||||
#define PRODUCT_VERSION_STR "1.0-alpha5"
|
||||
#define PRODUCT_BUILD_YEAR_STR "2016"
|
||||
|
||||
//
|
||||
// Numerical version presentation for ProductVersion propery in
|
||||
// MSI packages (syntax: N.N[.N[.N]])
|
||||
//
|
||||
#define PRODUCT_VERSION_INST "0.255.3"
|
||||
#define PRODUCT_VERSION_INST "0.255.5"
|
||||
|
||||
//
|
||||
// The product code for ProductCode property in MSI packages
|
||||
// Replace with new on every version change, regardless how minor it is.
|
||||
//
|
||||
#define PRODUCT_VERSION_GUID "{14FCBB4F-BA19-46D7-B881-CA5AE7F42991}"
|
||||
#define PRODUCT_VERSION_GUID "{4A006C27-4001-47C7-B0C2-2A16525A17C3}"
|
||||
|
||||
//
|
||||
// Since the product name is not finally confirmed at the time of
|
||||
|
2
lib/EAPBase/build/.gitignore
vendored
Normal file
2
lib/EAPBase/build/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/temp
|
||||
/*.user
|
12
lib/EAPBase/build/EAPBase.props
Normal file
12
lib/EAPBase/build/EAPBase.props
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
110
lib/EAPBase/build/EAPBase.vcxproj
Normal file
110
lib/EAPBase/build/EAPBase.vcxproj
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{AD6816A0-9600-4E01-8C49-39D03D1E791F}</ProjectGuid>
|
||||
<RootNamespace>EAPBase</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="EAPBase.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="EAPBase.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="EAPBase.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="EAPBase.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\Config.h" />
|
||||
<ClInclude Include="..\include\Credentials.h" />
|
||||
<ClInclude Include="..\include\EAP.h" />
|
||||
<ClInclude Include="..\include\EAPSerial.h" />
|
||||
<ClInclude Include="..\include\EAPXML.h" />
|
||||
<ClInclude Include="..\include\Module.h" />
|
||||
<ClInclude Include="..\include\Session.h" />
|
||||
<ClInclude Include="..\src\StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\Config.cpp" />
|
||||
<ClCompile Include="..\src\Credentials.cpp" />
|
||||
<ClCompile Include="..\src\Module.cpp" />
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
53
lib/EAPBase/build/EAPBase.vcxproj.filters
Normal file
53
lib/EAPBase/build/EAPBase.vcxproj.filters
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAP.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAPSerial.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAPXML.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Session.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Module.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Credentials.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Credentials.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Module.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
1075
lib/EAPBase/include/Config.h
Normal file
1075
lib/EAPBase/include/Config.h
Normal file
File diff suppressed because it is too large
Load Diff
409
lib/EAPBase/include/Credentials.h
Normal file
409
lib/EAPBase/include/Credentials.h
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sal.h>
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// Base class for method credential storage
|
||||
///
|
||||
class credentials;
|
||||
|
||||
///
|
||||
/// Password based method credentials
|
||||
///
|
||||
class credentials_pass;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a method credentials
|
||||
///
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::credentials &val);
|
||||
|
||||
///
|
||||
/// Unpacks a method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Credentials to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val);
|
||||
|
||||
///
|
||||
/// Packs a password based method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a password based method credentials
|
||||
///
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::credentials_pass &val);
|
||||
|
||||
///
|
||||
/// Unpacks a password based method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Credentials to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Config.h"
|
||||
#include "Module.h"
|
||||
#include "EAPSerial.h"
|
||||
|
||||
#include "../../../include/Version.h"
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <eaptypes.h> // Must include after <Windows.h>
|
||||
#include <tchar.h>
|
||||
#include <wincred.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class credentials : public config
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs credentials
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
credentials(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
credentials(_In_ const credentials &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
credentials(_Inout_ credentials &&other);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials& operator=(_In_ const credentials &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials& operator=(_Inout_ credentials &&other);
|
||||
|
||||
///
|
||||
/// Resets credentials
|
||||
///
|
||||
virtual void clear();
|
||||
|
||||
///
|
||||
/// Test credentials if blank
|
||||
///
|
||||
virtual bool empty() const;
|
||||
|
||||
/// \name XML configuration management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save credentials to XML document
|
||||
///
|
||||
/// \param[in] pDoc XML document
|
||||
/// \param[in] pConfigRoot Suggested root element for saving credentials
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Load credentials from XML document
|
||||
///
|
||||
/// \param[in] pConfigRoot Root element for loading credentials
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save credentials to Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const = 0;
|
||||
|
||||
///
|
||||
/// Retrieve credentials from Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Return target suffix for Windows Credential Manager credential name
|
||||
///
|
||||
virtual LPCTSTR target_suffix() const = 0;
|
||||
|
||||
///
|
||||
/// Returns target name for Windows Credential Manager credential name
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from
|
||||
///
|
||||
/// \returns Final target name to store/retrieve credentials in Windows Credential Manager
|
||||
///
|
||||
inline winstd::tstring target_name(_In_ LPCTSTR pszTargetName) const
|
||||
{
|
||||
winstd::tstring target_name(_T(PRODUCT_NAME_STR) _T("/"));
|
||||
target_name += pszTargetName;
|
||||
target_name += _T('/');
|
||||
target_name += target_suffix();
|
||||
assert(target_name.length() < CRED_MAX_GENERIC_TARGET_NAME_LENGTH);
|
||||
return target_name;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
std::wstring m_identity; ///< Identity (username\@domain, certificate name etc.)
|
||||
};
|
||||
|
||||
|
||||
class credentials_pass : public credentials
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs credentials
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
credentials_pass(_In_ module &mod);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
credentials_pass(_In_ const credentials_pass &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
credentials_pass(_Inout_ credentials_pass &&other);
|
||||
|
||||
///
|
||||
/// Copies credentials
|
||||
///
|
||||
/// \param[in] other Credentials to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_pass& operator=(_In_ const credentials_pass &other);
|
||||
|
||||
///
|
||||
/// Moves credentials
|
||||
///
|
||||
/// \param[in] other Credentials to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
credentials_pass& operator=(_Inout_ credentials_pass &&other);
|
||||
|
||||
///
|
||||
/// Resets credentials
|
||||
///
|
||||
virtual void clear();
|
||||
|
||||
///
|
||||
/// Test credentials if blank
|
||||
///
|
||||
virtual bool empty() const;
|
||||
|
||||
/// \name XML configuration management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save credentials to XML document
|
||||
///
|
||||
/// \param[in] pDoc XML document
|
||||
/// \param[in] pConfigRoot Suggested root element for saving credentials
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Load credentials from XML document
|
||||
///
|
||||
/// \param[in] pConfigRoot Root element for loading credentials
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Save credentials to Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
///
|
||||
/// Retrieve credentials from Windows Credential Manager
|
||||
///
|
||||
/// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError);
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
winstd::sanitizing_wstring m_password; ///< Password
|
||||
|
||||
private:
|
||||
/// \cond internal
|
||||
static const unsigned char s_entropy[1024];
|
||||
/// \endcond
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val)
|
||||
{
|
||||
pack(cursor, val.m_identity);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::credentials &val)
|
||||
{
|
||||
return get_pk_size(val.m_identity);
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val)
|
||||
{
|
||||
unpack(cursor, val.m_identity);
|
||||
}
|
||||
|
||||
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val)
|
||||
{
|
||||
pack(cursor, (const eap::credentials&)val);
|
||||
pack(cursor, val.m_password );
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::credentials_pass &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::credentials&)val) +
|
||||
get_pk_size(val.m_password );
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val)
|
||||
{
|
||||
unpack(cursor, (eap::credentials&)val);
|
||||
unpack(cursor, val.m_password );
|
||||
}
|
||||
}
|
107
lib/EAPBase/include/EAP.h
Normal file
107
lib/EAPBase/include/EAP.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define IDR_EAP_KEY_PUBLIC 1
|
||||
#define IDR_EAP_KEY_PRIVATE 2
|
||||
|
||||
#if !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
||||
|
||||
#include <sal.h>
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// EAP method numbers
|
||||
///
|
||||
/// \sa [Extensible Authentication Protocol (EAP) Registry (Chapter: Method Types)](https://www.iana.org/assignments/eap-numbers/eap-numbers.xhtml#eap-numbers-4)
|
||||
///
|
||||
enum type_t;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs an EAP method type
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val EAP method type to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::type_t &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of an EAP method type
|
||||
///
|
||||
/// \param[in] val EAP method type to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::type_t &val);
|
||||
|
||||
///
|
||||
/// Unpacks an EAP method type
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val EAP method type to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::type_t &val);
|
||||
}
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "EAPSerial.h"
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
enum type_t {
|
||||
type_undefined = 0, ///< Undefined EAP type
|
||||
type_tls = 13, ///< EAP-TLS
|
||||
type_ttls = 21, ///< EAP-TTLS
|
||||
type_peap = 25, ///< EAP-PEAP
|
||||
type_mschapv2 = 26, ///< EAP-MSCHAPv2
|
||||
type_pap = 192, ///< PAP (Not actually an EAP method; Moved to the Unassigned area)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::type_t &val)
|
||||
{
|
||||
pack(cursor, (unsigned char)val);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(_In_ const eap::type_t &val)
|
||||
{
|
||||
return get_pk_size((unsigned char)val);
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::type_t &val)
|
||||
{
|
||||
unsigned char t;
|
||||
unpack(cursor, t);
|
||||
val = (eap::type_t)t;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -20,40 +20,12 @@
|
||||
|
||||
#include <WinStd/Crypt.h>
|
||||
|
||||
#include <sal.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
template <class T> inline void pack(_Inout_ unsigned char *&cursor, _In_ const T &val);
|
||||
template <class T> inline size_t get_pk_size(_In_ const T &val);
|
||||
template <class T> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ T &val);
|
||||
|
||||
template<class _Elem, class _Traits, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val);
|
||||
template<class _Elem, class _Traits, class _Ax> inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val);
|
||||
template<class _Elem, class _Traits, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val);
|
||||
|
||||
template<class _Traits, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val);
|
||||
template<class _Traits, class _Ax> inline size_t get_pk_size(const std::basic_string<wchar_t, _Traits, _Ax> &val);
|
||||
template<class _Traits, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val);
|
||||
|
||||
template<class _Ty, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::vector<_Ty, _Ax> &val);
|
||||
template<class _Ty, class _Ax> inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val);
|
||||
template<class _Ty, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::vector<_Ty, _Ax> &val);
|
||||
|
||||
template<class _Ty, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::list<_Ty, _Ax> &val);
|
||||
template<class _Ty, class _Ax> inline size_t get_pk_size(const std::list<_Ty, _Ax> &val);
|
||||
template<class _Ty, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::list<_Ty, _Ax> &val);
|
||||
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const winstd::cert_context &val);
|
||||
inline size_t get_pk_size(const winstd::cert_context &val);
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ winstd::cert_context &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
@@ -62,13 +34,7 @@ namespace eapserial
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Variable with data to pack
|
||||
///
|
||||
template <class T>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const T &val)
|
||||
{
|
||||
memcpy(cursor, &val, sizeof(T));
|
||||
cursor += sizeof(T);
|
||||
}
|
||||
|
||||
template <class T> inline void pack(_Inout_ unsigned char *&cursor, _In_ const T &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a primitive data
|
||||
@@ -77,6 +43,155 @@ namespace eapserial
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template <class T> inline size_t get_pk_size(_In_ const T &val);
|
||||
|
||||
///
|
||||
/// Unpacks a primitive data
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Variable to receive unpacked value
|
||||
///
|
||||
template <class T> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ T &val);
|
||||
|
||||
///
|
||||
/// Packs a string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a string
|
||||
///
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax> inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Unpacks a string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val String to unpack to
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Packs a wide string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
template<class _Traits, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a wide string
|
||||
///
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Traits, class _Ax> inline size_t get_pk_size(const std::basic_string<wchar_t, _Traits, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Unpacks a wide string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val String to unpack to
|
||||
///
|
||||
template<class _Traits, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Packs a vector
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Vector to pack
|
||||
///
|
||||
template<class _Ty, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::vector<_Ty, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a vector
|
||||
///
|
||||
/// \param[in] val Vector to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Ty, class _Ax> inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Unpacks a vector
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Vector to unpack to
|
||||
///
|
||||
template<class _Ty, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::vector<_Ty, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Packs a list
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val List to pack
|
||||
///
|
||||
template<class _Ty, class _Ax> inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::list<_Ty, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a list
|
||||
///
|
||||
/// \param[in] val List to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Ty, class _Ax> inline size_t get_pk_size(const std::list<_Ty, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Unpacks a list
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val List to unpack to
|
||||
///
|
||||
template<class _Ty, class _Ax> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::list<_Ty, _Ax> &val);
|
||||
|
||||
///
|
||||
/// Packs a certificate context
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Certificate context to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const winstd::cert_context &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a certificate context
|
||||
///
|
||||
/// \param[in] val Certificate context to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const winstd::cert_context &val);
|
||||
|
||||
///
|
||||
/// Unpacks a certificate context
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Certificate context to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ winstd::cert_context &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
template <class T>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const T &val)
|
||||
{
|
||||
memcpy(cursor, &val, sizeof(T));
|
||||
cursor += sizeof(T);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline size_t get_pk_size(_In_ const T &val)
|
||||
{
|
||||
@@ -85,12 +200,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a primitive data
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Variable to receive unpacked value
|
||||
///
|
||||
template <class T>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ T &val)
|
||||
{
|
||||
@@ -99,12 +208,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs a string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val)
|
||||
{
|
||||
@@ -118,13 +221,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a string
|
||||
///
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val)
|
||||
{
|
||||
@@ -132,12 +228,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val String to unpack to
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val)
|
||||
{
|
||||
@@ -149,12 +239,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs a wide string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val)
|
||||
{
|
||||
@@ -164,26 +248,13 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a wide string
|
||||
///
|
||||
/// \param[in] val String to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
inline size_t get_pk_size(const std::basic_string<wchar_t, _Traits, _Ax> &val)
|
||||
{
|
||||
return sizeof(std::string::size_type) + sizeof(char)*WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), NULL, 0, NULL, NULL);
|
||||
return sizeof(std::string::size_type) + WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), NULL, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a wide string
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val String to unpack to
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val)
|
||||
{
|
||||
@@ -193,12 +264,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs a vector
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Vector to pack
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::vector<_Ty, _Ax> &val)
|
||||
{
|
||||
@@ -213,13 +278,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a vector
|
||||
///
|
||||
/// \param[in] val Vector to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val)
|
||||
{
|
||||
@@ -232,12 +290,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a vector
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Vector to unpack to
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::vector<_Ty, _Ax> &val)
|
||||
{
|
||||
@@ -256,12 +308,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs a list
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val List to pack
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::list<_Ty, _Ax> &val)
|
||||
{
|
||||
@@ -276,13 +322,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a list
|
||||
///
|
||||
/// \param[in] val List to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
inline size_t get_pk_size(const std::list<_Ty, _Ax> &val)
|
||||
{
|
||||
@@ -295,12 +334,6 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a list
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val List to unpack to
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::list<_Ty, _Ax> &val)
|
||||
{
|
||||
@@ -318,44 +351,33 @@ namespace eapserial
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs a certificate context
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Certificate context to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const winstd::cert_context &val)
|
||||
{
|
||||
*(DWORD*&)cursor = val->dwCertEncodingType;
|
||||
cursor += sizeof(DWORD);
|
||||
if (val) {
|
||||
*(DWORD*&)cursor = val->dwCertEncodingType;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
*(DWORD*&)cursor = val->cbCertEncoded;
|
||||
cursor += sizeof(DWORD);
|
||||
*(DWORD*&)cursor = val->cbCertEncoded;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
memcpy(cursor, val->pbCertEncoded, val->cbCertEncoded);
|
||||
cursor += val->cbCertEncoded;
|
||||
memcpy(cursor, val->pbCertEncoded, val->cbCertEncoded);
|
||||
cursor += val->cbCertEncoded;
|
||||
} else {
|
||||
*(DWORD*&)cursor = 0;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
*(DWORD*&)cursor = 0;
|
||||
cursor += sizeof(DWORD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a certificate context
|
||||
///
|
||||
/// \param[in] val Certificate context to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const winstd::cert_context &val)
|
||||
{
|
||||
return sizeof(DWORD) + sizeof(DWORD) + val->cbCertEncoded;
|
||||
return sizeof(DWORD) + sizeof(DWORD) + (val ? val->cbCertEncoded : 0);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a certificate context
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Certificate context to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ winstd::cert_context &val)
|
||||
{
|
||||
DWORD dwCertEncodingType = *(DWORD*&)cursor;
|
||||
@@ -364,7 +386,10 @@ namespace eapserial
|
||||
DWORD dwCertEncodedSize = *(DWORD*&)cursor;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
val.create(dwCertEncodingType, (BYTE*)cursor, dwCertEncodedSize);
|
||||
cursor += dwCertEncodedSize;
|
||||
if (dwCertEncodedSize) {
|
||||
val.create(dwCertEncodingType, (BYTE*)cursor, dwCertEncodedSize);
|
||||
cursor += dwCertEncodedSize;
|
||||
} else
|
||||
val.free();
|
||||
}
|
||||
}
|
@@ -18,11 +18,9 @@
|
||||
along with GÉANTLink. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <WinStd/Base64.h>
|
||||
#include <WinStd/COM.h>
|
||||
#include <WinStd/Hex.h>
|
||||
#include <assert.h>
|
||||
#include <MsXml.h>
|
||||
#include <msxml6.h>
|
||||
#include <sal.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -54,6 +52,12 @@ namespace eapxml
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <WinStd/Base64.h>
|
||||
#include <WinStd/COM.h>
|
||||
#include <WinStd/Hex.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
namespace eapxml
|
||||
{
|
822
lib/EAPBase/include/Module.h
Normal file
822
lib/EAPBase/include/Module.h
Normal file
@@ -0,0 +1,822 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// EAP module base class
|
||||
///
|
||||
/// Provides basic services to EAP methods.
|
||||
///
|
||||
class module;
|
||||
|
||||
///
|
||||
/// EAP peer base class
|
||||
///
|
||||
/// A group of methods all EAP peers must or should implement.
|
||||
///
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres> class peer_base;
|
||||
|
||||
///
|
||||
/// EAP peer base class
|
||||
///
|
||||
/// A group of methods all EAP peers must or should implement.
|
||||
///
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres> class peer;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "EAP.h"
|
||||
|
||||
#include <WinStd/Crypt.h>
|
||||
#include <WinStd/ETW.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <eaptypes.h> // Must include after <Windows.h>
|
||||
#include <sal.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <EventsETW.h> // Must include after <Windows.h>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class module
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a module for the given EAP type
|
||||
///
|
||||
module(_In_ type_t eap_method);
|
||||
|
||||
///
|
||||
/// Destructs the module
|
||||
///
|
||||
virtual ~module();
|
||||
|
||||
/// \name Memory management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Allocate a EAP_ERROR and fill it according to dwErrorCode
|
||||
///
|
||||
EAP_ERROR* make_error(_In_ DWORD dwErrorCode, _In_opt_z_ LPCWSTR pszRootCauseString = NULL, _In_opt_z_ LPCWSTR pszRepairString = NULL, _In_opt_ DWORD dwReasonCode = 0, _In_opt_ LPCGUID pRootCauseGuid = NULL, _In_opt_ LPCGUID pRepairGuid = NULL, _In_opt_ LPCGUID pHelpLinkGuid = NULL) const;
|
||||
|
||||
///
|
||||
/// Allocate BLOB
|
||||
///
|
||||
BYTE* alloc_memory(_In_ size_t size);
|
||||
|
||||
///
|
||||
/// Free BLOB allocated with this peer
|
||||
///
|
||||
void free_memory(_In_ BYTE *ptr);
|
||||
|
||||
///
|
||||
/// Free EAP_ERROR allocated with `make_error()` method
|
||||
///
|
||||
void free_error_memory(_In_ EAP_ERROR *err);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Logging
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Writes EAPMETHOD_TRACE_EVT_FN_CALL and returns auto event writer class
|
||||
///
|
||||
/// \param[in] pszFnName Function name
|
||||
///
|
||||
/// \returns A new auto event writer that writes EAPMETHOD_TRACE_EVT_FN_RETURN event on destruction
|
||||
///
|
||||
inline winstd::event_fn_auto get_event_fn_auto(_In_z_ LPCSTR pszFnName) const
|
||||
{
|
||||
return winstd::event_fn_auto(m_ep, &EAPMETHOD_TRACE_EVT_FN_CALL, &EAPMETHOD_TRACE_EVT_FN_RETURN, pszFnName);
|
||||
}
|
||||
|
||||
///
|
||||
/// Writes EAPMETHOD_TRACE_EVT_FN_CALL and returns auto event writer class
|
||||
///
|
||||
/// \param[in] pszFnName Function name
|
||||
///
|
||||
/// \returns A new auto event writer that writes EAPMETHOD_TRACE_EVT_FN_RETURN_DWORD event on destruction
|
||||
///
|
||||
inline winstd::event_fn_auto_ret<DWORD> get_event_fn_auto(_In_z_ LPCSTR pszFnName, _In_ DWORD &result) const
|
||||
{
|
||||
return winstd::event_fn_auto_ret<DWORD>(m_ep, &EAPMETHOD_TRACE_EVT_FN_CALL, &EAPMETHOD_TRACE_EVT_FN_RETURN_DWORD, pszFnName, result);
|
||||
}
|
||||
|
||||
///
|
||||
/// Logs error
|
||||
///
|
||||
void log_error(_In_ const EAP_ERROR *err) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Encryption
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Encrypts data
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data to encrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] enc Encrypted data
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
/// \param[out] hHash Handle of hashing object
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
bool encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash = NULL) const;
|
||||
|
||||
|
||||
///
|
||||
/// Encrypts a string
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] val String to encrypt
|
||||
/// \param[out] enc Encrypted data
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
/// \param[out] hHash Handle of hashing object
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
bool encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash = NULL) const
|
||||
{
|
||||
return encrypt(hProv, val.c_str(), val.length()*sizeof(_Elem), enc, ppEapError, hHash);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Encrypts a wide string
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] val String to encrypt
|
||||
/// \param[out] enc Encrypted data
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
/// \param[out] hHash Handle of hashing object
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
bool encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash = NULL) const
|
||||
{
|
||||
winstd::sanitizing_string val_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), val_utf8, NULL, NULL);
|
||||
return encrypt(hProv, val_utf8, enc, ppEapError, hHash);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Encrypts data and add MD5 hash for integrity check
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data to encrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] enc Encrypted data with 16B MD5 hash appended
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
bool encrypt_md5(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError) const;
|
||||
|
||||
|
||||
///
|
||||
/// Encrypts a string and add MD5 hash for integrity check
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] val String to encrypt
|
||||
/// \param[out] enc Encrypted data with 16B MD5 hash appended
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
bool encrypt_md5(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
return encrypt_md5(hProv, val.c_str(), val.length()*sizeof(_Elem), enc, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Encrypts a wide string and add MD5 hash for integrity check
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] val String to encrypt
|
||||
/// \param[out] enc Encrypted data with 16B MD5 hash appended
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
bool encrypt_md5(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
winstd::sanitizing_string val_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), val_utf8, NULL, NULL);
|
||||
return encrypt_md5(hProv, val_utf8, enc, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Decrypts data
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data to decrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] dec Decrypted data
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
/// \param[out] hHash Handle of hashing object
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
bool decrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::vector<_Ty, _Ax> &dec, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash = NULL) const
|
||||
{
|
||||
assert(ppEapError);
|
||||
|
||||
// Import the private RSA key.
|
||||
HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PRIVATE), RT_RCDATA);
|
||||
assert(res);
|
||||
HGLOBAL res_handle = LoadResource(m_instance, res);
|
||||
assert(res_handle);
|
||||
crypt_key key_rsa;
|
||||
unique_ptr<unsigned char[], LocalFree_delete<unsigned char[]> > keyinfo_data;
|
||||
DWORD keyinfo_size = 0;
|
||||
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, PKCS_RSA_PRIVATE_KEY, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."));
|
||||
return false;
|
||||
}
|
||||
if (!key_rsa.import(hProv, keyinfo_data.get(), keyinfo_size, NULL, 0)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" Private key import failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Import the 256-bit AES session key.
|
||||
crypt_key key_aes;
|
||||
if (!CryptImportKey(hProv, (LPCBYTE)data, 268, key_rsa, 0, &key_aes)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptImportKey failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decrypt the data using AES session key.
|
||||
vector<unsigned char, sanitizing_allocator<unsigned char> > buf;
|
||||
buf.assign((const unsigned char*)data + 268, (const unsigned char*)data + size);
|
||||
if (!CryptDecrypt(key_aes, hHash, TRUE, 0, buf)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptDecrypt failed."));
|
||||
return false;
|
||||
}
|
||||
dec.assign(buf.begin(), buf.end());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Decrypts a string
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data to decrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] dec Decrypted string
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
/// \param[out] hHash Handle of hashing object
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
bool decrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::basic_string<_Elem, _Traits, _Ax> &dec, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash = NULL) const
|
||||
{
|
||||
std::vector<_Elem, sanitizing_allocator<_Elem> > buf;
|
||||
if (!decrypt(hProv, data, size, buf, ppEapError, hHash))
|
||||
return false;
|
||||
dec.assign(buf.data(), buf.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Decrypts a wide string
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data to decrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] dec Decrypted string
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
/// \param[out] hHash Handle of hashing object
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
bool decrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &dec, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash = NULL) const
|
||||
{
|
||||
winstd::sanitizing_string buf;
|
||||
if (!decrypt(hProv, data, size, buf, ppEapError, hHash))
|
||||
return false;
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf.data(), (int)buf.size(), dec);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Decrypts data with MD5 integrity check
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data with 16B MD5 hash appended to decrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] dec Decrypted data
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Ty, class _Ax>
|
||||
bool decrypt_md5(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::vector<_Ty, _Ax> &dec, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
// Create hash.
|
||||
crypt_hash hash;
|
||||
if (!hash.create(hProv, CALG_MD5)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" Creating MD5 hash failed."));
|
||||
return false;
|
||||
}
|
||||
DWORD dwHashSize, dwHashSizeSize = sizeof(dwHashSize);
|
||||
CryptGetHashParam(hash, HP_HASHSIZE, (LPBYTE)&dwHashSize, &dwHashSizeSize, 0);
|
||||
if (size < dwHashSize) {
|
||||
*ppEapError = make_error(ERROR_INVALID_DATA, _T(__FUNCTION__) _T(" Encrypted data too short."));
|
||||
return false;
|
||||
}
|
||||
size_t enc_size = size - dwHashSize;
|
||||
|
||||
// Decrypt data.
|
||||
if (!decrypt(hProv, data, enc_size, dec, ppEapError, hash))
|
||||
return false;
|
||||
|
||||
// Calculate MD5 hash and verify it.
|
||||
vector<unsigned char> hash_bin;
|
||||
if (!CryptGetHashParam(hash, HP_HASHVAL, hash_bin, 0)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" Calculating MD5 hash failed."));
|
||||
return false;
|
||||
}
|
||||
if (memcmp((unsigned char*)data + enc_size, hash_bin.data(), dwHashSize) != 0) {
|
||||
*ppEapError = make_error(ERROR_INVALID_DATA, _T(__FUNCTION__) _T(" Invalid encrypted data."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Decrypts a string with MD5 integrity check
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data with 16B MD5 hash appended to decrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] dec Decrypted string
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
bool decrypt_md5(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::basic_string<_Elem, _Traits, _Ax> &dec, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
std::vector<_Elem, sanitizing_allocator<_Elem> > buf;
|
||||
if (!decrypt_md5(hProv, data, size, buf, ppEapError))
|
||||
return false;
|
||||
dec.assign(buf.data(), buf.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Decrypts a wide string with MD5 integrity check
|
||||
///
|
||||
/// \param[in ] hProv Handle of cryptographics provider
|
||||
/// \param[in ] data Pointer to data with 16B MD5 hash appended to decrypt
|
||||
/// \param[in ] size Size of \p data in bytes
|
||||
/// \param[out] dec Decrypted string
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class _Traits, class _Ax>
|
||||
bool decrypt_md5(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &dec, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
winstd::sanitizing_string buf;
|
||||
if (!decrypt_md5(hProv, data, size, buf, ppEapError))
|
||||
return false;
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf.data(), (int)buf.size(), dec);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Unencrypts and unpacks the BLOB
|
||||
///
|
||||
/// \param[inout] record Object to unpack to
|
||||
/// \param[in ] pDataIn Pointer to encrypted BLOB
|
||||
/// \param[in ] dwDataInSize Size of \p pDataIn
|
||||
/// \param[out ] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class T>
|
||||
bool unpack(
|
||||
_Inout_ T &record,
|
||||
_In_count_(dwDataInSize) const BYTE *pDataIn,
|
||||
_In_ DWORD dwDataInSize,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
#if 1
|
||||
// Prepare cryptographics provider.
|
||||
winstd::crypt_prov cp;
|
||||
if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptAcquireContext failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decrypt data.
|
||||
vector<unsigned char, sanitizing_allocator<unsigned char> > data;
|
||||
if (!decrypt_md5(cp, pDataIn, dwDataInSize, data, ppEapError))
|
||||
return false;
|
||||
|
||||
const unsigned char *cursor = data.data();
|
||||
eapserial::unpack(cursor, record);
|
||||
assert(cursor - data.data() <= (ptrdiff_t)data.size());
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
const unsigned char *cursor = pDataIn;
|
||||
eapserial::unpack(cursor, record);
|
||||
assert(cursor - pDataIn <= (ptrdiff_t)dwDataInSize);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Packs and encrypts to the BLOB
|
||||
///
|
||||
/// \param[in ] record Object to pack
|
||||
/// \param[out] ppDataOut Pointer to pointer to receive encrypted BLOB. Pointer must be freed using `module::free_memory()`.
|
||||
/// \param[out] pdwDataOutSize Pointer to \p ppDataOut size
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
template<class T>
|
||||
bool pack(
|
||||
_In_ const T &record,
|
||||
_Out_ BYTE **ppDataOut,
|
||||
_Out_ DWORD *pdwDataOutSize,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
#if 1
|
||||
// Allocate BLOB.
|
||||
std::vector<unsigned char, winstd::sanitizing_allocator<unsigned char> > data;
|
||||
data.resize(eapserial::get_pk_size(record));
|
||||
|
||||
// Pack to BLOB.
|
||||
unsigned char *cursor = data.data();
|
||||
eapserial::pack(cursor, record);
|
||||
data.resize(cursor - data.data());
|
||||
|
||||
// Prepare cryptographics provider.
|
||||
winstd::crypt_prov cp;
|
||||
if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptAcquireContext failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Encrypt BLOB.
|
||||
std::vector<unsigned char> data_enc;
|
||||
if (!encrypt_md5(cp, data.data(), data.size(), data_enc, ppEapError))
|
||||
return false;
|
||||
|
||||
// Copy encrypted BLOB to output.
|
||||
assert(ppDataOut);
|
||||
assert(pdwDataOutSize);
|
||||
*pdwDataOutSize = (DWORD)data_enc.size();
|
||||
*ppDataOut = alloc_memory(*pdwDataOutSize);
|
||||
if (!*ppDataOut) {
|
||||
log_error(*ppEapError = g_peer.make_error(ERROR_OUTOFMEMORY, tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for BLOB (%uB)."), *pdwDataOutSize).c_str()));
|
||||
return false;
|
||||
}
|
||||
memcpy(*ppDataOut, data_enc.data(), *pdwDataOutSize);
|
||||
#else
|
||||
// Allocate BLOB.
|
||||
assert(ppDataOut);
|
||||
assert(pdwDataOutSize);
|
||||
*pdwDataOutSize = (DWORD)eapserial::get_pk_size(record);
|
||||
*ppDataOut = alloc_memory(*pdwDataOutSize);
|
||||
if (!*ppDataOut) {
|
||||
log_error(*ppEapError = g_peer.make_error(ERROR_OUTOFMEMORY, tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for BLOB (%uB)."), *pdwDataOutSize).c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pack to BLOB.
|
||||
unsigned char *cursor = *ppDataOut;
|
||||
eapserial::pack(cursor, record);
|
||||
assert(cursor - *ppDataOut <= (ptrdiff_t)*pdwDataOutSize);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
HINSTANCE m_instance; ///< Windows module instance
|
||||
const type_t m_eap_method; ///< EAP method type
|
||||
|
||||
protected:
|
||||
winstd::heap m_heap; ///< Heap
|
||||
mutable winstd::event_provider m_ep; ///< Event Provider
|
||||
};
|
||||
|
||||
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres>
|
||||
class peer_base : public module
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Provider configuration data type
|
||||
///
|
||||
typedef config_provider<_Tcfg> provider_config_type;
|
||||
|
||||
///
|
||||
/// Configuration data type
|
||||
///
|
||||
typedef config_providers<provider_config_type> config_type;
|
||||
|
||||
///
|
||||
/// Identity data type
|
||||
///
|
||||
typedef _Tid identity_type;
|
||||
|
||||
///
|
||||
/// Interactive request data type
|
||||
///
|
||||
typedef _Tint interactive_request_type;
|
||||
|
||||
///
|
||||
/// Interactive response data type
|
||||
///
|
||||
typedef _Tintres interactive_response_type;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs a EAP peer module for the given EAP type
|
||||
///
|
||||
peer_base(_In_ type_t eap_method) : module(eap_method) {}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres>
|
||||
class peer : public peer_base<_Tcfg, _Tid, _Tint, _Tintres>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a EAP peer module for the given EAP type
|
||||
///
|
||||
peer(_In_ type_t eap_method) : peer_base<_Tcfg, _Tid, _Tint, _Tintres>(eap_method) {}
|
||||
|
||||
///
|
||||
/// Initializes an EAP peer method for EAPHost.
|
||||
///
|
||||
/// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool initialize(_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Shuts down the EAP method and prepares to unload its corresponding DLL.
|
||||
///
|
||||
/// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool shutdown(_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Returns the user data and user identity after being called by EAPHost.
|
||||
///
|
||||
/// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool get_identity(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ const config_type &cfg,
|
||||
_Inout_ identity_type &usr,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_Out_ BOOL *pfInvokeUI,
|
||||
_Out_ WCHAR **ppwszIdentity,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Defines the implementation of an EAP method-specific function that retrieves the properties of an EAP method given the connection and user data.
|
||||
///
|
||||
/// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool get_method_properties(
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ HANDLE hUserImpersonationToken,
|
||||
_In_ const config_type &cfg,
|
||||
_In_ const identity_type &usr,
|
||||
_Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray,
|
||||
_Out_ EAP_ERROR **ppEapError) const = 0;
|
||||
|
||||
///
|
||||
/// Defines the implementation of an EAP method-specific function that obtains the EAP Single-Sign-On (SSO) credential input fields for an EAP method.
|
||||
///
|
||||
/// \sa [EapPeerQueryCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363622.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool query_credential_input_fields(
|
||||
_In_ HANDLE hUserImpersonationToken,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwEapConnDataSize,
|
||||
_In_count_(dwEapConnDataSize) const BYTE *pEapConnData,
|
||||
_Out_ EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldsArray,
|
||||
_Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hUserImpersonationToken);
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(dwEapConnDataSize);
|
||||
UNREFERENCED_PARAMETER(pEapConnData);
|
||||
UNREFERENCED_PARAMETER(pEapConfigInputFieldsArray);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
*ppEapError = make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Defines the implementation of an EAP method function that obtains the user BLOB data provided in an interactive Single-Sign-On (SSO) UI raised on the supplicant.
|
||||
///
|
||||
/// \sa [EapPeerQueryUserBlobFromCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204697.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool query_user_blob_from_credential_input_fields(
|
||||
_In_ HANDLE hUserImpersonationToken,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwEapConnDataSize,
|
||||
_In_count_(dwEapConnDataSize) const BYTE *pEapConnData,
|
||||
_In_ const EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldArray,
|
||||
_Inout_ DWORD *pdwUsersBlobSize,
|
||||
_Inout_ BYTE **ppUserBlob,
|
||||
_Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hUserImpersonationToken);
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(dwEapConnDataSize);
|
||||
UNREFERENCED_PARAMETER(pEapConnData);
|
||||
UNREFERENCED_PARAMETER(pEapConfigInputFieldArray);
|
||||
UNREFERENCED_PARAMETER(pdwUsersBlobSize);
|
||||
UNREFERENCED_PARAMETER(ppUserBlob);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
*ppEapError = make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Defines the implementation of an EAP method API that provides the input fields for interactive UI components to be raised on the supplicant.
|
||||
///
|
||||
/// \sa [EapPeerQueryInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204695.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool query_interactive_ui_input_fields(
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwUIContextDataSize,
|
||||
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
|
||||
_Out_ EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData,
|
||||
_Out_ EAP_ERROR **ppEapError,
|
||||
_Inout_ LPVOID *pvReserved) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwVersion);
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(dwUIContextDataSize);
|
||||
UNREFERENCED_PARAMETER(pUIContextData);
|
||||
UNREFERENCED_PARAMETER(pEapInteractiveUIData);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
UNREFERENCED_PARAMETER(pvReserved);
|
||||
|
||||
*ppEapError = make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
///
|
||||
/// Converts user information into a user BLOB that can be consumed by EAPHost run-time functions.
|
||||
///
|
||||
/// \sa [EapPeerQueryUIBlobFromInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204696.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool query_ui_blob_from_interactive_ui_input_fields(
|
||||
_In_ DWORD dwVersion,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ DWORD dwUIContextDataSize,
|
||||
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
|
||||
_In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData,
|
||||
_Out_ DWORD *pdwDataFromInteractiveUISize,
|
||||
_Out_ BYTE **ppDataFromInteractiveUI,
|
||||
_Out_ EAP_ERROR **ppEapError,
|
||||
_Inout_ LPVOID *ppvReserved) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwVersion);
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(dwUIContextDataSize);
|
||||
UNREFERENCED_PARAMETER(pUIContextData);
|
||||
UNREFERENCED_PARAMETER(pEapInteractiveUIData);
|
||||
UNREFERENCED_PARAMETER(pdwDataFromInteractiveUISize);
|
||||
UNREFERENCED_PARAMETER(ppDataFromInteractiveUI);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
UNREFERENCED_PARAMETER(ppvReserved);
|
||||
|
||||
*ppEapError = make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
367
lib/EAPBase/include/Session.h
Normal file
367
lib/EAPBase/include/Session.h
Normal file
@@ -0,0 +1,367 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// EAP session
|
||||
///
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres> class session;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <eaptypes.h> // Must include after <Windows.h>
|
||||
extern "C" {
|
||||
#include <eapmethodpeerapis.h>
|
||||
}
|
||||
#include <sal.h>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres>
|
||||
class session
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Provider configuration data type
|
||||
///
|
||||
typedef config_provider<_Tcfg> provider_config_type;
|
||||
|
||||
///
|
||||
/// Configuration data type
|
||||
///
|
||||
typedef config_providers<provider_config_type> config_type;
|
||||
|
||||
///
|
||||
/// Identity data type
|
||||
///
|
||||
typedef _Tid identity_type;
|
||||
|
||||
///
|
||||
/// Interactive request data type
|
||||
///
|
||||
typedef _Tint interactive_request_type;
|
||||
|
||||
///
|
||||
/// Interactive response data type
|
||||
///
|
||||
typedef _Tintres interactive_response_type;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs a session
|
||||
///
|
||||
/// \param[in] mod Reference of the EAP module to use for global services
|
||||
///
|
||||
session(_In_ module &mod) :
|
||||
m_module(mod),
|
||||
m_cfg(mod),
|
||||
m_id(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copies session
|
||||
///
|
||||
/// \param[in] other Session to copy from
|
||||
///
|
||||
session(_In_ const session &other) :
|
||||
m_module(other.m_module),
|
||||
m_cfg(other.m_cfg),
|
||||
m_id(other.m_id)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Moves session
|
||||
///
|
||||
/// \param[in] other Session to move from
|
||||
///
|
||||
session(_Inout_ session &&other) :
|
||||
m_module(other.m_module),
|
||||
m_cfg(std::move(other.m_cfg)),
|
||||
m_id(std::move(other.m_id))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Copies session
|
||||
///
|
||||
/// \param[in] other Session to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
session& operator=(_In_ const session &other)
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
assert(std::addressof(m_module) ==std::addressof(other.m_module)); // Copy session within same module only!
|
||||
m_cfg = other.m_cfg;
|
||||
m_id = other.m_id;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Moves session
|
||||
///
|
||||
/// \param[in] other Session to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
session& operator=(_Inout_ session &&other)
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
assert(std::addressof(m_module) ==std::addressof(other.m_module)); // Move session within same module only!
|
||||
m_cfg = std::move(other.m_cfg);
|
||||
m_id = std::move(other.m_id);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// \name Session start/end
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Starts an EAP authentication session on the peer EAPHost using the EAP method.
|
||||
///
|
||||
/// \sa [EapPeerBeginSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363600.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool begin(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ const EapAttributes *pAttributeArray,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_In_ DWORD dwMaxSendPacketSize,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwFlags);
|
||||
UNREFERENCED_PARAMETER(pAttributeArray);
|
||||
UNREFERENCED_PARAMETER(hTokenImpersonateUser);
|
||||
UNREFERENCED_PARAMETER(dwMaxSendPacketSize);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Ends an EAP authentication session for the EAP method.
|
||||
///
|
||||
/// \sa [EapPeerEndSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363604.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool end(_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Packet processing
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Processes a packet received by EAPHost from a supplicant.
|
||||
///
|
||||
/// \sa [EapPeerProcessRequestPacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363621.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool process_request_packet(
|
||||
_In_ DWORD dwReceivedPacketSize,
|
||||
_In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket,
|
||||
_Out_ EapPeerMethodOutput *pEapOutput,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwReceivedPacketSize);
|
||||
UNREFERENCED_PARAMETER(pReceivedPacket);
|
||||
UNREFERENCED_PARAMETER(pEapOutput);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Obtains a response packet from the EAP method.
|
||||
///
|
||||
/// \sa [EapPeerGetResponsePacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363610.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool get_response_packet(
|
||||
_Inout_ DWORD *pdwSendPacketSize,
|
||||
_Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pdwSendPacketSize);
|
||||
UNREFERENCED_PARAMETER(pSendPacket);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Obtains the result of an authentication session from the EAP method.
|
||||
///
|
||||
/// \sa [EapPeerGetResult function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363611.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool get_result(_In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(reason);
|
||||
UNREFERENCED_PARAMETER(ppResult);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name UI interaction
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Obtains the user interface context from the EAP method.
|
||||
///
|
||||
/// \note This function is always followed by the `EapPeerInvokeInteractiveUI()` function, which is followed by the `EapPeerSetUIContext()` function.
|
||||
///
|
||||
/// \sa [EapPeerGetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363612.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool get_ui_context(
|
||||
_Out_ interactive_request_type &req,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(req);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Provides a user interface context to the EAP method.
|
||||
///
|
||||
/// \note This function is called after the UI has been raised through the `EapPeerGetUIContext()` function.
|
||||
///
|
||||
/// \sa [EapPeerSetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363626.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool set_ui_context(
|
||||
_In_ const interactive_response_type &res,
|
||||
_In_ const EapPeerMethodOutput *pEapOutput,
|
||||
_Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(res);
|
||||
UNREFERENCED_PARAMETER(pEapOutput);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Response attributes
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Obtains an array of EAP response attributes from the EAP method.
|
||||
///
|
||||
/// \sa [EapPeerGetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363609.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool get_response_attributes(_Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pAttribs);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Provides an updated array of EAP response attributes to the EAP method.
|
||||
///
|
||||
/// \sa [EapPeerSetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363625.aspx)
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool set_response_attributes(const _In_ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(pAttribs);
|
||||
UNREFERENCED_PARAMETER(pEapOutput);
|
||||
assert(ppEapError);
|
||||
|
||||
*ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported."));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
module &m_module; ///< Reference of the EAP module
|
||||
config_type m_cfg; ///< Session configuration
|
||||
identity_type m_id; ///< User identity
|
||||
};
|
||||
}
|
62
lib/EAPBase/src/Config.cpp
Normal file
62
lib/EAPBase/src/Config.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::config
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config::config(_In_ module &mod) :
|
||||
m_module(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config::config(_In_ const config &other) :
|
||||
m_module(other.m_module)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config::config(_Inout_ config &&other) :
|
||||
m_module(other.m_module)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config& eap::config::operator=(_In_ const config &other)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(other);
|
||||
assert(&m_module == &other.m_module); // Copy configuration within same module only!
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config& eap::config::operator=(_Inout_ config &&other)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(other);
|
||||
assert(&m_module == &other.m_module); // Move configuration within same module only!
|
||||
return *this;
|
||||
}
|
358
lib/EAPBase/src/Credentials.cpp
Normal file
358
lib/EAPBase/src/Credentials.cpp
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#pragma comment(lib, "Crypt32.lib")
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials::credentials(_In_ module &mod) : config(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials::credentials(_In_ const credentials &other) :
|
||||
m_identity(other.m_identity),
|
||||
config(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials::credentials(_Inout_ credentials &&other) :
|
||||
m_identity(std::move(other.m_identity)),
|
||||
config(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials& eap::credentials::operator=(_In_ const credentials &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = other;
|
||||
m_identity = other.m_identity;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&)*this = std::move(other);
|
||||
m_identity = std::move(other.m_identity);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials::clear()
|
||||
{
|
||||
m_identity.clear();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials::empty() const
|
||||
{
|
||||
return m_identity.empty();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
|
||||
DWORD dwResult;
|
||||
|
||||
// <UserName>
|
||||
if ((dwResult = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"UserName"), bstrNamespace, bstr(m_identity))) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, _T(__FUNCTION__) _T(" Error creating <UserName> element."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pConfigRoot);
|
||||
DWORD dwResult;
|
||||
|
||||
if ((dwResult = eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:UserName"), m_identity)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, _T(__FUNCTION__) _T(" Error reading <UserName> element."), _T("Please make sure profile XML is a valid ") _T(PRODUCT_NAME_STR) _T(" profile XML document."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::credentials_pass
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::credentials_pass::credentials_pass(_In_ module &mod) : credentials(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass::credentials_pass(_In_ const credentials_pass &other) :
|
||||
m_password(other.m_password),
|
||||
credentials(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) :
|
||||
m_password(std::move(other.m_password)),
|
||||
credentials(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass& eap::credentials_pass::operator=(_In_ const credentials_pass &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = other;
|
||||
m_password = other.m_password;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(credentials&)*this = std::move(other);
|
||||
m_password = std::move(other.m_password);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_pass::clear()
|
||||
{
|
||||
credentials::clear();
|
||||
m_password.clear();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::empty() const
|
||||
{
|
||||
return credentials::empty() && m_password.empty();
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
|
||||
DWORD dwResult;
|
||||
|
||||
if (!credentials::save(pDoc, pConfigRoot, ppEapError))
|
||||
return false;
|
||||
|
||||
// <Password>
|
||||
bstr pass(m_password);
|
||||
dwResult = eapxml::put_element_value(pDoc, pConfigRoot, bstr(L"Password"), bstrNamespace, pass);
|
||||
SecureZeroMemory((BSTR)pass, sizeof(OLECHAR)*pass.length());
|
||||
if (dwResult != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, _T(__FUNCTION__) _T(" Error creating <Password> element."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pConfigRoot);
|
||||
DWORD dwResult;
|
||||
|
||||
if (!credentials::load(pConfigRoot, ppEapError))
|
||||
return false;
|
||||
|
||||
bstr pass;
|
||||
if ((dwResult = eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:Password"), &pass)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, _T(__FUNCTION__) _T(" Error reading <Password> element."), _T("Please make sure profile XML is a valid ") _T(PRODUCT_NAME_STR) _T(" profile XML document."));
|
||||
return false;
|
||||
}
|
||||
m_password = pass;
|
||||
SecureZeroMemory((BSTR)pass, sizeof(OLECHAR)*pass.length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
assert(pszTargetName);
|
||||
assert(ppEapError);
|
||||
|
||||
// Convert password to UTF-8.
|
||||
sanitizing_string cred_utf8;
|
||||
WideCharToMultiByte(CP_UTF8, 0, m_password.c_str(), (int)m_password.length(), cred_utf8, NULL, NULL);
|
||||
|
||||
// Encrypt the password using user's key.
|
||||
DATA_BLOB cred_blob = { (DWORD)cred_utf8.size() , (LPBYTE)cred_utf8.data() };
|
||||
DATA_BLOB entropy_blob = { sizeof(s_entropy), (LPBYTE)s_entropy };
|
||||
data_blob cred_enc;
|
||||
if (!CryptProtectData(&cred_blob, NULL, &entropy_blob, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &cred_enc)) {
|
||||
*ppEapError = m_module.make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptProtectData failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
tstring target(target_name(pszTargetName));
|
||||
|
||||
// Write credentials.
|
||||
assert(cred_enc.cbData < CRED_MAX_CREDENTIAL_BLOB_SIZE);
|
||||
assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH );
|
||||
CREDENTIAL cred = {
|
||||
0, // Flags
|
||||
CRED_TYPE_GENERIC, // Type
|
||||
(LPTSTR)target.c_str(), // TargetName
|
||||
_T(""), // Comment
|
||||
{ 0, 0 }, // LastWritten
|
||||
cred_enc.cbData, // CredentialBlobSize
|
||||
cred_enc.pbData, // CredentialBlob
|
||||
CRED_PERSIST_ENTERPRISE, // Persist
|
||||
0, // AttributeCount
|
||||
NULL, // Attributes
|
||||
NULL, // TargetAlias
|
||||
(LPTSTR)m_identity.c_str() // UserName
|
||||
};
|
||||
if (!CredWrite(&cred, 0)) {
|
||||
*ppEapError = m_module.make_error(GetLastError(), _T(__FUNCTION__) _T(" CredWrite failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pszTargetName);
|
||||
|
||||
// Read credentials.
|
||||
unique_ptr<CREDENTIAL, CredFree_delete<CREDENTIAL> > cred;
|
||||
if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
*ppEapError = m_module.make_error(GetLastError(), _T(__FUNCTION__) _T(" CredRead failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decrypt the password using user's key.
|
||||
DATA_BLOB cred_enc = { cred->CredentialBlobSize, cred->CredentialBlob };
|
||||
DATA_BLOB entropy_blob = { sizeof(s_entropy) , (LPBYTE)s_entropy };
|
||||
data_blob cred_int;
|
||||
if (!CryptUnprotectData(&cred_enc, NULL, &entropy_blob, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN | CRYPTPROTECT_VERIFY_PROTECTION, &cred_int)) {
|
||||
*ppEapError = m_module.make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptUnprotectData failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert password from UTF-8.
|
||||
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)cred_int.pbData, (int)cred_int.cbData, m_password);
|
||||
SecureZeroMemory(cred_int.pbData, cred_int.cbData);
|
||||
|
||||
if (cred->UserName)
|
||||
m_identity = cred->UserName;
|
||||
else
|
||||
m_identity.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const unsigned char eap::credentials_pass::s_entropy[1024] = {
|
||||
0x40, 0x88, 0xd3, 0x13, 0x81, 0x8a, 0xf6, 0x74, 0x55, 0x8e, 0xcc, 0x73, 0x2c, 0xf8, 0x93, 0x37,
|
||||
0x4f, 0xeb, 0x1d, 0x66, 0xb7, 0xfb, 0x47, 0x75, 0xb4, 0xfd, 0x07, 0xbb, 0xf6, 0xb3, 0x05, 0x30,
|
||||
0x4a, 0xc0, 0xff, 0x05, 0xbd, 0x1e, 0x2f, 0x55, 0xc8, 0x77, 0x70, 0x47, 0xc9, 0x85, 0x57, 0x22,
|
||||
0x8e, 0x54, 0x0b, 0x4d, 0x26, 0x80, 0x11, 0x0c, 0x52, 0x55, 0xc2, 0x3b, 0x9b, 0xd2, 0x19, 0x61,
|
||||
0xf1, 0x71, 0xf5, 0x4b, 0x49, 0x73, 0xf9, 0x6d, 0x44, 0xd2, 0x90, 0x92, 0x2d, 0xae, 0xc6, 0xbb,
|
||||
0x3d, 0xfe, 0x52, 0x47, 0x82, 0xc1, 0xa9, 0xe1, 0x6a, 0xd1, 0xd2, 0x4e, 0x3d, 0x9b, 0x4e, 0xc0,
|
||||
0x40, 0x36, 0x79, 0xd3, 0x88, 0xfc, 0x0b, 0x79, 0x8c, 0xb2, 0x9d, 0x74, 0x13, 0x29, 0x59, 0x0c,
|
||||
0xe0, 0x87, 0x34, 0x7d, 0xc1, 0x30, 0xd4, 0xe9, 0x98, 0xd1, 0x3f, 0x82, 0xcb, 0x8b, 0x44, 0x09,
|
||||
0x2d, 0xc5, 0x9e, 0x3d, 0x66, 0xe5, 0x1a, 0x9d, 0xa6, 0x87, 0x20, 0x7f, 0x55, 0xd7, 0x89, 0xf2,
|
||||
0xbb, 0x5f, 0x00, 0xf9, 0x38, 0xd3, 0x49, 0x10, 0x6f, 0x3a, 0xab, 0x5d, 0x8f, 0x73, 0x8c, 0xbc,
|
||||
0x6f, 0xf1, 0xef, 0x83, 0x43, 0xcb, 0xc9, 0xb7, 0x9f, 0x24, 0xe4, 0x91, 0x3a, 0xe6, 0xab, 0x6c,
|
||||
0xf2, 0xfd, 0x66, 0xf0, 0xb1, 0x1a, 0xc8, 0xc4, 0x6b, 0x9d, 0xa7, 0x10, 0x7d, 0x30, 0x29, 0x1b,
|
||||
0xe5, 0xfe, 0x1c, 0x97, 0x86, 0x1e, 0x80, 0xe5, 0x12, 0x0a, 0x2a, 0x0d, 0xd9, 0x4a, 0x35, 0xe5,
|
||||
0xab, 0xdf, 0x61, 0x76, 0x4e, 0x36, 0xff, 0xb1, 0x26, 0x5e, 0x12, 0x7f, 0xdf, 0xd7, 0x98, 0x55,
|
||||
0xf9, 0x89, 0x30, 0xcc, 0xe9, 0xf6, 0xd0, 0xc0, 0x69, 0xf4, 0x78, 0x81, 0x10, 0xeb, 0x34, 0xf3,
|
||||
0x5a, 0x8a, 0x62, 0xd4, 0x97, 0xe6, 0xb7, 0x98, 0x86, 0x5f, 0xb6, 0xcb, 0x9c, 0xab, 0xd6, 0xe9,
|
||||
0xda, 0x2b, 0x41, 0xbb, 0xa3, 0x37, 0x1f, 0x7d, 0x4e, 0x19, 0x13, 0xc3, 0xab, 0x23, 0x4d, 0xa6,
|
||||
0x51, 0xa9, 0x07, 0x60, 0xb9, 0x0c, 0x49, 0xce, 0x40, 0x29, 0x15, 0x0d, 0x10, 0xde, 0xc9, 0x0c,
|
||||
0x11, 0x91, 0xdc, 0xdf, 0xc8, 0xac, 0x13, 0xe5, 0xe9, 0x11, 0xdc, 0x47, 0xb7, 0xb3, 0xf5, 0xd0,
|
||||
0xc4, 0x38, 0x10, 0x17, 0xf7, 0x93, 0x93, 0x6b, 0x56, 0x10, 0xc6, 0xa6, 0x4c, 0xf8, 0x9c, 0x52,
|
||||
0xb7, 0xbd, 0x87, 0xe8, 0xff, 0x84, 0x01, 0xbb, 0x40, 0x84, 0x03, 0x19, 0x6f, 0xf7, 0x46, 0x6f,
|
||||
0x10, 0xc0, 0x85, 0xdf, 0xfd, 0xad, 0x00, 0xf6, 0xd5, 0x05, 0x22, 0xf4, 0x28, 0x87, 0xf6, 0x0c,
|
||||
0xca, 0xda, 0x9a, 0x67, 0x63, 0xa4, 0x2d, 0x4d, 0xa5, 0x06, 0xa1, 0x8b, 0x32, 0x9b, 0xb0, 0xed,
|
||||
0x05, 0x8e, 0x36, 0xa4, 0xbe, 0xa0, 0x9c, 0x78, 0xfa, 0x2c, 0x9e, 0x99, 0x02, 0x50, 0x63, 0xd4,
|
||||
0xd5, 0x4a, 0x9b, 0xc3, 0x81, 0x95, 0xab, 0x18, 0x47, 0x3d, 0x44, 0x15, 0x33, 0x79, 0xd0, 0x53,
|
||||
0x4e, 0xfc, 0x2f, 0x66, 0xc9, 0x7c, 0xb9, 0xda, 0xa2, 0xce, 0xfa, 0x39, 0xea, 0x72, 0x2c, 0xe2,
|
||||
0x5c, 0x1f, 0x7e, 0xcd, 0x2a, 0x3e, 0x11, 0x19, 0x06, 0xc7, 0x03, 0x89, 0x4c, 0xd3, 0x73, 0xea,
|
||||
0xa5, 0x69, 0x1e, 0x68, 0x04, 0xcd, 0xbb, 0xc4, 0x74, 0x7b, 0x1e, 0x75, 0x6f, 0xf1, 0x89, 0xea,
|
||||
0x21, 0xdf, 0x9e, 0x1b, 0x27, 0x4a, 0x20, 0xb4, 0x5b, 0x72, 0x68, 0x8e, 0x47, 0xe2, 0x18, 0x75,
|
||||
0x36, 0x82, 0xae, 0xa9, 0xa9, 0x40, 0xe5, 0x19, 0xa7, 0xea, 0x48, 0xad, 0x26, 0x7c, 0x93, 0x3e,
|
||||
0xbf, 0x48, 0x6c, 0x3e, 0x66, 0xf7, 0x3c, 0x8f, 0x3c, 0x0e, 0x77, 0xc8, 0xb5, 0x56, 0x3b, 0x3a,
|
||||
0x25, 0x13, 0x49, 0xb4, 0xcc, 0xbb, 0x8e, 0x94, 0x73, 0xa4, 0x35, 0x16, 0x95, 0x74, 0xa5, 0x98,
|
||||
0xa4, 0x61, 0xa2, 0x36, 0xaf, 0x7f, 0xdf, 0x04, 0xce, 0x34, 0xd3, 0xfc, 0x09, 0x83, 0x43, 0xc1,
|
||||
0x7a, 0x22, 0xc7, 0xfa, 0x3d, 0x97, 0xce, 0xc0, 0xcd, 0x15, 0xa4, 0x97, 0xb4, 0xd4, 0x55, 0x51,
|
||||
0xf1, 0xef, 0x81, 0x1a, 0xce, 0x1f, 0x5a, 0x2d, 0xba, 0xce, 0xec, 0xbd, 0x85, 0x57, 0x53, 0xc6,
|
||||
0x2f, 0x2a, 0x84, 0xab, 0xf3, 0x6e, 0x3b, 0xac, 0xf8, 0x73, 0xf2, 0x20, 0x42, 0x6f, 0xc4, 0xe2,
|
||||
0x20, 0xb7, 0xf8, 0x5e, 0xbd, 0xe7, 0xd2, 0x2b, 0xe6, 0x10, 0xc2, 0x66, 0xe7, 0x25, 0xf9, 0xb9,
|
||||
0xcb, 0xe4, 0x85, 0xbd, 0xf9, 0x62, 0x10, 0xfd, 0x67, 0x8f, 0x3f, 0x15, 0x4b, 0x10, 0x9e, 0xde,
|
||||
0x8a, 0x9c, 0xb5, 0x46, 0xb7, 0x96, 0xa8, 0x9d, 0xe8, 0xf1, 0xde, 0x34, 0xcf, 0x4c, 0xa4, 0xe6,
|
||||
0x35, 0x24, 0xcf, 0x47, 0xc5, 0x2d, 0xf2, 0xe3, 0x15, 0xf3, 0x39, 0xb7, 0x45, 0x2c, 0x92, 0x23,
|
||||
0x37, 0x28, 0xfa, 0x7b, 0x7b, 0xe9, 0xc3, 0x04, 0x57, 0x0c, 0x30, 0xab, 0x52, 0x3a, 0x1d, 0xf7,
|
||||
0x3a, 0x7b, 0xa0, 0xf0, 0x22, 0x14, 0xa8, 0xc7, 0x4e, 0xd5, 0x8b, 0x9a, 0xac, 0x67, 0x33, 0x0a,
|
||||
0xa2, 0xa4, 0x76, 0x65, 0x45, 0x48, 0x7d, 0x92, 0xd7, 0xdb, 0xb1, 0x51, 0xae, 0x5f, 0x95, 0x1c,
|
||||
0x8c, 0xe0, 0xaa, 0x28, 0x72, 0xbb, 0x2d, 0x97, 0x65, 0xfb, 0x3f, 0x41, 0x06, 0x46, 0xd1, 0x8c,
|
||||
0x99, 0x64, 0x0e, 0xc7, 0xf0, 0x82, 0x1f, 0x1e, 0x5e, 0x8a, 0xc8, 0x6e, 0x29, 0xf0, 0xa8, 0x38,
|
||||
0xa5, 0x38, 0x12, 0xaa, 0x9d, 0x60, 0x3d, 0x40, 0xfc, 0x29, 0x17, 0xc5, 0xe1, 0x1d, 0xba, 0x14,
|
||||
0x45, 0xf0, 0x16, 0x32, 0x8f, 0x37, 0x88, 0xad, 0x7c, 0x77, 0x57, 0x06, 0x89, 0x70, 0x1f, 0x0e,
|
||||
0x88, 0x9d, 0x2b, 0x5f, 0x83, 0x69, 0xb0, 0x48, 0x03, 0x86, 0xe4, 0x2e, 0x1c, 0xfb, 0x85, 0xb1,
|
||||
0xce, 0x1c, 0x0e, 0xe0, 0xd4, 0x17, 0x0f, 0xb2, 0xf1, 0x79, 0xde, 0x8f, 0xd2, 0x0a, 0xa5, 0x10,
|
||||
0xee, 0x9e, 0x05, 0x57, 0x0d, 0x42, 0x21, 0xaa, 0x53, 0xb1, 0x53, 0xd9, 0x59, 0x8b, 0x43, 0x22,
|
||||
0x82, 0xbe, 0xa3, 0x2a, 0x79, 0x89, 0x46, 0xc4, 0x18, 0x31, 0x3e, 0xd4, 0x3d, 0x79, 0x9b, 0x06,
|
||||
0xde, 0x7e, 0xe5, 0x20, 0xdd, 0xae, 0x34, 0xa8, 0x31, 0xc2, 0xdf, 0x61, 0x6d, 0x1b, 0x47, 0xc4,
|
||||
0xae, 0x25, 0x44, 0xa8, 0x79, 0x5c, 0x2b, 0x4a, 0x17, 0x6e, 0x7a, 0xe5, 0xf1, 0x48, 0x3f, 0x82,
|
||||
0x24, 0x6a, 0xc5, 0xc1, 0xfc, 0x65, 0x61, 0xca, 0xe4, 0x89, 0x52, 0x14, 0xe4, 0xb3, 0x7a, 0x24,
|
||||
0xc2, 0xe5, 0x59, 0x1d, 0x55, 0xa3, 0x95, 0x16, 0xe2, 0xcf, 0x07, 0xd8, 0xad, 0x9c, 0x30, 0xbe,
|
||||
0x96, 0xee, 0x80, 0x54, 0x63, 0xe7, 0xd4, 0xa6, 0xac, 0xe8, 0x15, 0xd4, 0xfc, 0x7b, 0xf8, 0xee,
|
||||
0x0e, 0x88, 0x51, 0xd9, 0xad, 0x6f, 0x0d, 0xea, 0x19, 0x3a, 0x1a, 0x20, 0xbc, 0x99, 0x59, 0xcc,
|
||||
0xba, 0x19, 0xc8, 0x26, 0x79, 0x79, 0xe8, 0xf6, 0x3f, 0xa0, 0xdb, 0xa6, 0x52, 0x4d, 0xc0, 0x98,
|
||||
0x22, 0xcf, 0x30, 0xae, 0xdf, 0x22, 0x94, 0x5c, 0x19, 0x01, 0xe3, 0xf0, 0x44, 0x23, 0xe5, 0xeb,
|
||||
0x70, 0x1a, 0xd2, 0x7f, 0xe8, 0x91, 0x1b, 0x55, 0xe7, 0xcb, 0x0d, 0xc2, 0x53, 0xa0, 0xe6, 0x7a,
|
||||
0x48, 0xab, 0x05, 0xbb, 0x55, 0x28, 0x98, 0x12, 0xe5, 0xd1, 0xd9, 0x44, 0xe9, 0xa8, 0x8d, 0xa4,
|
||||
0x68, 0xc8, 0x21, 0xa8, 0xe9, 0x49, 0x46, 0x22, 0xce, 0x81, 0xfe, 0x4a, 0xe3, 0xa0, 0x1c, 0xb0,
|
||||
0x30, 0x29, 0x39, 0x9a, 0xd6, 0xab, 0x2e, 0xc6, 0x42, 0x47, 0x5e, 0x54, 0xbb, 0x90, 0xe6, 0x98,
|
||||
0xe6, 0x52, 0x58, 0x58, 0x1e, 0xd0, 0x00, 0x9c, 0x8f, 0x4a, 0x17, 0x7e, 0x8a, 0x5a, 0xef, 0x3e,
|
||||
};
|
206
lib/EAPBase/src/Module.cpp
Normal file
206
lib/EAPBase/src/Module.cpp
Normal file
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::module
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::module::module(type_t eap_method) :
|
||||
m_eap_method(eap_method),
|
||||
m_instance(NULL)
|
||||
{
|
||||
m_ep.create(&EAPMETHOD_TRACE_EVENT_PROVIDER);
|
||||
m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_LOAD, event_data((DWORD)m_eap_method), event_data::blank);
|
||||
|
||||
m_heap.create(0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
eap::module::~module()
|
||||
{
|
||||
m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_UNLOAD, event_data((DWORD)m_eap_method), event_data::blank);
|
||||
}
|
||||
|
||||
|
||||
EAP_ERROR* eap::module::make_error(_In_ DWORD dwErrorCode, _In_opt_z_ LPCWSTR pszRootCauseString, _In_opt_z_ LPCWSTR pszRepairString, _In_opt_ DWORD dwReasonCode, _In_opt_ LPCGUID pRootCauseGuid, _In_opt_ LPCGUID pRepairGuid, _In_opt_ LPCGUID pHelpLinkGuid) const
|
||||
{
|
||||
// Calculate memory size requirement.
|
||||
SIZE_T
|
||||
nRootCauseSize = pszRootCauseString != NULL && pszRootCauseString[0] ? (wcslen(pszRootCauseString) + 1)*sizeof(WCHAR) : 0,
|
||||
nRepairStringSize = pszRepairString != NULL && pszRepairString [0] ? (wcslen(pszRepairString ) + 1)*sizeof(WCHAR) : 0,
|
||||
nEapErrorSize = sizeof(EAP_ERROR) + nRootCauseSize + nRepairStringSize;
|
||||
|
||||
EAP_ERROR *pError = (EAP_ERROR*)HeapAlloc(m_heap, 0, nEapErrorSize);
|
||||
if (!pError)
|
||||
return NULL;
|
||||
BYTE *p = (BYTE*)(pError + 1);
|
||||
|
||||
// Fill the error descriptor.
|
||||
pError->dwWinError = dwErrorCode;
|
||||
pError->type.eapType.type = (BYTE)m_eap_method;
|
||||
pError->type.eapType.dwVendorId = 0;
|
||||
pError->type.eapType.dwVendorType = 0;
|
||||
pError->type.dwAuthorId = 67532;
|
||||
pError->dwReasonCode = dwReasonCode;
|
||||
pError->rootCauseGuid = pRootCauseGuid != NULL ? *pRootCauseGuid : GUID_NULL;
|
||||
pError->repairGuid = pRepairGuid != NULL ? *pRepairGuid : GUID_NULL;
|
||||
pError->helpLinkGuid = pHelpLinkGuid != NULL ? *pHelpLinkGuid : GUID_NULL;
|
||||
if (nRootCauseSize) {
|
||||
pError->pRootCauseString = (LPWSTR)p;
|
||||
memcpy(pError->pRootCauseString, pszRootCauseString, nRootCauseSize);
|
||||
p += nRootCauseSize;
|
||||
} else
|
||||
pError->pRootCauseString = NULL;
|
||||
if (nRepairStringSize) {
|
||||
pError->pRepairString = (LPWSTR)p;
|
||||
memcpy(pError->pRepairString, pszRepairString, nRepairStringSize);
|
||||
p += nRepairStringSize;
|
||||
} else
|
||||
pError->pRepairString = NULL;
|
||||
|
||||
return pError;
|
||||
}
|
||||
|
||||
|
||||
BYTE* eap::module::alloc_memory(_In_ size_t size)
|
||||
{
|
||||
return (BYTE*)HeapAlloc(m_heap, 0, size);
|
||||
}
|
||||
|
||||
|
||||
void eap::module::free_memory(_In_ BYTE *ptr)
|
||||
{
|
||||
// Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing.
|
||||
SecureZeroMemory(ptr, HeapSize(m_heap, 0, ptr));
|
||||
HeapFree(m_heap, 0, ptr);
|
||||
}
|
||||
|
||||
|
||||
void eap::module::free_error_memory(_In_ EAP_ERROR *err)
|
||||
{
|
||||
// pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations.
|
||||
HeapFree(m_heap, 0, err);
|
||||
}
|
||||
|
||||
|
||||
void eap::module::log_error(_In_ const EAP_ERROR *err) const
|
||||
{
|
||||
assert(err);
|
||||
|
||||
// Write trace event.
|
||||
vector<EVENT_DATA_DESCRIPTOR> evt_desc;
|
||||
evt_desc.reserve(8);
|
||||
evt_desc.push_back(event_data(err->dwWinError));
|
||||
DWORD dwType = err->type.eapType.type;
|
||||
evt_desc.push_back(event_data(dwType));
|
||||
evt_desc.push_back(event_data(err->dwReasonCode));
|
||||
evt_desc.push_back(event_data(&(err->rootCauseGuid), sizeof(GUID)));
|
||||
evt_desc.push_back(event_data(&(err->repairGuid), sizeof(GUID)));
|
||||
evt_desc.push_back(event_data(&(err->helpLinkGuid), sizeof(GUID)));
|
||||
evt_desc.push_back(event_data(err->pRootCauseString));
|
||||
evt_desc.push_back(event_data(err->pRepairString));
|
||||
m_ep.write(&EAPMETHOD_TRACE_EAP_ERROR, (ULONG)evt_desc.size(), evt_desc.data());
|
||||
}
|
||||
|
||||
|
||||
bool eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError, _Out_opt_ HCRYPTHASH hHash) const
|
||||
{
|
||||
assert(ppEapError);
|
||||
|
||||
// Generate 256-bit AES session key.
|
||||
crypt_key key_aes;
|
||||
if (!CryptGenKey(hProv, CALG_AES_256, MAKELONG(CRYPT_EXPORTABLE, 256), &key_aes)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptGenKey failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Import the public RSA key.
|
||||
HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA);
|
||||
assert(res);
|
||||
HGLOBAL res_handle = LoadResource(m_instance, res);
|
||||
assert(res_handle);
|
||||
crypt_key key_rsa;
|
||||
unique_ptr<CERT_PUBLIC_KEY_INFO, LocalFree_delete<CERT_PUBLIC_KEY_INFO> > keyinfo_data;
|
||||
DWORD keyinfo_size = 0;
|
||||
if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."));
|
||||
return false;
|
||||
}
|
||||
if (!key_rsa.import_public(hProv, X509_ASN_ENCODING, keyinfo_data.get())) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" Public key import failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Export AES session key encrypted with public RSA key.
|
||||
vector<unsigned char, sanitizing_allocator<unsigned char> > buf;
|
||||
if (!CryptExportKey(key_aes, key_rsa, SIMPLEBLOB, 0, buf)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptExportKey failed."));
|
||||
return false;
|
||||
}
|
||||
enc.assign(buf.begin(), buf.end());
|
||||
|
||||
// Pre-allocate memory to allow space, as encryption will grow the data.
|
||||
buf.assign((const unsigned char*)data, (const unsigned char*)data + size);
|
||||
DWORD dwBlockLen;
|
||||
if (!CryptGetKeyParam(key_aes, KP_BLOCKLEN, dwBlockLen, 0)) dwBlockLen = 0;
|
||||
buf.reserve((size + dwBlockLen) / dwBlockLen * dwBlockLen);
|
||||
|
||||
// Encrypt the data using AES key.
|
||||
if (!CryptEncrypt(key_aes, hHash, TRUE, 0, buf)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" CryptEncrypt failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Append encrypted data.
|
||||
enc.insert(enc.cend(), buf.begin(), buf.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool eap::module::encrypt_md5(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_ std::vector<unsigned char> &enc, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
// Create hash.
|
||||
crypt_hash hash;
|
||||
if (!hash.create(hProv, CALG_MD5)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" Creating MD5 hash failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Encrypt data.
|
||||
if (!encrypt(hProv, data, size, enc, ppEapError, hash))
|
||||
return false;
|
||||
|
||||
// Calculate MD5 hash.
|
||||
vector<unsigned char> hash_bin;
|
||||
if (!CryptGetHashParam(hash, HP_HASHVAL, hash_bin, 0)) {
|
||||
*ppEapError = make_error(GetLastError(), _T(__FUNCTION__) _T(" Calculating MD5 hash failed."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Append hash.
|
||||
enc.insert(enc.end(), hash_bin.begin(), hash_bin.end());
|
||||
return true;
|
||||
}
|
21
lib/EAPBase/src/StdAfx.cpp
Normal file
21
lib/EAPBase/src/StdAfx.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
35
lib/EAPBase/src/StdAfx.h
Normal file
35
lib/EAPBase/src/StdAfx.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/Config.h"
|
||||
#include "../include/Credentials.h"
|
||||
#include "../include/Module.h"
|
||||
#include "../include/Session.h"
|
||||
|
||||
#include "../include/EAP.h"
|
||||
#include "../include/EAPSerial.h"
|
||||
#include "../include/EAPXML.h"
|
||||
|
||||
#include <WinStd/Cred.h>
|
||||
#include <WinStd/ETW.h>
|
||||
|
||||
#include <EventsETW.h>
|
2
lib/EAPBase_UI/build/.gitignore
vendored
Normal file
2
lib/EAPBase_UI/build/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/temp
|
||||
/*.user
|
12
lib/EAPBase_UI/build/EAPBase_UI.props
Normal file
12
lib/EAPBase_UI/build/EAPBase_UI.props
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
108
lib/EAPBase_UI/build/EAPBase_UI.vcxproj
Normal file
108
lib/EAPBase_UI/build/EAPBase_UI.vcxproj
Normal file
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D4B54856-BE1F-4937-A8F7-495125BE76BE}</ProjectGuid>
|
||||
<RootNamespace>EAPBase_UI</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="EAPBase_UI.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="EAPBase_UI.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="EAPBase_UI.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="EAPBase_UI.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\EAP_UI.h" />
|
||||
<ClInclude Include="..\include\Module.h" />
|
||||
<ClInclude Include="..\res\wxEAP_UI.h" />
|
||||
<ClInclude Include="..\src\StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\res\wxEAP_UI.cpp" />
|
||||
<ClCompile Include="..\src\EAP_UI.cpp" />
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\res\wxEAP_UI.fbp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
47
lib/EAPBase_UI/build/EAPBase_UI.vcxproj.filters
Normal file
47
lib/EAPBase_UI/build/EAPBase_UI.vcxproj.filters
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\EAP_UI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\res\wxEAP_UI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Module.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\EAP_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\res\wxEAP_UI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\res\wxEAP_UI.fbp">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
673
lib/EAPBase_UI/include/EAP_UI.h
Normal file
673
lib/EAPBase_UI/include/EAP_UI.h
Normal file
@@ -0,0 +1,673 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <wx/hyperlink.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
///
|
||||
/// EAP configuration dialog
|
||||
///
|
||||
template <class _Tmeth, class _wxT> class wxEAPConfigDialog;
|
||||
|
||||
///
|
||||
/// EAP credentials dialog
|
||||
///
|
||||
template <class _Tprov> class wxEAPCredentialsDialog;
|
||||
|
||||
///
|
||||
/// EAP dialog banner
|
||||
///
|
||||
class wxEAPBannerPanel;
|
||||
|
||||
///
|
||||
/// EAP Provider-locked congifuration note
|
||||
///
|
||||
template <class _Tprov> class wxEAPProviderLocked;
|
||||
|
||||
///
|
||||
/// Base template for credentials configuration panel
|
||||
///
|
||||
template <class _Tprov, class _Tmeth, class _wxT> class wxEAPCredentialsConfigPanel;
|
||||
|
||||
///
|
||||
/// Base template for all credential panels
|
||||
///
|
||||
template <class _Tcred, class _Tbase> class wxCredentialsPanel;
|
||||
|
||||
///
|
||||
/// Password credentials panel
|
||||
///
|
||||
template <class _Tprov> class wxPasswordCredentialsPanel;
|
||||
|
||||
///
|
||||
/// Sets icon from resource
|
||||
///
|
||||
inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName);
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wx/msw/winundef.h> // Fixes `CreateDialog` name collision
|
||||
#include "../res/wxEAP_UI.h"
|
||||
|
||||
#include "../../EAPBase/include/Config.h"
|
||||
#include "../../EAPBase/include/Credentials.h"
|
||||
|
||||
#include <WinStd/Common.h>
|
||||
#include <WinStd/Cred.h>
|
||||
#include <WinStd/Win.h>
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
#include <CommCtrl.h>
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
|
||||
template <class _Tmeth, class _wxT>
|
||||
class wxEAPConfigDialog : public wxEAPConfigDialogBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Configuration provider data type
|
||||
///
|
||||
typedef eap::config_provider<_Tmeth> _Tprov;
|
||||
|
||||
///
|
||||
/// Configuration data type
|
||||
///
|
||||
typedef eap::config_providers<_Tprov> config_type;
|
||||
|
||||
///
|
||||
/// This data type
|
||||
///
|
||||
typedef wxEAPConfigDialog<_Tmeth, _wxT> _T;
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs a configuration dialog
|
||||
///
|
||||
wxEAPConfigDialog(config_type &cfg, wxWindow* parent) :
|
||||
m_cfg(cfg),
|
||||
wxEAPConfigDialogBase(parent)
|
||||
{
|
||||
// Set extra style here, as wxFormBuilder overrides all default flags.
|
||||
this->SetExtraStyle(this->GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
|
||||
|
||||
for (std::list<_Tprov>::iterator provider = m_cfg.m_providers.begin(), provider_end = m_cfg.m_providers.end(); provider != provider_end; ++provider) {
|
||||
bool is_single = provider->m_methods.size() == 1;
|
||||
std::list<_Tmeth>::size_type count = 0;
|
||||
std::list<_Tmeth>::iterator method = provider->m_methods.begin(), method_end = provider->m_methods.end();
|
||||
for (; method != method_end; ++method, count++)
|
||||
m_providers->AddPage(
|
||||
new _wxT(
|
||||
*provider,
|
||||
provider->m_methods.front(),
|
||||
provider->m_id.c_str(),
|
||||
m_providers),
|
||||
is_single ? provider->m_id : winstd::tstring_printf(_T("%s (%u)"), provider->m_id.c_str(), count));
|
||||
}
|
||||
|
||||
this->Layout();
|
||||
this->GetSizer()->Fit(this);
|
||||
|
||||
m_buttonsOK->SetDefault();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
// Forward the event to child panels.
|
||||
for (wxWindowList::compatibility_iterator provider = m_providers->GetChildren().GetFirst(); provider; provider = provider->GetNext()) {
|
||||
_wxT *prov = wxDynamicCast(provider->GetData(), _wxT);
|
||||
if (prov)
|
||||
prov->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
|
||||
protected:
|
||||
config_type &m_cfg; ///< EAP providers configuration
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPCredentialsDialog : public wxEAPCredentialsDialogBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credential dialog
|
||||
///
|
||||
wxEAPCredentialsDialog(_Tprov &prov, wxWindow* parent) : wxEAPCredentialsDialogBase(parent)
|
||||
{
|
||||
// Set extra style here, as wxFormBuilder overrides all default flags.
|
||||
this->SetExtraStyle(this->GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
|
||||
|
||||
// Set banner title.
|
||||
m_banner->m_title->SetLabel(wxString::Format(_("%s Credentials"), prov.m_id.c_str()));
|
||||
|
||||
m_buttonsOK->SetDefault();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Adds panels to the dialog
|
||||
///
|
||||
void AddContents(wxPanel **contents, size_t content_count)
|
||||
{
|
||||
if (content_count) {
|
||||
for (size_t i = 0; i < content_count; i++)
|
||||
m_panels->Add(contents[i], 0, wxALL|wxEXPAND, 5);
|
||||
|
||||
this->Layout();
|
||||
this->GetSizer()->Fit(this);
|
||||
contents[0]->SetFocusFromKbd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
|
||||
virtual void OnInitDialog(wxInitDialogEvent& event)
|
||||
{
|
||||
for (wxSizerItemList::compatibility_iterator panel = m_panels->GetChildren().GetFirst(); panel; panel = panel->GetNext())
|
||||
panel->GetData()->GetWindow()->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
};
|
||||
|
||||
|
||||
class wxEAPBannerPanel : public wxEAPBannerPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a banner pannel and set the title text to product name
|
||||
///
|
||||
wxEAPBannerPanel(wxWindow* parent);
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
virtual bool AcceptsFocusFromKeyboard() const { return false; }
|
||||
/// \endcond
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxEAPProviderLocked : public wxEAPProviderLockedBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a notice pannel and set the title text
|
||||
///
|
||||
wxEAPProviderLocked(_Tprov &prov, wxWindow* parent) :
|
||||
m_prov(prov),
|
||||
wxEAPProviderLockedBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_provider_locked_icon, m_icon, m_shell32, MAKEINTRESOURCE(48));
|
||||
|
||||
m_provider_locked_label->SetLabel(wxString::Format(_("%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification."),
|
||||
!m_prov.m_name.empty() ? m_prov.m_name.c_str() :
|
||||
!m_prov.m_id .empty() ? winstd::string_printf(_("Your %ls provider"), m_prov.m_id.c_str()).c_str() : _("Your provider")));
|
||||
m_provider_locked_label->Wrap(452);
|
||||
|
||||
if (!m_prov.m_help_email.empty() || !m_prov.m_help_web.empty() || !m_prov.m_help_phone.empty()) {
|
||||
wxStaticText *provider_notice = new wxStaticText(this, wxID_ANY, wxString::Format(_("For additional help and instructions, please contact %s at:"),
|
||||
!m_prov.m_name.empty() ? m_prov.m_name.c_str() :
|
||||
!m_prov.m_id .empty() ? winstd::string_printf(_("your %ls provider"), m_prov.m_id.c_str()).c_str() : _("your provider")), wxDefaultPosition, wxDefaultSize, 0);
|
||||
provider_notice->Wrap(452);
|
||||
m_provider_locked_vert->Add(provider_notice, 0, wxUP|wxLEFT|wxRIGHT|wxEXPAND, 5);
|
||||
|
||||
wxFlexGridSizer* sb_contact_tbl;
|
||||
sb_contact_tbl = new wxFlexGridSizer(0, 2, 5, 5);
|
||||
sb_contact_tbl->AddGrowableCol(1);
|
||||
sb_contact_tbl->SetFlexibleDirection(wxBOTH);
|
||||
sb_contact_tbl->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||
|
||||
wxFont font_wingdings(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Wingdings"));
|
||||
|
||||
if (!m_prov.m_help_web.empty()) {
|
||||
wxStaticText *label = new wxStaticText(this, wxID_ANY, wxT("\xb6"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
label->Wrap(-1);
|
||||
label->SetFont(font_wingdings);
|
||||
sb_contact_tbl->Add(label, 0, wxEXPAND|wxALIGN_TOP, 5);
|
||||
|
||||
wxHyperlinkCtrl *value = new wxHyperlinkCtrl(this, wxID_ANY, m_prov.m_help_web, m_prov.m_help_web, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
|
||||
value->SetToolTip(_("Open the default web browser"));
|
||||
sb_contact_tbl->Add(value, 0, wxEXPAND|wxALIGN_TOP, 5);
|
||||
}
|
||||
|
||||
if (!m_prov.m_help_email.empty()) {
|
||||
wxStaticText *label = new wxStaticText(this, wxID_ANY, wxT("\x2a"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
label->Wrap(-1);
|
||||
label->SetFont(font_wingdings);
|
||||
sb_contact_tbl->Add(label, 0, wxEXPAND|wxALIGN_TOP, 5);
|
||||
|
||||
wxHyperlinkCtrl *value = new wxHyperlinkCtrl(this, wxID_ANY, m_prov.m_help_email, wxString(wxT("mailto:")) + m_prov.m_help_email, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
|
||||
value->SetToolTip(_("Open your e-mail program"));
|
||||
sb_contact_tbl->Add(value, 0, wxEXPAND|wxALIGN_TOP, 5);
|
||||
}
|
||||
|
||||
if (!m_prov.m_help_phone.empty()) {
|
||||
wxStaticText *label = new wxStaticText(this, wxID_ANY, wxT("\x29"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
label->Wrap(-1);
|
||||
label->SetFont(font_wingdings);
|
||||
sb_contact_tbl->Add(label, 0, wxEXPAND|wxALIGN_TOP, 5);
|
||||
|
||||
wxHyperlinkCtrl *value = new wxHyperlinkCtrl(this, wxID_ANY, m_prov.m_help_phone, wxString(wxT("tel:")) + GetPhoneNumber(m_prov.m_help_phone.c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
|
||||
value->SetToolTip(_("Dial the phone number"));
|
||||
sb_contact_tbl->Add(value, 0, wxEXPAND|wxALIGN_TOP, 5);
|
||||
}
|
||||
|
||||
m_provider_locked_vert->Add(sb_contact_tbl, 0, wxLEFT|wxRIGHT|wxDOWN|wxEXPAND, 5);
|
||||
}
|
||||
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
|
||||
virtual bool AcceptsFocusFromKeyboard() const
|
||||
{
|
||||
return !m_prov.m_help_email.empty() || !m_prov.m_help_web.empty() || !m_prov.m_help_phone.empty();
|
||||
}
|
||||
|
||||
template<class _Elem, class _Traits, class _Ax>
|
||||
static std::basic_string<_Elem, _Traits, _Ax> GetPhoneNumber(_In_z_ const _Elem *num)
|
||||
{
|
||||
assert(num);
|
||||
|
||||
std::basic_string<_Elem, _Traits, _Ax> str;
|
||||
for (; *num; num++) {
|
||||
_Elem c = *num;
|
||||
if ('0' <= c && c <= '9' || c == '+' || c == '*' || c == '#')
|
||||
str += c;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
template<class _Elem>
|
||||
static std::basic_string<_Elem, std::char_traits<_Elem>, std::allocator<_Elem> > GetPhoneNumber(_In_z_ const _Elem *num)
|
||||
{
|
||||
return GetPhoneNumber<_Elem, std::char_traits<_Elem>, std::allocator<_Elem> >(num);
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tprov &m_prov; ///< EAP provider
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov, class _Tmeth, class _wxT>
|
||||
class wxEAPCredentialsConfigPanel : public wxEAPCredentialsConfigPanelBase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credential configuration panel
|
||||
///
|
||||
/// \param[inout] prov Provider configuration data
|
||||
/// \param[inout] cfg Configuration data
|
||||
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
|
||||
/// \param[in] parent Parent window
|
||||
///
|
||||
wxEAPCredentialsConfigPanel(_Tprov &prov, _Tmeth &cfg, LPCTSTR pszCredTarget, wxWindow *parent) :
|
||||
m_prov(prov),
|
||||
m_cfg(cfg),
|
||||
m_target(pszCredTarget),
|
||||
m_cred(m_cfg.m_module),
|
||||
wxEAPCredentialsConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(/*16770*/269));
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
if (m_prov.m_read_only) {
|
||||
// This is provider-locked configuration. Disable controls.
|
||||
m_own ->Enable(false);
|
||||
m_preshared ->Enable(false);
|
||||
m_preshared_identity->Enable(false);
|
||||
m_preshared_set ->Enable(false);
|
||||
}
|
||||
|
||||
if (!m_cfg.m_use_preshared) {
|
||||
m_own->SetValue(true);
|
||||
m_cred.clear();
|
||||
} else {
|
||||
m_preshared->SetValue(true);
|
||||
m_cred = m_cfg.m_preshared;
|
||||
}
|
||||
|
||||
return wxEAPCredentialsConfigPanelBase::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(wxEAPCredentialsConfigPanelBase::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Save the data.
|
||||
if (m_own->GetValue()) {
|
||||
m_cfg.m_use_preshared = false;
|
||||
} else {
|
||||
m_cfg.m_use_preshared = true;
|
||||
m_cfg.m_preshared = m_cred;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdateUI(wxUpdateUIEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
DWORD dwResult;
|
||||
|
||||
if (m_cfg.m_allow_save) {
|
||||
bool has_own;
|
||||
std::unique_ptr<CREDENTIAL, winstd::CredFree_delete<CREDENTIAL> > cred;
|
||||
if (CredRead(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
m_own_identity->SetValue(cred->UserName && cred->UserName[0] != 0 ? cred->UserName : _("<blank>"));
|
||||
has_own = true;
|
||||
} else if ((dwResult = GetLastError()) == ERROR_NOT_FOUND) {
|
||||
m_own_identity->Clear();
|
||||
has_own = false;
|
||||
} else {
|
||||
m_own_identity->SetValue(wxString::Format(_("<error %u>"), dwResult));
|
||||
has_own = true;
|
||||
}
|
||||
|
||||
if (m_own->GetValue()) {
|
||||
m_own_identity->Enable(true);
|
||||
m_own_set ->Enable(true);
|
||||
m_own_clear ->Enable(has_own);
|
||||
} else {
|
||||
m_own_identity->Enable(false);
|
||||
m_own_set ->Enable(false);
|
||||
m_own_clear ->Enable(false);
|
||||
}
|
||||
} else {
|
||||
m_own_identity->Clear();
|
||||
|
||||
m_own_identity->Enable(false);
|
||||
m_own_set ->Enable(false);
|
||||
m_own_clear ->Enable(false);
|
||||
}
|
||||
|
||||
m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.m_identity : _("<blank>"));
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Selectively enable/disable controls.
|
||||
if (m_own->GetValue()) {
|
||||
m_preshared_identity->Enable(false);
|
||||
m_preshared_set ->Enable(false);
|
||||
} else {
|
||||
m_preshared_identity->Enable(true);
|
||||
m_preshared_set ->Enable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnSetOwn(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
wxEAPCredentialsDialog<_Tprov> dlg(m_prov, this);
|
||||
|
||||
_wxT *panel = new _wxT(m_prov, m_cred, m_target.c_str(), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
virtual void OnClearOwn(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
if (!CredDelete(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0))
|
||||
wxLogError(_("Deleting credentials failed (error %u)."), GetLastError());
|
||||
}
|
||||
|
||||
|
||||
virtual void OnSetPreshared(wxCommandEvent& event)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
wxEAPCredentialsDialog<_Tprov> dlg(m_prov, this);
|
||||
|
||||
_wxT *panel = new _wxT(m_prov, m_cred, _T(""), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tprov &m_prov; ///< EAP provider
|
||||
_Tmeth &m_cfg; ///< EAP configuration
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
|
||||
private:
|
||||
typename _Tmeth::credentials_type m_cred; ///< Temporary credential data
|
||||
};
|
||||
|
||||
|
||||
template <class _Tcred, class _Tbase>
|
||||
class wxCredentialsPanel : public _Tbase
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a credentials panel
|
||||
///
|
||||
/// \param[inout] cred Credentials data
|
||||
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
|
||||
/// \param[in] parent Parent window
|
||||
/// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled.
|
||||
///
|
||||
wxCredentialsPanel(_Tcred &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) :
|
||||
m_cred(cred),
|
||||
m_target(pszCredTarget),
|
||||
_Tbase(parent)
|
||||
{
|
||||
if (m_target.empty() || is_config) {
|
||||
// No Credential Manager, or user is setting credentials via configuration UI.
|
||||
// => Pointless if not stored to Credential Manager
|
||||
m_remember->SetValue(true);
|
||||
m_remember->Enable(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
if (!m_target.empty()) {
|
||||
// Read credentials from Credential Manager
|
||||
EAP_ERROR *pEapError;
|
||||
if (m_cred.retrieve(m_target.c_str(), &pEapError)) {
|
||||
m_remember->SetValue(true);
|
||||
} else if (pEapError) {
|
||||
if (pEapError->dwWinError != ERROR_NOT_FOUND)
|
||||
wxLogError(winstd::tstring_printf(_("Error reading credentials from Credential Manager: %ls (error %u)"), pEapError->pRootCauseString, pEapError->dwWinError).c_str());
|
||||
m_cred.m_module.free_error_memory(pEapError);
|
||||
} else
|
||||
wxLogError(_("Reading credentials failed."));
|
||||
}
|
||||
|
||||
return _Tbase::TransferDataToWindow();
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
wxCHECK(_Tbase::TransferDataFromWindow(), false);
|
||||
|
||||
if (!m_target.empty()) {
|
||||
// Write credentials to credential manager.
|
||||
if (m_remember->GetValue()) {
|
||||
EAP_ERROR *pEapError;
|
||||
if (!m_cred.store(m_target.c_str(), &pEapError)) {
|
||||
if (pEapError) {
|
||||
wxLogError(winstd::tstring_printf(_("Error writing credentials to Credential Manager: %ls (error %u)"), pEapError->pRootCauseString, pEapError->dwWinError).c_str());
|
||||
m_cred.m_module.free_error_memory(pEapError);
|
||||
} else
|
||||
wxLogError(_("Writing credentials failed."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
_Tcred &m_cred; ///< Password credentials
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
class wxPasswordCredentialsPanel : public wxCredentialsPanel<eap::credentials_pass, wxPasswordCredentialsPanelBase>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a password credentials panel
|
||||
///
|
||||
/// \param[inout] prov EAP provider
|
||||
/// \param[inout] cred Credentials data
|
||||
/// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name.
|
||||
/// \param[in] parent Parent window
|
||||
/// \param[in] is_config Is this panel used to pre-enter credentials? When \c true, the "Remember" checkbox is always selected and disabled.
|
||||
///
|
||||
wxPasswordCredentialsPanel(_Tprov &prov, eap::credentials_pass &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config = false) :
|
||||
wxCredentialsPanel<eap::credentials_pass, wxPasswordCredentialsPanelBase>(cred, pszCredTarget, parent, is_config)
|
||||
{
|
||||
// Load and set icon.
|
||||
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
|
||||
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(269));
|
||||
|
||||
bool layout = false;
|
||||
if (!prov.m_lbl_alt_credential.empty()) {
|
||||
m_credentials_label->SetLabel(prov.m_lbl_alt_credential);
|
||||
m_credentials_label->Wrap( 446 );
|
||||
layout = true;
|
||||
}
|
||||
|
||||
if (!prov.m_lbl_alt_identity.empty()) {
|
||||
m_identity_label->SetLabel(prov.m_lbl_alt_identity);
|
||||
layout = true;
|
||||
}
|
||||
|
||||
if (!prov.m_lbl_alt_password.empty()) {
|
||||
m_password_label->SetLabel(prov.m_lbl_alt_password);
|
||||
layout = true;
|
||||
}
|
||||
|
||||
if (layout)
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// \cond internal
|
||||
|
||||
virtual bool TransferDataToWindow()
|
||||
{
|
||||
// Inherited TransferDataToWindow() calls m_cred.retrieve().
|
||||
// Therefore, call it now, to set m_cred.
|
||||
wxCHECK(__super::TransferDataToWindow(), false);
|
||||
|
||||
m_identity->SetValue(m_cred.m_identity);
|
||||
m_identity->SetSelection(0, -1);
|
||||
m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool TransferDataFromWindow()
|
||||
{
|
||||
m_cred.m_identity = m_identity->GetValue();
|
||||
|
||||
wxString pass = m_password->GetValue();
|
||||
if (pass.compare(s_dummy_password) != 0) {
|
||||
m_cred.m_password = pass;
|
||||
pass.assign(pass.length(), wxT('*'));
|
||||
}
|
||||
|
||||
// Inherited TransferDataFromWindow() calls m_cred.store().
|
||||
// Therefore, call it only now, that m_cred is set.
|
||||
return __super::TransferDataFromWindow();
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
protected:
|
||||
winstd::library m_shell32; ///< shell32.dll resource library reference
|
||||
wxIcon m_icon; ///< Panel icon
|
||||
|
||||
private:
|
||||
static const wxStringCharType *s_dummy_password;
|
||||
};
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
const wxStringCharType *wxPasswordCredentialsPanel<_Tprov>::s_dummy_password = wxT("dummypass");
|
||||
|
||||
|
||||
inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName)
|
||||
{
|
||||
wxASSERT(bmp);
|
||||
|
||||
HICON hIcon;
|
||||
if (SUCCEEDED(LoadIconWithScaleDown(hinst, pszName, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), &hIcon))) {
|
||||
icon.CreateFromHICON(hIcon);
|
||||
bmp->SetIcon(icon);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
109
lib/EAPBase_UI/include/Module.h
Normal file
109
lib/EAPBase_UI/include/Module.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace eap
|
||||
{
|
||||
///
|
||||
/// EAP UI peer base abstract class template
|
||||
///
|
||||
/// A group of methods all EAP UI peers must or should implement.
|
||||
///
|
||||
template <class _Tmeth, class _Tid, class _Tint, class _Tintres> class peer_ui;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../EAPBase/include/Module.h"
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
template <class _Tcfg, class _Tid, class _Tint, class _Tintres>
|
||||
class peer_ui : public peer_base<_Tcfg, _Tid, _Tint, _Tintres>
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs a EAP UI peer module for the given EAP type
|
||||
///
|
||||
peer_ui(_In_ type_t eap_method) : peer_base<_Tcfg, _Tid, _Tint, _Tintres>(eap_method) {}
|
||||
|
||||
///
|
||||
/// Raises the EAP method's specific connection configuration user interface dialog on the client.
|
||||
///
|
||||
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
|
||||
///
|
||||
/// \param[in] hwndParent Parent window
|
||||
/// \param[inout] cfg Configuration to edit
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool invoke_config_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_Inout_ config_type &cfg,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client.
|
||||
///
|
||||
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
|
||||
///
|
||||
/// \param[in] hwndParent Parent window
|
||||
/// \param[in] dwFlags Flags passed to `EapPeerInvokeIdentityUI()` call
|
||||
/// \param[inout] cfg Configuration
|
||||
/// \param[inout] usr User data to edit
|
||||
/// \param[out] ppwszIdentity Pointer to user identity. Free using `module::free_memory()`.
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool invoke_identity_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_In_ DWORD dwFlags,
|
||||
_Inout_ config_type &cfg,
|
||||
_Inout_ identity_type &usr,
|
||||
_Out_ LPWSTR *ppwszIdentity,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
|
||||
///
|
||||
/// Raises a custom interactive user interface dialog for the EAP method on the client.
|
||||
///
|
||||
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
|
||||
///
|
||||
/// \param[in] hwndParent Parent window
|
||||
/// \param[in] req Interactive request
|
||||
/// \param[out] res Interactive response
|
||||
/// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`.
|
||||
///
|
||||
/// \returns
|
||||
/// - \c true if succeeded
|
||||
/// - \c false otherwise. See \p ppEapError for details.
|
||||
///
|
||||
virtual bool invoke_interactive_ui(
|
||||
_In_ HWND hwndParent,
|
||||
_In_ const interactive_request_type &req,
|
||||
_Out_ interactive_response_type &res,
|
||||
_Out_ EAP_ERROR **ppEapError) = 0;
|
||||
};
|
||||
}
|
@@ -23,8 +23,10 @@ wxEAPConfigDialogBase::wxEAPConfigDialogBase( wxWindow* parent, wxWindowID id, c
|
||||
sb_content->Add( m_banner, 0, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
m_providers = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_providers->SetExtraStyle( wxWS_EX_VALIDATE_RECURSIVELY );
|
||||
|
||||
sb_content->Add( m_providers, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
sb_content->Add( m_providers, 1, wxEXPAND|wxALL, 10 );
|
||||
|
||||
m_buttons = new wxStdDialogButtonSizer();
|
||||
m_buttonsOK = new wxButton( this, wxID_OK );
|
||||
@@ -117,6 +119,34 @@ wxEAPBannerPanelBase::~wxEAPBannerPanelBase()
|
||||
{
|
||||
}
|
||||
|
||||
wxEAPProviderLockedBase::wxEAPProviderLockedBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
|
||||
{
|
||||
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK ) );
|
||||
|
||||
wxBoxSizer* sb_provider_locked_horiz;
|
||||
sb_provider_locked_horiz = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_provider_locked_icon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sb_provider_locked_horiz->Add( m_provider_locked_icon, 0, wxALL, 5 );
|
||||
|
||||
m_provider_locked_vert = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_provider_locked_label = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_provider_locked_label->Wrap( 452 );
|
||||
m_provider_locked_vert->Add( m_provider_locked_label, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
sb_provider_locked_horiz->Add( m_provider_locked_vert, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( sb_provider_locked_horiz );
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
wxEAPProviderLockedBase::~wxEAPProviderLockedBase()
|
||||
{
|
||||
}
|
||||
|
||||
wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
|
||||
{
|
||||
wxStaticBoxSizer* sb_credentials;
|
||||
@@ -131,43 +161,86 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
wxBoxSizer* sb_credentials_vert;
|
||||
sb_credentials_vert = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_credentials_label = new wxStaticText( sb_credentials->GetStaticBox(), wxID_ANY, _("Manage your credentials stored in Windows Credential Manager."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_credentials_label = new wxStaticText( sb_credentials->GetStaticBox(), wxID_ANY, _("Manage credentials used to connect."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_credentials_label->Wrap( 446 );
|
||||
sb_credentials_vert->Add( m_credentials_label, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxFlexGridSizer* sb_credentials_tbl;
|
||||
sb_credentials_tbl = new wxFlexGridSizer( 0, 2, 5, 5 );
|
||||
sb_credentials_tbl->AddGrowableCol( 1 );
|
||||
sb_credentials_tbl->SetFlexibleDirection( wxBOTH );
|
||||
sb_credentials_tbl->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
wxBoxSizer* sb_cred_radio;
|
||||
sb_cred_radio = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_identity_label = new wxStaticText( sb_credentials->GetStaticBox(), wxID_ANY, _("Identity:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_identity_label->Wrap( -1 );
|
||||
sb_credentials_tbl->Add( m_identity_label, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
wxBoxSizer* sz_own;
|
||||
sz_own = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_identity = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_identity->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
wxBoxSizer* sz_own_inner;
|
||||
sz_own_inner = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
sb_credentials_tbl->Add( m_identity, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
m_own = new wxRadioButton( sb_credentials->GetStaticBox(), wxID_ANY, _("Use &own credentials:"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
||||
m_own->SetToolTip( _("Select this option if you have your unique credentials to connect") );
|
||||
|
||||
sz_own_inner->Add( m_own, 2, wxEXPAND, 5 );
|
||||
|
||||
m_own_identity = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_own_identity->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
|
||||
sz_own_inner->Add( m_own_identity, 3, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
sb_credentials_vert->Add( sb_credentials_tbl, 0, wxEXPAND|wxALL, 5 );
|
||||
sz_own->Add( sz_own_inner, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
wxBoxSizer* sb_buttons;
|
||||
sb_buttons = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* sb_buttons_own;
|
||||
sb_buttons_own = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_set = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_set->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
m_own_clear = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Clear Credentials"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_own_clear->SetToolTip( _("Click to clear your credentials from Credential Manager.\nNote: You will be prompted to enter credentials when connecting.") );
|
||||
|
||||
sb_buttons->Add( m_set, 0, wxRIGHT, 5 );
|
||||
sb_buttons_own->Add( m_own_clear, 0, wxRIGHT, 5 );
|
||||
|
||||
m_clear = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Clear Credentials"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_clear->SetToolTip( _("Click to clear your credentials from Credential Manager.\nNote: You will be prompted to enter credentials when connecting.") );
|
||||
m_own_set = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_own_set->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
|
||||
sb_buttons->Add( m_clear, 0, wxLEFT, 5 );
|
||||
sb_buttons_own->Add( m_own_set, 0, wxLEFT, 5 );
|
||||
|
||||
|
||||
sb_credentials_vert->Add( sb_buttons, 0, wxALIGN_RIGHT|wxALL, 5 );
|
||||
sz_own->Add( sb_buttons_own, 0, wxALIGN_RIGHT, 5 );
|
||||
|
||||
|
||||
sb_cred_radio->Add( sz_own, 0, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
wxBoxSizer* sz_preshared;
|
||||
sz_preshared = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* sz_preshared_inner;
|
||||
sz_preshared_inner = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_preshared = new wxRadioButton( sb_credentials->GetStaticBox(), wxID_ANY, _("Use &pre-shared credentials:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_preshared->SetToolTip( _("Select this options if all clients connect using the same credentials") );
|
||||
|
||||
sz_preshared_inner->Add( m_preshared, 2, wxEXPAND, 5 );
|
||||
|
||||
m_preshared_identity = new wxTextCtrl( sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
m_preshared_identity->SetToolTip( _("Enter your user name here (user@domain.org, DOMAINUser, etc.)") );
|
||||
|
||||
sz_preshared_inner->Add( m_preshared_identity, 3, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
sz_preshared->Add( sz_preshared_inner, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
wxBoxSizer* sb_buttons_preshared;
|
||||
sb_buttons_preshared = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_preshared_set = new wxButton( sb_credentials->GetStaticBox(), wxID_ANY, _("&Set Credentials..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_preshared_set->SetToolTip( _("Click here to set or modify your credentials") );
|
||||
|
||||
sb_buttons_preshared->Add( m_preshared_set, 0, 0, 5 );
|
||||
|
||||
|
||||
sz_preshared->Add( sb_buttons_preshared, 0, wxALIGN_RIGHT, 5 );
|
||||
|
||||
|
||||
sb_cred_radio->Add( sz_preshared, 0, wxEXPAND|wxTOP, 5 );
|
||||
|
||||
|
||||
sb_credentials_vert->Add( sb_cred_radio, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
|
||||
sb_credentials_horiz->Add( sb_credentials_vert, 1, wxEXPAND, 5 );
|
||||
@@ -181,16 +254,18 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPCredentialsConfigPanelBase::OnUpdateUI ) );
|
||||
m_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSet ), NULL, this );
|
||||
m_clear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClear ), NULL, this );
|
||||
m_own_clear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this );
|
||||
m_own_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this );
|
||||
m_preshared_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this );
|
||||
}
|
||||
|
||||
wxEAPCredentialsConfigPanelBase::~wxEAPCredentialsConfigPanelBase()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPCredentialsConfigPanelBase::OnUpdateUI ) );
|
||||
m_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSet ), NULL, this );
|
||||
m_clear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClear ), NULL, this );
|
||||
m_own_clear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this );
|
||||
m_own_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this );
|
||||
m_preshared_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this );
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,7 @@ class wxEAPBannerPanel;
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/checkbox.h>
|
||||
@@ -91,15 +92,34 @@ class wxEAPBannerPanelBase : public wxPanel
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_title;
|
||||
|
||||
public:
|
||||
wxStaticText* m_title;
|
||||
|
||||
wxEAPBannerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = 0 );
|
||||
~wxEAPBannerPanelBase();
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class wxEAPProviderLockedBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class wxEAPProviderLockedBase : public wxPanel
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxStaticBitmap* m_provider_locked_icon;
|
||||
wxBoxSizer* m_provider_locked_vert;
|
||||
wxStaticText* m_provider_locked_label;
|
||||
|
||||
public:
|
||||
|
||||
wxEAPProviderLockedBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxSIMPLE_BORDER|wxTAB_TRAVERSAL );
|
||||
~wxEAPProviderLockedBase();
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class wxEAPCredentialsConfigPanelBase
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -110,15 +130,19 @@ class wxEAPCredentialsConfigPanelBase : public wxPanel
|
||||
protected:
|
||||
wxStaticBitmap* m_credentials_icon;
|
||||
wxStaticText* m_credentials_label;
|
||||
wxStaticText* m_identity_label;
|
||||
wxTextCtrl* m_identity;
|
||||
wxButton* m_set;
|
||||
wxButton* m_clear;
|
||||
wxRadioButton* m_own;
|
||||
wxTextCtrl* m_own_identity;
|
||||
wxButton* m_own_clear;
|
||||
wxButton* m_own_set;
|
||||
wxRadioButton* m_preshared;
|
||||
wxTextCtrl* m_preshared_identity;
|
||||
wxButton* m_preshared_set;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void OnSet( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnClear( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnClearOwn( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnSetOwn( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnSetPreshared( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
31
lib/EAPBase_UI/src/EAP_UI.cpp
Normal file
31
lib/EAPBase_UI/src/EAP_UI.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// wxEAPBannerPanel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxEAPBannerPanel::wxEAPBannerPanel(wxWindow* parent) : wxEAPBannerPanelBase(parent)
|
||||
{
|
||||
m_title->SetLabelText(wxT(PRODUCT_NAME_STR));
|
||||
}
|
21
lib/EAPBase_UI/src/StdAfx.cpp
Normal file
21
lib/EAPBase_UI/src/StdAfx.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
26
lib/EAPBase_UI/src/StdAfx.h
Normal file
26
lib/EAPBase_UI/src/StdAfx.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2015-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS // Prevent warnings from wxWidgets headers
|
||||
|
||||
#include "../include/EAP_UI.h"
|
||||
#include "../include/Module.h"
|
9
lib/Events/MSIBuild/.gitignore
vendored
Normal file
9
lib/Events/MSIBuild/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*-1.idt
|
||||
/*-2.idt
|
||||
/*-2.idtx
|
||||
/*.Binary-1
|
||||
/*.Binary-2
|
||||
/*.Icon-1
|
||||
/*.Icon-2
|
||||
/*.lst
|
||||
/*.msm
|
BIN
lib/Events/MSIBuild/Makefile
Normal file
BIN
lib/Events/MSIBuild/Makefile
Normal file
Binary file not shown.
2
lib/Events/build/.gitignore
vendored
Normal file
2
lib/Events/build/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/temp
|
||||
/*.user
|
@@ -15,12 +15,12 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\res\EAPMethodETW.man">
|
||||
<CustomBuild Include="..\res\EventsETW.man">
|
||||
<Filter>Resource Files</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EAPMethodEvents.rc">
|
||||
<ResourceCompile Include="Events.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
16
lib/Events/build/Events.props
Normal file
16
lib/Events/build/Events.props
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="..\..\..\include\ResourceDLL.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir>..\..\..\output\$(Platform).$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>temp\Events.$(Platform).$(Configuration).$(PlatformToolset);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
Binary file not shown.
@@ -21,7 +21,7 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>EAPMethodEvents</RootNamespace>
|
||||
<RootNamespace>Events</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -51,27 +51,27 @@
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\include\Win32.props" />
|
||||
<Import Project="..\..\include\Debug.props" />
|
||||
<Import Project="EAPMethodEvents.props" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="Events.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\include\x64.props" />
|
||||
<Import Project="..\..\include\Debug.props" />
|
||||
<Import Project="EAPMethodEvents.props" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="Events.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\include\Win32.props" />
|
||||
<Import Project="..\..\include\Release.props" />
|
||||
<Import Project="EAPMethodEvents.props" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="Events.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\include\x64.props" />
|
||||
<Import Project="..\..\include\Release.props" />
|
||||
<Import Project="EAPMethodEvents.props" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="Events.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
@@ -79,7 +79,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\res\EAPMethodETW.man">
|
||||
<CustomBuild Include="..\res\EventsETW.man">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc.exe "%(Identity)" -u -b -e "h" -h "$(IntDir)." -r "$(IntDir)."</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc.exe "%(Identity)" -u -b -e "h" -h "$(IntDir)." -r "$(IntDir)."</Command>
|
||||
@@ -89,14 +89,14 @@
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling manifest...</Message>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compiling manifest...</Message>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compiling manifest...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EAPMethodEvents.rc" />
|
||||
<ResourceCompile Include="Events.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
Binary file not shown.
2
lib/PAP/build/.gitignore
vendored
Normal file
2
lib/PAP/build/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/temp
|
||||
/*.user
|
12
lib/PAP/build/PAP.props
Normal file
12
lib/PAP/build/PAP.props
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user