--- /dev/null
+#\r
+# Copyright (c) 2006 Secure Endpoints Inc.\r
+#\r
+# Permission is hereby granted, free of charge, to any person\r
+# obtaining a copy of this software and associated documentation files\r
+# (the "Software"), to deal in the Software without restriction,\r
+# including without limitation the rights to use, copy, modify, merge,\r
+# publish, distribute, sublicense, and/or sell copies of the Software,\r
+# and to permit persons to whom the Software is furnished to do so,\r
+# subject to the following conditions:\r
+#\r
+# The above copyright notice and this permission notice shall be\r
+# included in all copies or substantial portions of the Software.\r
+#\r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+# SOFTWARE.\r
+\r
+# Environment variables\r
+# ---------------------\r
+#\r
+# Before running the makefile, set the environment variable KFWSDKDIR\r
+# to the directory containing the Kerberos for Windows SDK version 3.1\r
+# or later. The path should not end in a backslash.\r
+\r
+# Configuration settings\r
+# ----------------------\r
+\r
+# Declare a few things about our plug-in.\r
+\r
+# TODO: Change the plug-in name\r
+PLUGINNAME=MyPlugin\r
+\r
+# TODO: Change the module name\r
+MODULENAME=MyModule\r
+\r
+# TODO: Change the credtype name\r
+CREDTYPENAME=MyCred\r
+\r
+# TODO: Change this as appropriate\r
+DLLBASENAME=myplugin\r
+\r
+# Version info\r
+\r
+# TODO: Change the version numbers\r
+VERMAJOR=0\r
+VERMINOR=1\r
+VERAUX =0\r
+VERPATCH=0\r
+\r
+# Leave these as-is\r
+VERLIST=$(VERMAJOR).$(VERMINOR).$(VERAUX).$(VERPATCH)\r
+VERLISTC=$(VERMAJOR),$(VERMINOR),$(VERAUX),$(VERPATCH)\r
+\r
+# Various checks\r
+\r
+!ifndef MSSDK\r
+! error Platform SDK environment variables not set.\r
+!endif\r
+\r
+!ifndef KFWSDKDIR\r
+! error KFWSDKDIR environment variable not set.\r
+!endif\r
+\r
+# Directories\r
+\r
+BUILDROOT=.\r
+\r
+!ifdef NODEBUG\r
+BUILDTYPE=release\r
+!else\r
+BUILDTYPE=debug\r
+!endif\r
+\r
+!ifndef CPU\r
+!error Environment variable 'CPU' is not defined.\r
+!endif\r
+\r
+DEST=$(BUILDROOT)\dest\$(CPU)_$(BUILDTYPE)\r
+OBJ=$(BUILDROOT)\obj\$(CPU)_$(BUILDTYPE)\r
+\r
+!ifndef NIDMRAWDIRS\r
+KFWINCDIR=$(KFWSDKDIR)\inc\r
+NIDMINCDIR=$(KFWINCDIR)\netidmgr\r
+NIDMLIBDIR=$(KFWSDKDIR)\lib\$(CPU)\r
+!else\r
+NIDMINCDIR=$(KFWSDKDIR)\inc\r
+NIDMLIBDIR=$(KFWSDKDIR)\r
+!endif\r
+\r
+# Win32.mak\r
+\r
+!include <Win32.Mak>\r
+\r
+# Program macros\r
+\r
+CD=cd\r
+RM=del /q\r
+MKDIR=mkdir\r
+RMDIR=rmdir\r
+ECHO=echo\r
+CP=copy /y\r
+LINK=link\r
+MC=mc\r
+\r
+# Lots more macros\r
+\r
+incflags = -I$(NIDMINCDIR) -I$(OBJ) -I.\r
+rincflags = /i $(NIDMINCDIR) /i $(OBJ) /i .\r
+\r
+ldebug = $(ldebug) /DEBUG\r
+cdebug = $(cdebug) -Os -Zi\r
+\r
+cdefines = $(cdefines) -DUNICODE -D_UNICODE\r
+\r
+C2OBJ=$(CC) $(cdebug) $(cflags) $(incflags) $(cdefines) /Fo"$@" /c $**\r
+\r
+DLLGUILINK=$(LINK) /NOLOGO $(ldebug) $(dlllflags) $(guilibsmt) /OUT:$@ /IMPLIB:$(DEST)\$(@B).lib $**\r
+\r
+DLLRESLINK=$(LINK) /NOLOGO /DLL /NOENTRY /MACHINE:$(PROCESSOR_ARCHITECTURE) /OUT:$@ $**\r
+\r
+RC2RES=$(RC) $(RFLAGS) $(rincflags) /fo $@ $**\r
+\r
+MC2RC=$(MC) $(MCFLAGS) -h $(OBJ)\ -m 1024 -r $(OBJ)\ -x $(OBJ)\ $**\r
+\r
+{}.c{$(OBJ)}.obj:\r
+ $(C2OBJ)\r
+\r
+{$(OBJ)}.c{$(OBJ)}.obj:\r
+ $(C2OBJ)\r
+\r
+{}.rc{$(OBJ)}.res:\r
+ $(RC2RES)\r
+\r
+mkdirs::\r
+!if !exist($(DEST))\r
+ $(MKDIR) $(DEST)\r
+!endif\r
+!if !exist($(OBJ))\r
+ $(MKDIR) $(OBJ)\r
+!endif\r
+\r
+clean::\r
+ $(RM) $(OBJ)\*.*\r
+ $(RM) $(DEST)\*.*\r
+\r
+.SUFFIXES: .h\r
+\r
+#\r
+# Manifest handling\r
+#\r
+# Starting with Visual Studio 8, the C compiler and the linker\r
+# generate manifests so that the applications will link with the\r
+# correct side-by-side DLLs at run-time. These are required for\r
+# correct operation under Windows XP. We also have custom manifests\r
+# which need to be merged with the manifests that VS creates.\r
+#\r
+# The syntax for invoking the _VC_MANIFEST_EMBED_foo macro is:\r
+# $(_VC_MANIFEST_EMBED_???) <any additional manifests that need to be merged in>\r
+#\r
+\r
+!ifndef MT\r
+MT=mt.exe -nologo\r
+!endif\r
+\r
+_VC_MANIFEST_EMBED_EXE= \\r
+if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest\r
+\r
+_VC_MANIFEST_EMBED_DLL=$(_VC_MANIFEST_EMBED_EXE)\r
+\r
+# Note that if you are merging manifests, then the VS generated\r
+# manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???.\r
+# This ensures that even if the DLL or EXE is executed in-place, the\r
+# embedded manifest will be used. Otherwise the $@.manifest file will\r
+# be used.\r
+_VC_MANIFEST_CLEAN= \\r
+if exist $@.manifest $(RM) $@.manifest\r
+\r
+# End of manifest handling\r
+\r
+\r
+# Now for the actual build stuff\r
+\r
+DLL=$(DEST)\$(DLLBASENAME).dll\r
+\r
+LIBFILES= \\r
+ $(NIDMLIBDIR)\nidmgr32.lib\r
+\r
+OBJFILES= \\r
+ $(OBJ)\credacq.obj \\r
+ $(OBJ)\credtype.obj \\r
+ $(OBJ)\main.obj \\r
+ $(OBJ)\plugin.obj \\r
+ $(OBJ)\proppage.obj \\r
+ $(OBJ)\config_main.obj \\r
+ $(OBJ)\config_id.obj \\r
+ $(OBJ)\config_ids.obj\r
+\r
+DLLRESFILE=$(OBJ)\version.res\r
+\r
+CONFIGHEADER=$(OBJ)\credacq_config.h\r
+\r
+all: mkdirs $(CONFIGHEADER) $(DLL) lang\r
+\r
+$(CONFIGHEADER): Makefile\r
+ $(CP) << $@\r
+/* This is a generated file. Do not modify directly. */\r
+\r
+#pragma once\r
+\r
+#define MYPLUGIN_DLLBASE "$(DLLBASENAME)"\r
+\r
+#define MYPLUGIN_NAME "$(PLUGINNAME)"\r
+\r
+#define MYMODULE_NAME "$(MODULENAME)"\r
+\r
+#define MYCREDTYPE_NAME "$(CREDTYPENAME)"\r
+\r
+#define VERSION_MAJOR $(VERMAJOR)\r
+#define VERSION_MINOR $(VERMINOR)\r
+#define VERSION_AUX $(VERAUX)\r
+#define VERSION_PATCH $(VERPATCH)\r
+\r
+#define VERSION_LIST $(VERLIST)\r
+#define VERSION_LISTC $(VERLISTC)\r
+#define VERSION_STRING "$(VERLIST)"\r
+\r
+<<\r
+\r
+clean::\r
+ $(RM) $(CONFIGHEADER)\r
+\r
+$(DLL): $(OBJFILES) $(DLLRESFILE)\r
+ $(DLLGUILINK) $(LIBFILES)\r
+ $(_VC_MANIFEST_EMBED_DLL)\r
+ $(_VC_MANIFEST_CLEAN)\r
+\r
+clean::\r
+ $(RM) $(DLL)\r
+\r
+# Language specific resources\r
+\r
+# (repeat the following block as needed, redefining LANG for each\r
+# supported language)\r
+\r
+# English-US\r
+LANG=en_us\r
+\r
+LANGDLL=$(DEST)\$(DLLBASENAME)_$(LANG).dll\r
+\r
+lang:: $(LANGDLL)\r
+\r
+$(LANGDLL): $(OBJ)\langres_$(LANG).res $(OBJ)\version_$(LANG).res\r
+ $(DLLRESLINK)\r
+ $(_VC_MANIFEST_EMBED_DLL)\r
+ $(_VC_MANIFEST_CLEAN)\r
+\r
+clean::\r
+ $(RM) $(LANGDLL)\r
+\r
+$(OBJ)\version_$(LANG).res: version.rc\r
+ $(RC) $(RFLAGS) $(rincflags) /d LANGRES /d LANG_$(LANG) /fo $@ $**\r
+\r
+clean::\r
+ $(RM) $(OBJ)\version_$(LANG).res\r
+\r
+$(OBJ)\langres_$(LANG).res: lang\$(LANG)\langres.rc\r
+ $(RC2RES)\r
+\r
+clean::\r
+ $(RM) $(OBJ)\langres_$(LANG).res\r
+\r
+# /English-US\r
--- /dev/null
+\r
+ Network Identity Manager\r
+\r
+ Credentials Provider Plug-in Template\r
+\r
+------------------------------------------------------------------\r
+\r
+ CONTENTS\r
+\r
+ 1. INTRODUCTION\r
+ 2. COPYRIGHT AND LICENSE\r
+ 3. ROADMAP OF THE TEMPLATE\r
+ 4. BUILD REQUIREMENTS\r
+ 5. BUILDING\r
+ 6. RUNNING THE PLUG-IN\r
+ 7. KNOWN ISSUES\r
+ 8. SUPPORT / BUG REPORTS\r
+\r
+------------------------------------------------------------------\r
+\r
+1. INTRODUCTION\r
+\r
+ This directory and subdirectories contain a plug-in template for\r
+ creating a credentials provider plug-in for Network Identity\r
+ Manager. A credentials manager plug-in provides knowledge of a\r
+ specifc credentials type to the NetIDMgr application and manages\r
+ those credentials on behalf of NetIDMgr.\r
+\r
+ This version of the template adheres to the following version\r
+ constraints:\r
+\r
+ Network Identity Manager API version : 5\r
+\r
+ (This API version corresponds to the MIT Kerberos for Windows\r
+ version 3.1).\r
+\r
+ The source files in this template can be used to build the plug-in\r
+ DLL and the US English resource DLL for the plug-in. In its\r
+ current form, the plug-in doesn't do any credentials management.\r
+ However, it implements a number of stub functions that can be\r
+ filled in to perform the necessary credentials management\r
+ operations.\r
+\r
+------------------------------------------------------------------\r
+\r
+2. COPYRIGHT AND LICENSE\r
+\r
+ Copyright (c) 2006 Secure Endpoints Inc.\r
+\r
+ Permission is hereby granted, free of charge, to any person\r
+ obtaining a copy of this software and associated documentation\r
+ files (the "Software"), to deal in the Software without\r
+ restriction, including without limitation the rights to use, copy,\r
+ modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ of the Software, and to permit persons to whom the Software is\r
+ furnished to do so, subject to the following conditions:\r
+\r
+ The above copyright notice and this permission notice shall be\r
+ included in all copies or substantial portions of the Software.\r
+\r
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r
+ DEALINGS IN THE SOFTWARE.\r
+\r
+------------------------------------------------------------------\r
+\r
+3. ROADMAP OF THE TEMPLATE\r
+\r
+ The template consists of the following files and directories:\r
+\r
+ .\README\r
+\r
+ This file.\r
+\r
+ .\Makefile\r
+\r
+ The primary (and only) Makefile used by 'nmake' to build the\r
+ plug-in. In addition to providing build directives, it also\r
+ contains a set of macros which defines the names and version\r
+ information that is used throughout the plug-in code.\r
+\r
+ Look for the 'Configuration Settings' section of the Makefile\r
+ for the macros. If you are basing a plug-in on this template,\r
+ you will want to change these macros. These macros will be\r
+ used to generate 'credacq_config.h', a header file included by\r
+ 'credprov.h' so that the values of the macros can be used in C\r
+ code.\r
+\r
+ .\credprov.h\r
+\r
+ The main header file for all the C source files in the\r
+ plug-in.\r
+\r
+ .\main.c\r
+\r
+ Provides the entry points for the module.\r
+\r
+ .\plugin.c\r
+\r
+ Provides the message processing functions and support routines\r
+ for implementing the plug-in. Note that some of the message\r
+ processing routines have been moved to other sources files\r
+ based on their use.\r
+\r
+ .\credtype.c\r
+\r
+ Functions for handling our credentials type.\r
+\r
+ .\credacq.c\r
+\r
+ Handlers for the credentials acquisition messages including\r
+ handling the user interface for the new credentials dialogs.\r
+\r
+ .\proppage.c\r
+\r
+ Dialog procedures and support code for displaying property\r
+ sheets for credentials that belong to our credentials type.\r
+\r
+ .\config_main.c\r
+\r
+ Dialog procedures and support code for providing the general\r
+ configuration panel for this plug-in.\r
+\r
+ .\config_id.c\r
+\r
+ Dialog procedures and support code for providing per-identity\r
+ configuration for this plug-in.\r
+\r
+ .\config_ids.c\r
+\r
+ Dialog procedures and support code for providing configuration\r
+ for defaults across all identities.\r
+\r
+ .\version.rc\r
+\r
+ Version information for the plug-in as well as all the\r
+ language resource DLLs.\r
+\r
+ .\langres.h\r
+\r
+ Declarations for the language resources (see below). In its\r
+ current form, it was generated via Visual Studio while editing\r
+ the language resouces file.\r
+\r
+ .\images\plugin.ico\r
+\r
+ A generic plug-in icon.\r
+\r
+ .\lang\en_us\langres.rc\r
+\r
+ US-English language resources. This will be used to create\r
+ the language resource DLL.\r
+\r
+------------------------------------------------------------------\r
+\r
+4. BUILD REQUIREMENTS\r
+\r
+ Microsoft(R) Platform SDK (Windows Server 2003 or later)\r
+\r
+ (http://www.microsoft.com/msdownload/platformsdk/sdkupdate/)\r
+\r
+ Microsoft(R) Visual C++ (Visual Studio 2003 or later)\r
+\r
+ Although not tested, the template should build using the\r
+ Microsoft Visual C++ toolkit.\r
+\r
+ MIT Kerberos for Windows (version 3.1 or later) SDK\r
+\r
+ At the current time, version 3.1 is still in beta. However,\r
+ the template will not work with the 3.0 SDK due to a number of\r
+ changes that were made to the NetIDMgr API between 3.0 and\r
+ 3.1.\r
+\r
+------------------------------------------------------------------\r
+\r
+5. BUILDING\r
+\r
+ The build process is fairly starightforward. The source is set up\r
+ to build using 'nmake', a build tool distributed with the Platform\r
+ SDK as well as with Visual Studio.\r
+\r
+ 1. Open a command prompt with a suitable build environment.\r
+\r
+ From a plain command prompt, you can set up a debug build\r
+ environment targetting Windows XP (32-bit) with:\r
+\r
+ > "%PROGRAMFILES%\Microsoft Platform SDK\SetEnv.Cmd" /XP32 /DEBUG\r
+\r
+ 2. Set the environment variable KFWSDKDIR to point to the root of\r
+ the Kerberos for Windows 3.1 SDK. (i.e. %KFWSDKDIR%\inc\r
+ should be the include directory of the SDK)\r
+\r
+ > SET KFWSDKDIR=%PROGRAMFILES%\MIT\Kerberos\r
+\r
+ 3. Start the build:\r
+\r
+ > NMAKE all\r
+\r
+ The build target 'all' builds the plug-in and the language\r
+ resources. There is an additional build target 'clean' which\r
+ removes the temporary files and the binaries generated during\r
+ the build.\r
+\r
+ Assuming everything goes well, the plug-in binaries should be\r
+ created under a subdirectory under 'dest'. The name of the\r
+ subdirectory reflects the target architecture and the build\r
+ type ('debug' or 'release').\r
+\r
+------------------------------------------------------------------\r
+\r
+6. RUNNING THE PLUG-IN\r
+\r
+ Once the binaries for the plug-in have been built, you need to\r
+ register the plug-in with NetIDMgr by adding a registry value as\r
+ follows:\r
+\r
+ [HKEY_CURRENT_USER\Software\MIT\NetIDMgr\PluginManager\Modules\<Module name>]\r
+ "ImagePath"="<path>"\r
+\r
+ The <path> should be the full path to the plug-in DLL.\r
+\r
+ <Module name> is the name of the module that you built. The\r
+ default value specified in the template is 'MyModule'. This is\r
+ the value of the macro 'MODULENAME' defined in the 'Makefile'.\r
+\r
+ Once this is done, you need to restart NetIDMgr so that it will\r
+ pick up the new plug-in.\r
+\r
+------------------------------------------------------------------\r
+\r
+7. KNOWN ISSUES\r
+\r
+ 1. With the current MIT Kerberos for Windows 3.1 beta, NetIDMgr\r
+ will fail to load the plug-in when tries to load the plug-in\r
+ for the first time. Restarting NetIDMgr will fix the problem.\r
+ This will be fixed in a future beta and the final release of\r
+ KfW 3.1\r
+\r
+------------------------------------------------------------------\r
+\r
+8. SUPPORT / BUG REPORTS\r
+\r
+ Problems should be sent to netidmgr@secure-endpoints.com\r
+\r
+------------------------------------------------------------------\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+#include <assert.h>\r
+\r
+/* Dialog procedures and support functions for handling configuration\r
+ dialogs for per-identity configuration. When the configuration\r
+ dialog is activated, an instance of this dialog will be created for\r
+ each identity that the user touches. */\r
+\r
+/* The structure that we use to hold state information for the\r
+ dialog. */\r
+typedef struct tag_config_id_dlg_data {\r
+ khui_config_init_data cfg; /* instance information for this\r
+ dialog */\r
+\r
+ khm_handle ident; /* handle to the identity for this\r
+ dialog */\r
+\r
+ /* TODO: Add any fields for holding state here */\r
+} config_id_dlg_data;\r
+\r
+INT_PTR CALLBACK\r
+config_id_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ config_id_dlg_data * d;\r
+\r
+ switch (uMsg) {\r
+ case WM_INITDIALOG:\r
+ {\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+ khm_int32 rv;\r
+\r
+ d = malloc(sizeof(*d));\r
+ assert(d);\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ /* for subpanels, lParam is a pointer to a\r
+ khui_config_init_data strucutre that provides the\r
+ instance and context information. It's not a\r
+ persistent strucutre, so we have to make a copy. */\r
+ d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+ cb = sizeof(idname);\r
+ rv = khui_cfg_get_name(d->cfg.ctx_node, idname, &cb);\r
+ assert(KHM_SUCCEEDED(rv));\r
+\r
+ rv = kcdb_identity_create(idname, 0, &d->ident);\r
+ assert(KHM_SUCCEEDED(rv));\r
+\r
+ /* TODO: perform any other required initialization */\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+ }\r
+ break;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ d = (config_id_dlg_data *)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ /* TODO: apply changes */\r
+\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ {\r
+ d = (config_id_dlg_data *)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (d) {\r
+ if (d->ident)\r
+ kcdb_identity_release(d->ident);\r
+\r
+ /* TODO: perform any other required uninitialization */\r
+\r
+ free(d);\r
+ }\r
+ }\r
+ break;\r
+ }\r
+\r
+ return FALSE;\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+#include<assert.h>\r
+\r
+/* Dialog procedures and support functions for handling configuration\r
+ dialogs for all identities. */\r
+\r
+/* The structure that we use to hold state information for the\r
+ dialog. */\r
+typedef struct tag_config_ids_dlg_data {\r
+ khui_config_init_data cfg; /* instance information for this\r
+ dialog */\r
+\r
+ /* TODO: Add any fields for holding state here */\r
+} config_ids_dlg_data;\r
+\r
+INT_PTR CALLBACK\r
+config_ids_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ config_ids_dlg_data * d;\r
+\r
+ switch (uMsg) {\r
+ case WM_INITDIALOG:\r
+ {\r
+ d = malloc(sizeof(*d));\r
+ assert(d);\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ /* for subpanels, lParam is a pointer to a\r
+ khui_config_init_data strucutre that provides the\r
+ instance and context information. It's not a\r
+ persistent strucutre, so we have to make a copy. */\r
+ d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+ /* TODO: perform any additional initialization */\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+ }\r
+ break;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ d = (config_ids_dlg_data *)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ /* TODO: apply changes */\r
+\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ d = (config_ids_dlg_data *)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (d) {\r
+ /* TODO: Perform any additional uninitialization */\r
+\r
+ free (d);\r
+ }\r
+ break;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+#include <assert.h>\r
+\r
+/* Dialog procedures and support functions for handling configuration\r
+ dialogs for general plug-in configuration. */\r
+\r
+/* Structure for holding dialog data for the configuration window. */\r
+typedef struct tag_config_main_dlg_data {\r
+ khui_config_node cnode;\r
+\r
+ /* TODO: add fields as needed */\r
+} config_main_dlg_data;\r
+\r
+INT_PTR CALLBACK\r
+config_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ config_main_dlg_data * d;\r
+\r
+ switch (uMsg) {\r
+ case WM_INITDIALOG:\r
+ d = malloc(sizeof(*d));\r
+ assert(d);\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ /* for configuration panels that are not subpanels, lParam is\r
+ a held handle to the configuration node. The handle will\r
+ be held for the lifetime of the window. */\r
+\r
+ d->cnode = (khui_config_node) lParam;\r
+\r
+ /* TODO: perform any other required initialization stuff\r
+ here */\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+ break;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ {\r
+ d = (config_main_dlg_data *)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ /* WMCFG_APPLY is the only notification we care about */\r
+\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ /* TODO: Apply changes and update the state */\r
+\r
+ return TRUE;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ d = (config_main_dlg_data *)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ /* TODO: perform any other required uninitialization here */\r
+\r
+ if (d)\r
+ free(d);\r
+\r
+ break;\r
+ }\r
+\r
+ return FALSE;\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+#include<assert.h>\r
+\r
+/* This file provides handlers for the credentials acquisition\r
+ messages including handling the user interface for the new\r
+ credentials dialogs. */\r
+\r
+/*********************************************************************\r
+\r
+These are stubs for the Window message for the dialog panel. This\r
+dialog panel is the one that is added to the new credentials window\r
+for obtaining new credentials.\r
+\r
+Note that all the UI callbacks run under the UI thread.\r
+\r
+ *********************************************************************/\r
+\r
+/* This structure will hold all the state information we will need to\r
+ access from the new credentials panel for our credentials type. */\r
+struct nc_dialog_data {\r
+ khui_new_creds * nc;\r
+ khui_new_creds_by_type * nct;\r
+\r
+ /* TODO: add any other state information here */\r
+};\r
+\r
+/* Note: This callback runs under the UI thread */\r
+INT_PTR\r
+handle_wm_initdialog(HWND hwnd, WPARAM wParam, LPARAM lParam) {\r
+ khui_new_creds * nc = NULL;\r
+ khui_new_creds_by_type * nct = NULL;\r
+ struct nc_dialog_data * d = NULL;\r
+\r
+ nc = (khui_new_creds *) lParam;\r
+ khui_cw_find_type(nc, credtype_id, &nct);\r
+\r
+ assert(nct);\r
+\r
+ d = malloc(sizeof(*d));\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ d->nc = nc;\r
+ d->nct = nct;\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) d);\r
+#pragma warning(pop)\r
+\r
+ nct->aux = (LPARAM) d; /* we can use the auxiliary field to\r
+ hold a pointer to d */\r
+\r
+ /* TODO: Perform any additional initialization here */\r
+\r
+ return FALSE;\r
+}\r
+\r
+/* Note: This callback runs under the UI thread */\r
+INT_PTR\r
+handle_khui_wm_nc_notify(HWND hwnd, WPARAM wParam, LPARAM lParam) {\r
+\r
+ struct nc_dialog_data * d;\r
+\r
+ /* Refer to the khui_wm_nc_notifications enumeration in the\r
+ NetIDMgr SDK for the full list of notification messages that\r
+ can be sent. */\r
+\r
+ d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (!d)\r
+ return TRUE;\r
+\r
+ /* these should be set by now */\r
+ assert(d->nc);\r
+ assert(d->nct);\r
+\r
+ switch (HIWORD(wParam)) {\r
+ case WMNC_UPDATE_CREDTEXT:\r
+ {\r
+ wchar_t fmt[KHUI_MAXCCH_LONG_DESC];\r
+ wchar_t tbuf[256];\r
+\r
+ /* we are being requested to update the credentials\r
+ text. We already allocated a buffer when we created the\r
+ nct structure. So we can just set the text here.*/\r
+\r
+ /* TODO: The credtext should reflect the credentials that\r
+ will be obtained when the new credentials operation\r
+ completes. */\r
+\r
+ LoadString(hResModule, IDS_NC_CT_TEMPLATE,\r
+ fmt, ARRAYLENGTH(fmt));\r
+\r
+ LoadString(hResModule, IDS_GEN_NONE,\r
+ tbuf, ARRAYLENGTH(tbuf));\r
+\r
+ assert(d->nct->credtext);\r
+\r
+ StringCbPrintf(d->nct->credtext, KHUI_MAXCB_LONG_DESC,\r
+ fmt, tbuf);\r
+ }\r
+ break;\r
+\r
+ case WMNC_CREDTEXT_LINK:\r
+ break;\r
+\r
+ case WMNC_IDENTITY_CHANGE:\r
+ break;\r
+\r
+ case WMNC_DIALOG_PREPROCESS:\r
+ break;\r
+ }\r
+\r
+ return TRUE;\r
+}\r
+\r
+/* Note: This callback runs under the UI thread */\r
+INT_PTR\r
+handle_wm_command(HWND hwnd, WPARAM wParam, LPARAM lParam) {\r
+\r
+ struct nc_dialog_data * d;\r
+\r
+ d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ /* TODO: handle WM_COMMAND */\r
+ return FALSE;\r
+}\r
+\r
+/* Note: This callback runs under the UI thread */\r
+INT_PTR\r
+handle_wm_destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) {\r
+\r
+ struct nc_dialog_data * d;\r
+\r
+ d = (struct nc_dialog_data *) GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (d) {\r
+ d->nc = NULL;\r
+ d->nct = NULL;\r
+\r
+ free(d);\r
+ }\r
+\r
+ /* TODO: Perform any additional uninitialization */\r
+\r
+ return FALSE;\r
+}\r
+\r
+/* Dialog procedure for the new credentials panel for our credentials\r
+ type. We just dispatch messages here to other functions here.\r
+\r
+ Note that this procedure runs under the UI thread.\r
+ */\r
+INT_PTR CALLBACK\r
+nc_dlg_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ switch (uMsg) {\r
+ case WM_INITDIALOG:\r
+ return handle_wm_initdialog(hwnd, wParam, lParam);\r
+\r
+ case WM_COMMAND:\r
+ return handle_wm_command(hwnd, wParam, lParam);\r
+\r
+ case KHUI_WM_NC_NOTIFY:\r
+ return handle_khui_wm_nc_notify(hwnd, wParam, lParam);\r
+\r
+ case WM_DESTROY:\r
+ return handle_wm_destroy(hwnd, wParam, lParam);\r
+\r
+ /* TODO: add code for handling other windows messages here. */\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/*******************************************************************\r
+\r
+The following section contains function stubs for each of the\r
+credentials messages that a credentials provider is likely to want to\r
+handle. It doesn't include a few messages, but they should be easy to\r
+add. Please see the documentation for each of the KMSG_CRED_*\r
+messages for documentation on how to handle each of the messages.\r
+\r
+********************************************************************/\r
+\r
+\r
+/* Handler for KMSG_CRED_NEW_CREDS */\r
+khm_int32\r
+handle_kmsg_cred_new_creds(khui_new_creds * nc) {\r
+\r
+ wchar_t wshortdesc[KHUI_MAXCCH_SHORT_DESC];\r
+ size_t cb = 0;\r
+ khui_new_creds_by_type * nct = NULL;\r
+\r
+ /* This is a minimal handler that just adds a dialog pane to the\r
+ new credentials window to handle new credentials acquisition\r
+ for this credentials type. */\r
+\r
+ /* TODO: add additional initialization etc. as needed */\r
+\r
+ nct = malloc(sizeof(*nct));\r
+ ZeroMemory(nct, sizeof(*nct));\r
+\r
+ nct->type = credtype_id;\r
+ nct->ordinal = -1;\r
+\r
+ LoadString(hResModule, IDS_CT_SHORT_DESC,\r
+ wshortdesc, ARRAYLENGTH(wshortdesc));\r
+ StringCbLength(wshortdesc, sizeof(wshortdesc), &cb);\r
+#ifdef DEBUG\r
+ assert(cb > 0);\r
+#endif\r
+ cb += sizeof(wchar_t);\r
+\r
+ nct->name = malloc(cb);\r
+ StringCbCopy(nct->name, cb, wshortdesc);\r
+\r
+ /* while we are at it, we should also allocate space for the\r
+ credential text. */\r
+ nct->credtext = malloc(KHUI_MAXCB_LONG_DESC);\r
+ ZeroMemory(nct->credtext, KHUI_MAXCB_LONG_DESC);\r
+\r
+ nct->h_module = hResModule;\r
+ nct->dlg_proc = nc_dlg_proc;\r
+ nct->dlg_template = MAKEINTRESOURCE(IDD_NEW_CREDS);\r
+\r
+ khui_cw_add_type(nc, nct);\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_RENEW_CREDS */\r
+khm_int32\r
+handle_kmsg_cred_renew_creds(khui_new_creds * nc) {\r
+\r
+ khui_new_creds_by_type * nct;\r
+\r
+ /* This is a minimal handler that just adds this credential type\r
+ to the list of credential types that are participating in this\r
+ renewal operation. */\r
+\r
+ /* TODO: add additional initialization etc. as needed */\r
+\r
+ nct = malloc(sizeof(*nct));\r
+ ZeroMemory(nct, sizeof(*nct));\r
+\r
+ nct->type = credtype_id;\r
+\r
+ khui_cw_add_type(nc, nct);\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_DIALOG_PRESTART */\r
+khm_int32\r
+handle_kmsg_cred_dialog_prestart(khui_new_creds * nc) {\r
+ /* TODO: Handle this message */\r
+\r
+ /* The message is sent after the dialog has been created. The\r
+ window handle for the created dialog can be accessed through\r
+ the hwnd_panel member of the khui_new_creds_by_type structure\r
+ that was added for this credentials type. */\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_DIALOG_NEW_IDENTITY */\r
+/* Not a message sent out by NetIDMgr. See documentation of\r
+ KMSG_CRED_DIALOG_NEW_IDENTITY */\r
+khm_int32\r
+handle_kmsg_cred_dialog_new_identity(khm_ui_4 uparam,\r
+ void * vparam) {\r
+ /* TODO: Handle this message */\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_DIALOG_NEW_OPTIONS */\r
+/* Not a message sent out by NetIDMgr. See documentation of\r
+ KMSG_CRED_DIALOG_NEW_OPTIONS */\r
+khm_int32\r
+handle_kmsg_cred_dialog_new_options(khm_ui_4 uparam,\r
+ void * vparam) {\r
+ /* TODO: Handle this message */\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_PROCESS */\r
+khm_int32\r
+handle_kmsg_cred_process(khui_new_creds * nc) {\r
+ /* TODO: Handle this message */\r
+\r
+ /* This is where the credentials acquisition should be performed\r
+ as determined by the UI. Note that this message is sent even\r
+ when the user clicks 'cancel'. The value of nc->result should\r
+ be checked before performing any credentials acquisition. If\r
+ the value is KHUI_NC_RESULT_CANCEL, then no credentials should\r
+ be acquired. Otherwise, the value would be\r
+ KHUI_NC_RESULT_PROCESS. */\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_END */\r
+khm_int32\r
+handle_kmsg_cred_end(khui_new_creds * nc) {\r
+\r
+ khui_new_creds_by_type * nct = NULL;\r
+\r
+ /* TODO: Perform any additional uninitialization as needed. */\r
+\r
+ khui_cw_find_type(nc, credtype_id, &nct);\r
+\r
+ if (nct) {\r
+\r
+ khui_cw_del_type(nc, credtype_id);\r
+\r
+ if (nct->name)\r
+ free(nct->name);\r
+ if (nct->credtext)\r
+ free(nct->credtext);\r
+\r
+ free(nct);\r
+\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for KMSG_CRED_IMPORT */\r
+khm_int32\r
+handle_kmsg_cred_import(void) {\r
+\r
+ /* TODO: Handle this message */\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+\r
+/******************************************************\r
+ Dispatch each message to individual handlers above.\r
+ */\r
+khm_int32 KHMAPI\r
+handle_cred_acq_msg(khm_int32 msg_type,\r
+ khm_int32 msg_subtype,\r
+ khm_ui_4 uparam,\r
+ void * vparam) {\r
+\r
+ khm_int32 rv = KHM_ERROR_SUCCESS;\r
+\r
+ switch(msg_subtype) {\r
+ case KMSG_CRED_NEW_CREDS:\r
+ return handle_kmsg_cred_new_creds((khui_new_creds *) vparam);\r
+\r
+ case KMSG_CRED_RENEW_CREDS:\r
+ return handle_kmsg_cred_renew_creds((khui_new_creds *) vparam);\r
+\r
+ case KMSG_CRED_DIALOG_PRESTART:\r
+ return handle_kmsg_cred_dialog_prestart((khui_new_creds *) vparam);\r
+\r
+ case KMSG_CRED_PROCESS:\r
+ return handle_kmsg_cred_process((khui_new_creds *) vparam);\r
+\r
+ case KMSG_CRED_DIALOG_NEW_IDENTITY:\r
+ return handle_kmsg_cred_dialog_new_identity(uparam, vparam);\r
+\r
+ case KMSG_CRED_DIALOG_NEW_OPTIONS:\r
+ return handle_kmsg_cred_dialog_new_options(uparam, vparam);\r
+\r
+ case KMSG_CRED_END:\r
+ return handle_kmsg_cred_end((khui_new_creds *) vparam);\r
+\r
+ case KMSG_CRED_IMPORT:\r
+ return handle_kmsg_cred_import();\r
+ }\r
+\r
+ return rv;\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+/* only include this header file once */\r
+#pragma once\r
+\r
+#ifndef _UNICODE\r
+#ifndef RC_INVOKED\r
+/* This template relies on _UNICODE being defined to call the correct\r
+ APIs. */\r
+#error This template needs to be compiled with _UNICODE\r
+#endif\r
+#endif\r
+\r
+/* Pull in configuration macros from the Makefile */\r
+#include "credacq_config.h"\r
+\r
+/* declare a few macros about our plugin */\r
+\r
+/* The following macro will be used throughout the template to refer\r
+ to the name of the plugin. The macro is actually defined the\r
+ Makefile generated configuration header file. Modify the\r
+ PLUGINNAME Makefile macro.*/\r
+#ifndef MYPLUGIN_NAME\r
+#error MYPLUGIN_NAME not defined\r
+#endif\r
+\r
+/* Also define the unicde equivalent of the name. In general strings\r
+ in NetIDMgr are unicode. */\r
+#define MYPLUGIN_NAMEW _T(MYPLUGIN_NAME)\r
+\r
+/* The name of the module. This is distinct from the name of the\r
+ plugin for several reasons. One of which is that a single module\r
+ can provide multiple plugins. Also, having a module name distinct\r
+ from a plugin name allows multiple vendors to provide the same\r
+ plugin. For example, the module name for the MIT Kerberos 5 plugin\r
+ is MITKrb5 while the plugin name is Krb5Cred. The macro is\r
+ actually defined in the Makefile generated configuration header\r
+ file. Modify the MODULENAME Makefile macro.*/\r
+#ifndef MYMODULE_NAME\r
+#error MYMODULE_NAME not defined\r
+#endif\r
+\r
+#define MYMODULE_NAMEW _T(MYMODULE_NAME)\r
+\r
+/* When logging events from our plugin, the event logging API can\r
+ optionally take a facility name to provide a friendly label to\r
+ identify where each event came from. We will default to the plugin\r
+ name, although it can be anything. */\r
+#define MYPLUGIN_FACILITYW MYPLUGIN_NAMEW\r
+\r
+/* Base name of the DLL that will be providing the plugin. We use it\r
+ to construct names of the DLLs that will contain localized\r
+ resources. This is defined in the Makefile and fed in to the build\r
+ through there. The macro to change in the Makefile is\r
+ DLLBASENAME. */\r
+#ifndef MYPLUGIN_DLLBASE\r
+#error MYPLUGIN_DLLBASE Not defined!\r
+#endif\r
+\r
+#define MYPLUGIN_DLLBASEW _T(MYPLUGIN_DLLBASE)\r
+\r
+/* Name of the credentials type that will be registered by the plugin.\r
+ This macro is actually defined in the Makefile generated\r
+ configuration header file. Change the CREDTYPENAME macro in the\r
+ Makefile. */\r
+#ifndef MYCREDTYPE_NAME\r
+#error MYCREDTYPE_NAME not defined\r
+#endif\r
+\r
+#define MYCREDTYPE_NAMEW _T(MYCREDTYPE_NAME)\r
+\r
+/* Configuration node names. We just concatenate a few strings\r
+ together, although you should feel free to completely define your\r
+ own. */\r
+\r
+#define CONFIGNODE_MAIN MYCREDTYPE_NAMEW L"Config"\r
+#define CONFIGNODE_ALL_ID MYCREDTYPE_NAMEW L"AllIdents"\r
+#define CONFIGNODE_PER_ID MYCREDTYPE_NAMEW L"PerIdent"\r
+\r
+#include<windows.h>\r
+/* include the standard NetIDMgr header files */\r
+#include<netidmgr.h>\r
+#include<tchar.h>\r
+\r
+/* declarations for language resources */\r
+#include "langres.h"\r
+\r
+#ifndef NOSTRSAFE\r
+#include<strsafe.h>\r
+#endif\r
+\r
+/***************************************************\r
+ Externals\r
+***************************************************/\r
+\r
+extern kmm_module h_khModule;\r
+extern HINSTANCE hInstance;\r
+extern HMODULE hResModule;\r
+\r
+extern const wchar_t * my_facility;\r
+\r
+extern khm_int32 credtype_id;\r
+\r
+/* Function declarations */\r
+\r
+/* in plugin.c */\r
+khm_int32 KHMAPI\r
+plugin_msg_proc(khm_int32 msg_type,\r
+ khm_int32 msg_subtype,\r
+ khm_ui_4 uparam,\r
+ void * vparam);\r
+\r
+/* in credtype.c */\r
+khm_int32 KHMAPI\r
+cred_is_equal(khm_handle cred1,\r
+ khm_handle cred2,\r
+ void * rock);\r
+\r
+/* in credacq.c */\r
+khm_int32 KHMAPI\r
+handle_cred_acq_msg(khm_int32 msg_type,\r
+ khm_int32 msg_subtype,\r
+ khm_ui_4 uparam,\r
+ void * vparam);\r
+\r
+/* in proppage.c */\r
+INT_PTR CALLBACK\r
+pp_cred_dlg_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+/* in config_id.c */\r
+INT_PTR CALLBACK\r
+config_id_dlgproc(HWND hwndDlg,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+/* in config_ids.c */\r
+INT_PTR CALLBACK\r
+config_ids_dlgproc(HWND hwndDlg,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+/* in config_main.c */\r
+INT_PTR CALLBACK\r
+config_dlgproc(HWND hwndDlg,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AND\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+\r
+/* Functions for handling our credentials type.\r
+*/\r
+\r
+khm_int32 KHMAPI\r
+cred_is_equal(khm_handle cred1,\r
+ khm_handle cred2,\r
+ void * rock) {\r
+\r
+ khm_int32 result;\r
+\r
+ /* TODO: Check any additional fields to determine if the two\r
+ credentials are equal or not. */\r
+\r
+ /* Note that this is actually a comparison function. It should\r
+ return 0 if the credentials are found to be equal, and non-zero\r
+ if they are not. We just set this to 0 if we don't need to\r
+ check any additional fields and accept the two credentials as\r
+ being equal. By the time this function is called, the\r
+ identity, name and type of the credentials have already been\r
+ found to be equal. */\r
+ result = 0;\r
+\r
+ return result;\r
+}\r
--- /dev/null
+// Microsoft Visual C++ generated resource script.\r
+//\r
+#include "..\..\langres.h"\r
+\r
+#define APSTUDIO_READONLY_SYMBOLS\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 2 resource.\r
+//\r
+#include "afxres.h"\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#undef APSTUDIO_READONLY_SYMBOLS\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// English (U.S.) resources\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
+#ifdef _WIN32\r
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r
+#pragma code_page(1252)\r
+#endif //_WIN32\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// TEXTINCLUDE\r
+//\r
+\r
+1 TEXTINCLUDE \r
+BEGIN\r
+ "..\\..\\langres.h\0"\r
+END\r
+\r
+2 TEXTINCLUDE \r
+BEGIN\r
+ "#include ""afxres.h""\r\n"\r
+ "\0"\r
+END\r
+\r
+3 TEXTINCLUDE \r
+BEGIN\r
+ "\r\n"\r
+ "\0"\r
+END\r
+\r
+#endif // APSTUDIO_INVOKED\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Icon\r
+//\r
+\r
+// Icon with lowest ID value placed first to ensure application icon\r
+// remains consistent on all systems.\r
+IDI_PLUGIN ICON "..\\..\\images\\plugin.ico"\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Dialog\r
+//\r
+\r
+IDD_PP_CRED DIALOGEX 0, 0, 235, 156\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION\r
+CAPTION "Property Page"\r
+FONT 8, "MS Shell Dlg", 0, 0, 0x0\r
+BEGIN\r
+ LTEXT "TODO: layout property page",IDC_STATIC,60,73,110,8\r
+END\r
+\r
+IDD_PP_IDENT DIALOGEX 0, 0, 235, 156\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION\r
+CAPTION "Property Page"\r
+FONT 8, "MS Shell Dlg", 0, 0, 0x0\r
+BEGIN\r
+ LTEXT "TODO: layout property page",IDC_STATIC,60,73,106,8\r
+END\r
+\r
+IDD_NEW_CREDS DIALOGEX 0, 0, 300, 166\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+ CONTROL "My Cred Options",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | SS_SUNKEN | WS_GROUP,7,7,286,11\r
+END\r
+\r
+IDD_CONFIG DIALOGEX 0, 0, 255, 182\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+END\r
+\r
+IDD_CONFIG_ID DIALOGEX 0, 0, 235, 151\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+END\r
+\r
+IDD_CONFIG_IDS DIALOGEX 0, 0, 235, 151\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+END\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// DESIGNINFO\r
+//\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+GUIDELINES DESIGNINFO \r
+BEGIN\r
+ IDD_PP_CRED, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 228\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 149\r
+ END\r
+\r
+ IDD_PP_IDENT, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 228\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 149\r
+ END\r
+\r
+ IDD_NEW_CREDS, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 293\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 159\r
+ END\r
+\r
+ IDD_CONFIG, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 248\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 175\r
+ END\r
+\r
+ IDD_CONFIG_ID, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 228\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 144\r
+ END\r
+\r
+ IDD_CONFIG_IDS, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 228\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 144\r
+ END\r
+END\r
+#endif // APSTUDIO_INVOKED\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// String Table\r
+//\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_PLUGIN_DESC "My Credentials Provider Plugin"\r
+ IDS_CT_SHORT_DESC "My Cred"\r
+ IDS_CT_LONG_DESC "My Credential"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_NC_CT_TEMPLATE "<p><a id=""SwitchPanel"" param=""MyCred""><b>My Cred</b></a><tab>: %s</p>"\r
+ IDS_NC_CT_TEMPLATE_NL "<p><tab> %s</p>"\r
+ IDS_GEN_NONE "(none)"\r
+ IDS_CFG_SHORT_DESC "My Creds"\r
+ IDS_CFG_LONG_DESC "My Creds Options"\r
+ IDS_CFG_IDS_SHORT_DESC "My Creds"\r
+ IDS_CFG_IDS_LONG_DESC "My Creds Options for all identities"\r
+ IDS_CFG_ID_SHORT_DESC "My Creds"\r
+ IDS_CFG_ID_LONG_DESC "My Creds Options for this identity"\r
+END\r
+\r
+#endif // English (U.S.) resources\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+#ifndef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 3 resource.\r
+//\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#endif // not APSTUDIO_INVOKED\r
+\r
--- /dev/null
+//{{NO_DEPENDENCIES}}\r
+// Microsoft Visual C++ generated include file.\r
+// Used by C:\work\pismere\athena\auth\krb5\src\windows\identity\sample\templates\credprov\lang\en_us\langres.rc\r
+//\r
+#define IDD_PP_CRED 106\r
+#define IDD_PP_IDENT 107\r
+#define IDS_PLUGIN_DESC 109\r
+#define IDS_CT_SHORT_DESC 110\r
+#define IDI_PLUGIN 110\r
+#define IDS_CT_LONG_DESC 111\r
+#define IDD_NEW_CREDS 112\r
+#define IDS_NC_CT_TEMPLATE 112\r
+#define IDS_NC_CT_TEMPLATE_NL 113\r
+#define IDD_CONFIG 113\r
+#define IDS_GEN_NONE 114\r
+#define IDD_CONFIG_ID 114\r
+#define IDS_CFG_SHORT_DESC 115\r
+#define IDD_CONFIG_IDS 115\r
+#define IDS_CFG_LONG_DESC 116\r
+#define IDS_CFG_IDS_SHORT_DESC 117\r
+#define IDS_CFG_IDS_LONG_DESC 118\r
+#define IDS_CFG_ID_SHORT_DESC 119\r
+#define IDS_CFG_ID_LONG_DESC 120\r
+\r
+// Next default values for new objects\r
+// \r
+#ifdef APSTUDIO_INVOKED\r
+#ifndef APSTUDIO_READONLY_SYMBOLS\r
+#define _APS_NEXT_RESOURCE_VALUE 116\r
+#define _APS_NEXT_COMMAND_VALUE 40001\r
+#define _APS_NEXT_CONTROL_VALUE 1039\r
+#define _APS_NEXT_SYMED_VALUE 101\r
+#endif\r
+#endif\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+\r
+/* This file provides the entry points for the module. The purpose of\r
+ each entry point is explained below.\r
+*/\r
+\r
+kmm_module h_khModule; /* KMM's handle to this module */\r
+HINSTANCE hInstance; /* handle to our DLL */\r
+HMODULE hResModule; /* handle to DLL containing language specific resources */\r
+\r
+const wchar_t * my_facility = MYPLUGIN_FACILITYW;\r
+\r
+/* locales and n_locales are used to provide information to NetIDMgr\r
+ about the locales that we support. Each locale that is supported\r
+ is represented by a single line below. NetIDMgr will pick a\r
+ suitable locale from this list as described in the documentation\r
+ for kmm_set_locale_info(). */\r
+kmm_module_locale locales[] = {\r
+\r
+ /* there needs to be at least one language that is supported.\r
+ Here we declare that to be US English, and make it the\r
+ default. */\r
+ LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),\r
+ MYPLUGIN_DLLBASEW L"_en_us.dll", /* this is the name of\r
+ the DLL. We paste a\r
+ trailer to basename\r
+ of the DLL. This\r
+ DLL should reside in\r
+ the same directory\r
+ as the plugin\r
+ DLL. */\r
+ KMM_MLOC_FLAG_DEFAULT)\r
+};\r
+int n_locales = ARRAYLENGTH(locales);\r
+\r
+/*******************************************************************\r
+ init_module\r
+ *****************************************************************\r
+\r
+ This is the entry point for the module. Each module can provide\r
+ multiple plugins and each plugin will need a separate entry point.\r
+ Generally, the module entry point will set up localized resources\r
+ and register the plugins.\r
+\r
+*/\r
+KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {\r
+\r
+ khm_int32 rv = KHM_ERROR_SUCCESS;\r
+ kmm_plugin_reg pi;\r
+ wchar_t description[KMM_MAXCCH_DESC];\r
+ int t;\r
+\r
+ h_khModule = h_module;\r
+\r
+ rv = kmm_set_locale_info(h_module, locales, n_locales);\r
+ if(KHM_SUCCEEDED(rv)) {\r
+ /* if the call succeeded, then NetIDMgr has picked a localized\r
+ resource DLL for us to use. */\r
+ hResModule = kmm_get_resource_hmodule(h_module);\r
+ } else\r
+ goto _exit;\r
+\r
+ /* TODO: Perform any other required initialization operations. */\r
+\r
+ /* register our plugin */\r
+ ZeroMemory(&pi, sizeof(pi));\r
+\r
+ pi.name = MYPLUGIN_NAMEW; /* name of the plugin */\r
+ pi.type = KHM_PITYPE_CRED; /* type. This is a credentials\r
+ provider. Setting this type has\r
+ the effect of having the plugin\r
+ entrypoint being automatically\r
+ subscribed to credentials provider\r
+ messages. */\r
+\r
+ /* An icon is optional, but we provide one anyway. */\r
+ pi.icon = LoadImage(hResModule, MAKEINTRESOURCE(IDI_PLUGIN),\r
+ IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);\r
+ pi.flags = 0;\r
+ pi.msg_proc = plugin_msg_proc;\r
+ pi.description = description;\r
+ pi.dependencies = NULL;\r
+ t = LoadString(hResModule, IDS_PLUGIN_DESC,\r
+ description, ARRAYLENGTH(description));\r
+ if (!t)\r
+ description[0] = L'\0';\r
+ else\r
+ description[ARRAYLENGTH(description) - 1] = L'\0';\r
+\r
+ rv = kmm_provide_plugin(h_module, &pi);\r
+\r
+ /* TODO: register any additional plugins */\r
+\r
+ /* Returning a successful code (KHM_ERROR_SUCCESS) will cause the\r
+ plugins to be initialized. If no plugin is successfully\r
+ registered while processing init_module or if a code other than\r
+ KHM_ERROR_SUCCESS is returned, the module will be immediately\r
+ unloaded. */\r
+\r
+ _exit:\r
+ return rv;\r
+}\r
+\r
+/**********************************************************\r
+ Exit module\r
+ ********************************************************\r
+\r
+ Called by the NetIDMgr module manager when unloading the module.\r
+ This will get called even if the module is being unloaded due to an\r
+ error code returned by init_module(). This callback is required. */\r
+KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) {\r
+\r
+ /* Unregistering the plugin is not required at this point. */\r
+\r
+ /* TODO: Perform any other required cleanup here. */\r
+\r
+ return KHM_ERROR_SUCCESS; /* the return code is ignored */\r
+}\r
+\r
+/* General DLL initialization. It is advisable to not do anything\r
+ here and also keep in mind that the plugin will be loaded at a time\r
+ where some threads have already started. So DLL_THREAD_ATTACH will\r
+ not fire for every thread. In addition, the plugin will be\r
+ unloaded before the application and all the threads terminate. */\r
+BOOL WINAPI DllMain(HINSTANCE hinstDLL,\r
+ DWORD fdwReason,\r
+ LPVOID lpvReserved)\r
+{\r
+ switch(fdwReason) {\r
+ case DLL_PROCESS_ATTACH:\r
+ hInstance = hinstDLL;\r
+ break;\r
+\r
+ case DLL_PROCESS_DETACH:\r
+ break;\r
+\r
+ case DLL_THREAD_ATTACH:\r
+ break;\r
+\r
+ case DLL_THREAD_DETACH:\r
+ break;\r
+ }\r
+\r
+ return TRUE;\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+#include<assert.h>\r
+\r
+/* This file provides the message processing function and the support\r
+ routines for implementing our plugin. Note that some of the\r
+ message processing routines have been moved to other source files\r
+ based on their use.\r
+*/\r
+\r
+khm_int32 credtype_id = KCDB_CREDTYPE_INVALID;\r
+khm_handle g_credset = NULL;\r
+\r
+/* Handler for system messages. The only two we handle are\r
+ KMSG_SYSTEM_INIT and KMSG_SYSTEM_EXIT. */\r
+khm_int32 KHMAPI\r
+handle_kmsg_system(khm_int32 msg_type,\r
+ khm_int32 msg_subtype,\r
+ khm_ui_4 uparam,\r
+ void * vparam) {\r
+ khm_int32 rv = KHM_ERROR_SUCCESS;\r
+\r
+ switch (msg_subtype) {\r
+\r
+ /* This is the first message that will be received by a\r
+ plugin. We use it to perform initialization operations\r
+ such as registering any credential types, data types and\r
+ attributes. */\r
+ case KMSG_SYSTEM_INIT:\r
+ {\r
+ kcdb_credtype ct;\r
+ wchar_t short_desc[KCDB_MAXCCH_SHORT_DESC];\r
+ wchar_t long_desc[KCDB_MAXCCH_LONG_DESC];\r
+ khui_config_node cnode;\r
+ khui_config_node_reg creg;\r
+\r
+ /* First and foremost, we need to register a credential\r
+ type. */\r
+ ZeroMemory(&ct, sizeof(ct));\r
+ ct.id = KCDB_CREDTYPE_AUTO;\r
+ ct.name = MYCREDTYPE_NAMEW;\r
+\r
+ short_desc[0] = L'\0';\r
+ LoadString(hResModule, IDS_CT_SHORT_DESC,\r
+ short_desc, ARRAYLENGTH(short_desc));\r
+\r
+ long_desc[0] = L'\0';\r
+ LoadString(hResModule, IDS_CT_LONG_DESC,\r
+ long_desc, ARRAYLENGTH(long_desc));\r
+\r
+ ct.icon = NULL; /* We skip the icon for now, but you\r
+ can assign a handle to an icon\r
+ here. The icon will be used to\r
+ represent the credentials type.*/\r
+\r
+ kmq_create_subscription(plugin_msg_proc, &ct.sub);\r
+\r
+ ct.is_equal = cred_is_equal;\r
+\r
+ rv = kcdb_credtype_register(&ct, &credtype_id);\r
+\r
+ /* We create a global credential set that we use in the\r
+ plug-in thread. This alleviates the need to create one\r
+ everytime we need one. Keep in mind that this should\r
+ only be used in the plug-in thread and should not be\r
+ touched from the UI thread or any other thread. */\r
+ kcdb_credset_create(&g_credset);\r
+\r
+ /* TODO: Perform additional initialization operations. */\r
+\r
+ /* TODO: Also list out the credentials of this type that\r
+ already exist. */\r
+\r
+ /* Now we register our configuration panels. */\r
+\r
+\r
+ /* This configuration panel is the one that controls\r
+ general options. We leave the identity specific and\r
+ identity defaults for other configuration panels. */\r
+\r
+ ZeroMemory(&creg, sizeof(creg));\r
+\r
+ short_desc[0] = L'\0';\r
+\r
+ LoadString(hResModule, IDS_CFG_SHORT_DESC,\r
+ short_desc, ARRAYLENGTH(short_desc));\r
+\r
+ long_desc[0] = L'\0';\r
+\r
+ LoadString(hResModule, IDS_CFG_LONG_DESC,\r
+ long_desc, ARRAYLENGTH(long_desc));\r
+\r
+ creg.name = CONFIGNODE_MAIN;\r
+ creg.short_desc = short_desc;\r
+ creg.long_desc = long_desc;\r
+ creg.h_module = hResModule;\r
+ creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG);\r
+ creg.dlg_proc = config_dlgproc;\r
+ creg.flags = 0;\r
+\r
+ khui_cfg_register(NULL, &creg);\r
+\r
+ /* Now we do the identity specific and identity default\r
+ configuration panels. "KhmIdentities" is a predefined\r
+ configuration node under which all the identity spcific\r
+ configuration is managed. */\r
+\r
+ if (KHM_FAILED(khui_cfg_open(NULL, L"KhmIdentities", &cnode))) {\r
+ /* this should always work */\r
+ assert(FALSE);\r
+ rv = KHM_ERROR_NOT_FOUND;\r
+ break;\r
+ }\r
+\r
+ /* First the tab panel for defaults for all identities */\r
+\r
+ ZeroMemory(&creg, sizeof(creg));\r
+\r
+ short_desc[0] = L'\0';\r
+ LoadString(hResModule, IDS_CFG_IDS_SHORT_DESC,\r
+ short_desc, ARRAYLENGTH(short_desc));\r
+ long_desc[0] = L'\0';\r
+ LoadString(hResModule, IDS_CFG_IDS_LONG_DESC,\r
+ long_desc, ARRAYLENGTH(long_desc));\r
+\r
+ creg.name = CONFIGNODE_ALL_ID;\r
+ creg.short_desc = short_desc;\r
+ creg.long_desc = long_desc;\r
+ creg.h_module = hResModule;\r
+ creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG_IDS);\r
+ creg.dlg_proc = config_ids_dlgproc;\r
+ creg.flags = KHUI_CNFLAG_SUBPANEL;\r
+\r
+ khui_cfg_register(cnode, &creg);\r
+\r
+ /* Now the panel for per identity configuration */\r
+\r
+ ZeroMemory(&creg, sizeof(creg));\r
+\r
+ short_desc[0] = L'\0';\r
+ LoadString(hResModule, IDS_CFG_ID_SHORT_DESC,\r
+ short_desc, ARRAYLENGTH(short_desc));\r
+ long_desc[0] = L'\0';\r
+ LoadString(hResModule, IDS_CFG_ID_LONG_DESC,\r
+ long_desc, ARRAYLENGTH(long_desc));\r
+\r
+ creg.name = CONFIGNODE_PER_ID;\r
+ creg.short_desc = short_desc;\r
+ creg.long_desc = long_desc;\r
+ creg.h_module = hResModule;\r
+ creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG_ID);\r
+ creg.dlg_proc = config_id_dlgproc;\r
+ creg.flags = KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_PLURAL;\r
+\r
+ khui_cfg_register(cnode, &creg);\r
+\r
+ khui_cfg_release(cnode);\r
+ }\r
+ break;\r
+\r
+ /* This is the last message that will be received by the\r
+ plugin. */\r
+ case KMSG_SYSTEM_EXIT:\r
+ {\r
+ khui_config_node cnode;\r
+ khui_config_node cn_idents;\r
+\r
+ /* It should not be assumed that initialization of the\r
+ plugin went well at this point since we receive a\r
+ KMSG_SYSTEM_EXIT even if the initialization failed. */\r
+\r
+ if (credtype_id != KCDB_CREDTYPE_INVALID) {\r
+ kcdb_credtype_unregister(credtype_id);\r
+ credtype_id = KCDB_CREDTYPE_INVALID;\r
+ }\r
+\r
+ if (g_credset) {\r
+ kcdb_credset_delete(g_credset);\r
+ g_credset = NULL;\r
+ }\r
+\r
+ /* Now unregister any configuration nodes we registered. */\r
+\r
+ if (KHM_SUCCEEDED(khui_cfg_open(NULL, CONFIGNODE_MAIN, &cnode))) {\r
+ khui_cfg_remove(cnode);\r
+ khui_cfg_release(cnode);\r
+ }\r
+\r
+ if (KHM_SUCCEEDED(khui_cfg_open(NULL, L"KhmIdentities", &cn_idents))) {\r
+ if (KHM_SUCCEEDED(khui_cfg_open(cn_idents,\r
+ CONFIGNODE_ALL_ID,\r
+ &cnode))) {\r
+ khui_cfg_remove(cnode);\r
+ khui_cfg_release(cnode);\r
+ }\r
+\r
+ if (KHM_SUCCEEDED(khui_cfg_open(cn_idents,\r
+ CONFIGNODE_PER_ID,\r
+ &cnode))) {\r
+ khui_cfg_remove(cnode);\r
+ khui_cfg_release(cnode);\r
+ }\r
+\r
+ khui_cfg_release(cn_idents);\r
+ }\r
+\r
+ /* TODO: Perform additional uninitialization\r
+ operations. */\r
+ }\r
+ break;\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
+/* Handler for credentials the refresh message. */\r
+khm_int32\r
+handle_kmsg_cred_refresh(void) {\r
+ /* TODO: Re-enumerate the credentials of our credentials type */\r
+\r
+ /*\r
+ Re-enumerating credentials would look something like this:\r
+\r
+ - flush all credentials from g_credset (kcdb_credset_flush())\r
+\r
+ - list out the credentials and add them to g_credset\r
+\r
+ - collect the credentials from g_credset to the root credentials\r
+ set. (kcdb_credset_collect())\r
+\r
+ Note that when listing credentials, each credential must be\r
+ populated with enough information to locate the actual\r
+ credential at a later time.\r
+ */\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Handler for destroying credentials */\r
+khm_int32\r
+handle_kmsg_cred_destroy_creds(khui_action_context * ctx) {\r
+ /* TODO: Destroy credentials of our type as specified by the\r
+ action context passed in through vparam. */\r
+\r
+ /* The credential set in ctx->credset contains the credentials\r
+ that are to be destroyed. */\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Begin a property sheet */\r
+khm_int32\r
+handle_kmsg_cred_pp_begin(khui_property_sheet * ps) {\r
+\r
+ /* TODO: Provide the information necessary to show a property\r
+ page for a credentials belonging to our credential type. */\r
+\r
+ PROPSHEETPAGE *p;\r
+\r
+ if (ps->credtype == credtype_id &&\r
+ ps->cred) {\r
+ /* We have been requested to show a property sheet for one of\r
+ our credentials. */\r
+ p = malloc(sizeof(*p));\r
+ ZeroMemory(p, sizeof(*p));\r
+\r
+ p->dwSize = sizeof(*p);\r
+ p->dwFlags = 0;\r
+ p->hInstance = hResModule;\r
+ p->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED);\r
+ p->pfnDlgProc = pp_cred_dlg_proc;\r
+ p->lParam = (LPARAM) ps;\r
+ khui_ps_add_page(ps, credtype_id, 0, p, NULL);\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* End a property sheet */\r
+khm_int32\r
+handle_kmsg_cred_pp_end(khui_property_sheet * ps) {\r
+ /* TODO: Handle the end of a property sheet. */\r
+\r
+ khui_property_page * p = NULL;\r
+\r
+ khui_ps_find_page(ps, credtype_id, &p);\r
+ if (p) {\r
+ if (p->p_page)\r
+ free(p->p_page);\r
+ p->p_page = NULL;\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* IP address change notification */\r
+khm_int32\r
+handle_kmsg_cred_addr_change(void) {\r
+ /* TODO: Handle this message. */\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+/* Message dispatcher for credentials messages. */\r
+khm_int32 KHMAPI\r
+handle_kmsg_cred(khm_int32 msg_type,\r
+ khm_int32 msg_subtype,\r
+ khm_ui_4 uparam,\r
+ void * vparam) {\r
+ khm_int32 rv = KHM_ERROR_SUCCESS;\r
+\r
+ switch(msg_subtype) {\r
+ case KMSG_CRED_REFRESH:\r
+ return handle_kmsg_cred_refresh();\r
+\r
+ case KMSG_CRED_DESTROY_CREDS:\r
+ return handle_kmsg_cred_destroy_creds((khui_action_context *) vparam);\r
+\r
+ case KMSG_CRED_PP_BEGIN:\r
+ return handle_kmsg_cred_pp_begin((khui_property_sheet *) vparam);\r
+\r
+ case KMSG_CRED_PP_END:\r
+ return handle_kmsg_cred_pp_end((khui_property_sheet *) vparam);\r
+\r
+ case KMSG_CRED_ADDR_CHANGE:\r
+ return handle_kmsg_cred_addr_change();\r
+\r
+ default:\r
+ /* Credentials acquisition messages are all handled in a\r
+ different source file. */\r
+ if (IS_CRED_ACQ_MSG(msg_subtype))\r
+ return handle_cred_acq_msg(msg_type, msg_subtype,\r
+ uparam, vparam);\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
+\r
+/* This is the main message handler for our plugin. All the plugin\r
+ messages end up here where we either handle it directly or dispatch\r
+ it to other handlers. */\r
+khm_int32 KHMAPI plugin_msg_proc(khm_int32 msg_type,\r
+ khm_int32 msg_subtype,\r
+ khm_ui_4 uparam,\r
+ void * vparam) {\r
+\r
+ switch(msg_type) {\r
+ case KMSG_SYSTEM:\r
+ return handle_kmsg_system(msg_type, msg_subtype, uparam, vparam);\r
+\r
+ case KMSG_CRED:\r
+ return handle_kmsg_cred(msg_type, msg_subtype, uparam, vparam);\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+\r
+/* Dialog procedure and support code for displaying property sheets\r
+ for credentials of type MyCred. */\r
+\r
+/* Dialog procedure for the property sheet. This will run under the\r
+ UI thread when a property sheet is being displayed for one of our\r
+ credentials.. */\r
+INT_PTR CALLBACK\r
+pp_cred_dlg_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ switch (uMsg) {\r
+ case WM_INITDIALOG:\r
+ {\r
+ khui_property_sheet * ps;\r
+ PROPSHEETPAGE * p;\r
+\r
+ p = (PROPSHEETPAGE *) lParam;\r
+ ps = (khui_property_sheet *) p->lParam;\r
+\r
+ /* TODO: Populate the property sheet controls with values\r
+ extracted from the credential. (ps->cred) */\r
+\r
+ return FALSE;\r
+ }\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
--- /dev/null
+/* Copyright (c) 2006 Secure Endpoints Inc.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include "credprov.h"\r
+#include<netidmgr_version.h>\r
+\r
+/* We use the same version.rc file for the main plugin DLL as well as\r
+ for the localized resource DLLs.*/\r
+\r
+#ifndef LANGVER\r
+\r
+#define STR_FILEDESC "My Credentials Provider Plugin for NetIDMgr"\r
+#define STR_INTNAME MYPLUGIN_NAME\r
+#define STR_ORIGNAME MYPLUGIN_DLLBASE ".dll"\r
+\r
+#else\r
+\r
+#ifdef LANG_en_us\r
+\r
+#define STR_FILEDESC "English(US) language resources for My Credentials Provider"\r
+#define STR_INTNAME MYPLUGIN_DLLBASE "_en_us"\r
+#define STR_ORIGNAME MYPLUGIN_DLLBASE "_en_us.dll"\r
+\r
+#else\r
+\r
+#error Unknown langugae\r
+\r
+#endif\r
+\r
+#endif\r
+\r
+1 VERSIONINFO \r
+ FILEVERSION VERSION_LISTC\r
+ PRODUCTVERSION VERSION_LISTC\r
+ FILEFLAGSMASK KH_VER_FILEFLAGMASK\r
+ FILEFLAGS KH_VER_FILEFLAGS\r
+ FILEOS KH_VER_FILEOS\r
+ FILETYPE KH_VER_FILETYPEDLL\r
+ FILESUBTYPE 0\r
+ {\r
+\r
+ BLOCK "StringFileInfo"\r
+ {\r
+ BLOCK "040904b0"\r
+ {\r
+ VALUE "CompanyName", "My Company"\r
+ VALUE "FileDescription", "My Credentials Provider Plugin"\r
+ VALUE "FileVersion", VERSION_STRING\r
+ VALUE "InternalName", STR_INTNAME\r
+ VALUE "LegalCopyright", "(C) 2006 My Company"\r
+ VALUE "OriginalFilename", STR_ORIGNAME\r
+ VALUE "ProductName", "My Plugin Product"\r
+ VALUE "ProductVersion", VERSION_STRING\r
+#ifndef LANGVER\r
+ VALUE NIMV_MODULE, MYMODULE_NAME\r
+\r
+/* if more than one plugin is provided by this module, then all of\r
+ those plugins should be listed here separated by commas. */\r
+ VALUE NIMV_PLUGINS, MYPLUGIN_NAME\r
+\r
+ VALUE NIMV_APIVER, KH_VERSION_STRINGAPI\r
+ VALUE NIMV_SUPPORT, "http://example.com/myplugin"\r
+#endif\r
+ }\r
+ }\r
+\r
+ BLOCK "VarFileInfo"\r
+ {\r
+ VALUE "Translation", 0x409, 1200\r
+ }\r
+ }\r