From 55aa6f04dcfebae134b3459944e005599d06ef05 Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Sun, 17 Feb 2008 14:33:26 +0000 Subject: [PATCH] windows-netidmgr-extension-sample-20080217 LICENSE MIT A sample template for constructing Network Identity Manager OpenAFS Provider Extensions for obtaining and identifying new token types. --- .../extensions/sample/Makefile | 278 ++++++++++++++++++ .../netidmgr_plugin/extensions/sample/README | 239 +++++++++++++++ .../extensions/sample/afspext.c | 98 ++++++ .../extensions/sample/config_main.c | 103 +++++++ .../extensions/sample/credprov.h | 149 ++++++++++ .../extensions/sample/images/plugin.ico | Bin 0 -> 9110 bytes .../extensions/sample/lang/en_us/langres.rc | 123 ++++++++ .../extensions/sample/langres.h | 31 ++ .../netidmgr_plugin/extensions/sample/main.c | 166 +++++++++++ .../extensions/sample/plugin.c | 180 ++++++++++++ .../extensions/sample/version.rc | 94 ++++++ 11 files changed, 1461 insertions(+) create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/Makefile create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/README create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/afspext.c create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/config_main.c create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/credprov.h create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/images/plugin.ico create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/lang/en_us/langres.rc create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/langres.h create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/main.c create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/plugin.c create mode 100644 src/WINNT/netidmgr_plugin/extensions/sample/version.rc diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/Makefile b/src/WINNT/netidmgr_plugin/extensions/sample/Makefile new file mode 100644 index 0000000000..6c5e8edbcb --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/Makefile @@ -0,0 +1,278 @@ +# +# Copyright (c) 2008 Secure Endpoints Inc. +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Environment variables +# --------------------- +# +# Before running the makefile, set the environment variable KFWSDKDIR +# to the directory containing the Kerberos for Windows SDK version 3.1 +# or later. The path should not end in a backslash. + +# Configuration settings +# ---------------------- + +# Declare a few things about our plug-in. + +# TODO: Change the plug-in name +PLUGINNAME=MyAFSExtPlugin + +# TODO: Change the module name +MODULENAME=MyAFSExtModule + +# TODO: Change the authentication method name +AUTHMETHODNAME=$(PLUGINNAME) + +# TODO: Change this as appropriate +DLLBASENAME=myplugin + +# Version info + +# TODO: Change the version numbers +VERMAJOR=0 +VERMINOR=1 +VERAUX =0 +VERPATCH=0 + +# Leave these as-is +VERLIST=$(VERMAJOR).$(VERMINOR).$(VERAUX).$(VERPATCH) +VERLISTC=$(VERMAJOR),$(VERMINOR),$(VERAUX),$(VERPATCH) + +# Various checks + +!ifndef MSSDK +! error Platform SDK environment variables not set. +!endif + +!ifndef KFWSDKDIR +! error KFWSDKDIR environment variable not set. +!endif + +!ifndef AFSPLUGINDIR +! error AFSPLUGINDIR environment variable not set. +!endif + +# Directories + +BUILDROOT=. + +!ifdef NODEBUG +BUILDTYPE=release +!else +BUILDTYPE=debug +!endif + +!ifndef CPU +!error Environment variable 'CPU' is not defined. +!endif + +DEST=$(BUILDROOT)\dest\$(CPU)_$(BUILDTYPE) +OBJ=$(BUILDROOT)\obj\$(CPU)_$(BUILDTYPE) + +!ifndef NIDMRAWDIRS +KFWINCDIR=$(KFWSDKDIR)\inc +NIDMINCDIR=$(KFWINCDIR)\netidmgr +NIDMLIBDIR=$(KFWSDKDIR)\lib\$(CPU) +!else +NIDMINCDIR=$(KFWSDKDIR)\inc +NIDMLIBDIR=$(KFWSDKDIR) +!endif + +# Win32.mak + +!include + +# Program macros + +CD=cd +RM=del /q +MKDIR=mkdir +RMDIR=rmdir +ECHO=echo +CP=copy /y +LINK=link +MC=mc + +# Lots more macros + +incflags = -I"$(NIDMINCDIR)" -I"$(OBJ)" -I"$(AFSPLUGINDIR)" -I. +rincflags = /i "$(NIDMINCDIR)" /i "$(OBJ)" /i "$(AFSPLUGINDIR)" /i . + +ldebug = $(ldebug) /DEBUG +cdebug = $(cdebug) -Os -Zi + +cdefines = $(cdefines) -DUNICODE -D_UNICODE + +C2OBJ=$(CC) $(cdebug) $(cflags) $(incflags) $(cdefines) /Fo"$@" /c $** + +DLLGUILINK=$(LINK) /NOLOGO $(ldebug) $(dlllflags) $(guilibsmt) /OUT:"$@" /IMPLIB:$(DEST)\$(@B).lib $** + +DLLRESLINK=$(LINK) /NOLOGO /DLL /NOENTRY /MACHINE:$(PROCESSOR_ARCHITECTURE) /OUT:"$@" $** + +RC2RES=$(RC) $(RFLAGS) $(rincflags) /fo "$@" $** + +MC2RC=$(MC) $(MCFLAGS) -h "$(OBJ)\" -m 1024 -r "$(OBJ)\" -x "$(OBJ)\" $** + +{}.c{$(OBJ)}.obj: + $(C2OBJ) + +{$(OBJ)}.c{$(OBJ)}.obj: + $(C2OBJ) + +{}.rc{$(OBJ)}.res: + $(RC2RES) + +mkdirs:: +!if !exist($(DEST)) + $(MKDIR) "$(DEST)" +!endif +!if !exist($(OBJ)) + $(MKDIR) "$(OBJ)" +!endif + +clean:: + $(RM) "$(OBJ)\*.*" + $(RM) "$(DEST)\*.*" + +.SUFFIXES: .h + +# +# Manifest handling +# +# Starting with Visual Studio 8, the C compiler and the linker +# generate manifests so that the applications will link with the +# correct side-by-side DLLs at run-time. These are required for +# correct operation under Windows XP. We also have custom manifests +# which need to be merged with the manifests that VS creates. +# +# The syntax for invoking the _VC_MANIFEST_EMBED_foo macro is: +# $(_VC_MANIFEST_EMBED_???) +# + +!ifndef MT +MT=mt.exe -nologo +!endif + +_VC_MANIFEST_EMBED_EXE= \ +if exist "$@.manifest" $(MT) -outputresource:"$@";1 -manifest "$@.manifest" + +_VC_MANIFEST_EMBED_DLL=$(_VC_MANIFEST_EMBED_EXE) + +# Note that if you are merging manifests, then the VS generated +# manifest should be cleaned up after calling _VC_MANIFEST_EMBED_???. +# This ensures that even if the DLL or EXE is executed in-place, the +# embedded manifest will be used. Otherwise the $@.manifest file will +# be used. +_VC_MANIFEST_CLEAN= \ +if exist "$@.manifest" $(RM) "$@.manifest" + +# End of manifest handling + + +# Now for the actual build stuff + +DLL=$(DEST)\$(DLLBASENAME).dll + +LIBFILES= \ + "$(NIDMLIBDIR)\nidmgr32.lib" + +OBJFILES= \ + $(OBJ)\afspext.obj \ + $(OBJ)\main.obj \ + $(OBJ)\plugin.obj \ + $(OBJ)\config_main.obj + +DLLRESFILE=$(OBJ)\version.res + +CONFIGHEADER=$(OBJ)\credacq_config.h + +all: mkdirs $(CONFIGHEADER) $(DLL) lang + +$(CONFIGHEADER): Makefile + $(CP) << "$@" +/* This is a generated file. Do not modify directly. */ + +#pragma once + +#define MYPLUGIN_DLLBASE "$(DLLBASENAME)" + +#define MYPLUGIN_NAME "$(PLUGINNAME)" + +#define MYMODULE_NAME "$(MODULENAME)" + +#define AUTHMETHOD_NAME "$(AUTHMETHODNAME)" + +#define VERSION_MAJOR $(VERMAJOR) +#define VERSION_MINOR $(VERMINOR) +#define VERSION_AUX $(VERAUX) +#define VERSION_PATCH $(VERPATCH) + +#define VERSION_LIST $(VERLIST) +#define VERSION_LISTC $(VERLISTC) +#define VERSION_STRING "$(VERLIST)" + +<< + +clean:: + $(RM) $(CONFIGHEADER) + +$(DLL): $(OBJFILES) $(DLLRESFILE) + $(DLLGUILINK) $(LIBFILES) + $(_VC_MANIFEST_EMBED_DLL) + $(_VC_MANIFEST_CLEAN) + +clean:: + $(RM) $(DLL) + +# Language specific resources + +# (repeat the following block as needed, redefining LANG for each +# supported language) + +# English-US +LANG=en_us + +LANGDLL=$(DEST)\$(DLLBASENAME)_$(LANG).dll + +lang:: $(LANGDLL) + +$(LANGDLL): $(OBJ)\langres_$(LANG).res $(OBJ)\version_$(LANG).res + $(DLLRESLINK) + $(_VC_MANIFEST_EMBED_DLL) + $(_VC_MANIFEST_CLEAN) + +clean:: + $(RM) $(LANGDLL) + +$(OBJ)\version_$(LANG).res: version.rc + $(RC) $(RFLAGS) $(rincflags) /d LANGRES /d LANG_$(LANG) /fo $@ $** + +clean:: + $(RM) $(OBJ)\version_$(LANG).res + +$(OBJ)\langres_$(LANG).res: lang\$(LANG)\langres.rc + $(RC2RES) + +clean:: + $(RM) $(OBJ)\langres_$(LANG).res + +# /English-US diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/README b/src/WINNT/netidmgr_plugin/extensions/sample/README new file mode 100644 index 0000000000..64afcdaa5e --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/README @@ -0,0 +1,239 @@ + + OpenAFS Network Identity Provider Plug-in + + OpenAFS Plug-in Extension Template + +------------------------------------------------------------------ + + CONTENTS + + 1. INTRODUCTION + 2. COPYRIGHT AND LICENSE + 3. ROADMAP OF THE TEMPLATE + 4. BUILD REQUIREMENTS + 5. BUILDING + 6. RUNNING THE PLUG-IN + 7. KNOWN ISSUES + 8. SUPPORT / BUG REPORTS + +------------------------------------------------------------------ + +1. INTRODUCTION + + This directory and subdirectories contain a plug-in template for + creating an extension for the OpenAFS Network Identity Manager + plug-in. Currently, such extensions are limited to providing + additional authentication methods. + + This version of the template adheres to the following version + constraints: + + Network Identity Manager API version : 10 or later + OpenAFS Plug-in Version : 1 or later + + The source files in this template can be used to build the plug-in + DLL and the US English resource DLL for the plug-in. In its + current form, the plug-in doesn't do much. However, the source + code contains a number of stub functions that can be used to + implement your extension. + + Note that this template is based on the credentials provider + template in the Network Identity Manager SDK, and has numerous + references to credentials providers that are not applicable to + this particular type of plug-in. + +------------------------------------------------------------------ + +2. COPYRIGHT AND LICENSE + + Copyright (c) 2008 Secure Endpoints Inc. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +------------------------------------------------------------------ + +3. ROADMAP OF THE TEMPLATE + + The files and directories included in the template are described + below. The files that you most likely want to change are + Makefile, afspext.c, version.rc and lang\en_us\langres.rc. + + .\README + + This file. + + .\Makefile + + The primary (and only) Makefile used by 'nmake' to build the + plug-in. In addition to providing build directives, it also + contains a set of macros which defines the names and version + information that is used throughout the plug-in code. + + Look for the 'Configuration Settings' section of the Makefile + for the macros. If you are basing a plug-in on this template, + you will want to change these macros. These macros will be + used to generate 'credacq_config.h', a header file included by + 'credprov.h' so that the values of the macros can be used in C + code. + + .\credprov.h + + The main header file for all the C source files in the + plug-in. + + .\main.c + + Provides the entry points for the module. + + .\plugin.c + + Provides the message processing functions and support routines + for implementing the plug-in. Note that some of the message + processing routines have been moved to other sources files + based on their use. + + .\afspext.c + + The message handler for AFS_MSG messages. The OpenAFS plug-in + uses these messages to communicate with its extensions. This + is probably the only C source file you would want to modify + when implementing an extension plug-in for the OpenAFS + plug-in. + + .\config_main.c + + Dialog procedures and support code for providing the general + configuration panel for this plug-in. Providing a + configuration panel isn't required for an extension plug-in. + + .\version.rc + + Version information for the plug-in as well as all the + language resource DLLs. + + .\langres.h + + Declarations for the language resources (see below). In its + current form, it was generated via Visual Studio while editing + the language resouces file. + + .\images\plugin.ico + + A generic plug-in icon. + + .\lang\en_us\langres.rc + + US-English language resources. This will be used to create + the language resource DLL. + +------------------------------------------------------------------ + +4. BUILD REQUIREMENTS + + Microsoft(R) Platform SDK (Windows Server 2003 or later) + + (http://www.microsoft.com/msdownload/platformsdk/sdkupdate/) + + Microsoft(R) Visual C++ (Visual Studio 2003 or later) + + Although not tested, the template should build using the + Microsoft Visual C++ toolkit. + + MIT Kerberos for Windows (version 3.2 or later) SDK + + OpenAFS for Windows 1.5.x SDK or source + + The only file that is needed for building an extension plug-in + is afspext.h. + +------------------------------------------------------------------ + +5. BUILDING + + The build process is fairly starightforward. The source is set up + to build using 'nmake', a build tool distributed with the Platform + SDK as well as with Visual Studio. + + 1. Open a command prompt with a suitable build environment. + + From a plain command prompt, you can set up a debug build + environment targetting Windows XP (32-bit) with: + + > "%PROGRAMFILES%\Microsoft Platform SDK\SetEnv.Cmd" /XP32 /DEBUG + + 2. Set the environment variable KFWSDKDIR to point to the root of + the Kerberos for Windows 3.1 SDK. (i.e. %KFWSDKDIR%\inc + should be the include directory of the SDK) + + > SET KFWSDKDIR=%PROGRAMFILES%\MIT\Kerberos + + 3. Set the environment variable AFSPLUGINDIR to the directory + that contains afspext.h. This could either be in the OpenAFS + SDK include directory or in the source tree at + src\WINNT\netidmgr_plugin. + + > SET AFSPLUGINDIR=... + + 4. Start the build: + + > NMAKE all + + The build target 'all' builds the plug-in and the language + resources. There is an additional build target 'clean' which + removes the temporary files and the binaries generated during + the build. + + Assuming everything goes well, the plug-in binaries should be + created under a subdirectory under 'dest'. The name of the + subdirectory reflects the target architecture and the build + type ('debug' or 'release'). + +------------------------------------------------------------------ + +6. RUNNING THE PLUG-IN + + Once the binaries for the plug-in have been built, you need to + register the plug-in with NetIDMgr by adding a registry value as + follows: + + [HKEY_CURRENT_USER\Software\MIT\NetIDMgr\PluginManager\Modules\] + "ImagePath"="" + + The should be the full path to the plug-in DLL. + + is the name of the module that you built. The + default value specified in the template is 'MyAFSExtModule'. This + is the value of the macro 'MODULENAME' defined in the 'Makefile'. + + Once this is done, you need to restart NetIDMgr so that it will + pick up the new plug-in. + +------------------------------------------------------------------ + +7. KNOWN ISSUES + +------------------------------------------------------------------ + +8. SUPPORT / BUG REPORTS + + Problems should be sent to openafs@secure-endpoints.com + +------------------------------------------------------------------ diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/afspext.c b/src/WINNT/netidmgr_plugin/extensions/sample/afspext.c new file mode 100644 index 0000000000..4960e31475 --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/afspext.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2006 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +#include "credprov.h" +#include "afspext.h" +#include + +/* Resolve a token + + This message is typically sent when the AFS plug-in can't determine + the authentication method that was used to obtain a specific token. + + When the AFS plug-in starts, it attempts to list the AFS tokens + that belong to the user. During this process, the plug-in has to + determine the authentication method and identity corresponding to + each token for the purpose of handling token renewals and + acquisitions. If the plug-in is unable to do so, it will query any + registered extensions using this message. If you handle this + message, and are able to determine the authentication method used + to obtain the token specified in prt->token, then you should set + prt->ident and prt->method members to the identity and method for + the token and return KHM_ERROR_SUCCESS. + */ +khm_int32 +handle_AFS_MSG_RESOLVE_TOKEN(afs_msg_resolve_token * prt) +{ + /* TODO: Implement this */ + return KHM_ERROR_NOT_IMPLEMENTED; +} + +/* Handle a klog message + + This message is sent when the AFS plug-in is attempting to obtain a + token using this authentication method, or if it is attempting to + obtain a token using the 'AUTO' method and none of the stock + authentication methods were successful. + + If you handle this message and successfully obtain a token, you + should return KHM_ERROR_SUCCESS. Any other return value will cause + the AFS plug-in to either report a failure or continue down the + list of authentication method extensions. + +*/ +khm_int32 +handle_AFS_MSG_KLOG(afs_msg_klog * pklog) +{ + + /* TODO: Implement this */ + + return KHM_ERROR_NOT_IMPLEMENTED; +} + +/* Handle AFS_MSG messages + + These are the messages that the AFS plug-in uses to communicate + with its extensions. This function just dispatches the messages to + the appropriate handler defined above. + */ +khm_int32 KHMAPI +handle_AFS_MSG(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) +{ + switch (msg_subtype) { + case AFS_MSG_RESOLVE_TOKEN: + return handle_AFS_MSG_RESOLVE_TOKEN((afs_msg_resolve_token *) vparam); + + case AFS_MSG_KLOG: + return handle_AFS_MSG_KLOG((afs_msg_klog *) vparam); + } + + return KHM_ERROR_NOT_IMPLEMENTED; +} + diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/config_main.c b/src/WINNT/netidmgr_plugin/extensions/sample/config_main.c new file mode 100644 index 0000000000..9a338a86c1 --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/config_main.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2006 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +#include "credprov.h" +#include + +/* Dialog procedures and support functions for handling configuration + dialogs for general plug-in configuration. */ + +/* Structure for holding dialog data for the configuration window. */ +typedef struct tag_config_main_dlg_data { + khui_config_node cnode; + + /* TODO: add fields as needed */ +} config_main_dlg_data; + +INT_PTR CALLBACK +config_dlgproc(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + + config_main_dlg_data * d; + + switch (uMsg) { + case WM_INITDIALOG: + d = malloc(sizeof(*d)); + assert(d); + ZeroMemory(d, sizeof(*d)); + + /* for configuration panels that are not subpanels, lParam is + a held handle to the configuration node. The handle will + be held for the lifetime of the window. */ + + d->cnode = (khui_config_node) lParam; + + /* TODO: perform any other required initialization stuff + here */ + +#pragma warning(push) +#pragma warning(disable: 4244) + SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d); +#pragma warning(pop) + + break; + + case KHUI_WM_CFG_NOTIFY: + { + d = (config_main_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + if (d == NULL) + break; + + /* WMCFG_APPLY is the only notification we care about */ + + if (HIWORD(wParam) == WMCFG_APPLY) { + /* TODO: Apply changes and update the state */ + + return TRUE; + } + } + break; + + case WM_DESTROY: + d = (config_main_dlg_data *) + GetWindowLongPtr(hwnd, DWLP_USER); + + /* TODO: perform any other required uninitialization here */ + + if (d) { + free(d); + SetWindowLongPtr(hwnd, DWLP_USER, 0); + } + + break; + } + + return FALSE; + +} diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/credprov.h b/src/WINNT/netidmgr_plugin/extensions/sample/credprov.h new file mode 100644 index 0000000000..6d617f2b69 --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/credprov.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2006 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +/* only include this header file once */ +#pragma once + +#ifndef _UNICODE +#ifndef RC_INVOKED +/* This template relies on _UNICODE being defined to call the correct + APIs. */ +#error This template needs to be compiled with _UNICODE +#endif +#endif + +/* Pull in configuration macros from the Makefile */ +#include "credacq_config.h" + +/* declare a few macros about our plugin */ + +/* The following macro will be used throughout the template to refer + to the name of the plugin. The macro is actually defined the + Makefile generated configuration header file. Modify the + PLUGINNAME Makefile macro.*/ +#ifndef MYPLUGIN_NAME +#error MYPLUGIN_NAME not defined +#endif + +/* Also define the unicde equivalent of the name. In general strings + in NetIDMgr are unicode. */ +#define MYPLUGIN_NAMEW _T(MYPLUGIN_NAME) + +/* The name of the module. This is distinct from the name of the + plugin for several reasons. One of which is that a single module + can provide multiple plugins. Also, having a module name distinct + from a plugin name allows multiple vendors to provide the same + plugin. For example, the module name for the MIT Kerberos 5 plugin + is MITKrb5 while the plugin name is Krb5Cred. The macro is + actually defined in the Makefile generated configuration header + file. Modify the MODULENAME Makefile macro.*/ +#ifndef MYMODULE_NAME +#error MYMODULE_NAME not defined +#endif + +#define MYMODULE_NAMEW _T(MYMODULE_NAME) + +/* When logging events from our plugin, the event logging API can + optionally take a facility name to provide a friendly label to + identify where each event came from. We will default to the plugin + name, although it can be anything. */ +#define MYPLUGIN_FACILITYW MYPLUGIN_NAMEW + +/* Base name of the DLL that will be providing the plugin. We use it + to construct names of the DLLs that will contain localized + resources. This is defined in the Makefile and fed in to the build + through there. The macro to change in the Makefile is + DLLBASENAME. */ +#ifndef MYPLUGIN_DLLBASE +#error MYPLUGIN_DLLBASE Not defined! +#endif + +#define MYPLUGIN_DLLBASEW _T(MYPLUGIN_DLLBASE) + +/* Name of the authentication method that will be registered by the + plugin. This macro is actually defined in the Makefile generated + configuration header file. Change the AUTHMETHODNAME macro in the + Makefile. */ +#ifndef AUTHMETHOD_NAME +#error AUTHMETHOD_NAME not defined +#endif + +#define AUTHMETHOD_NAMEW _T(AUTHMETHOD_NAME) + +/* Configuration node names. We just concatenate a few strings + together, although you should feel free to completely define your + own. */ + +#define CONFIGNODE_MAIN AUTHMETHOD_NAMEW L"Config" + +#include +/* include the standard NetIDMgr header files */ +#include + +/* And the AFS plug-in extension header file */ +#include "afspext.h" +#include + +/* declarations for language resources */ +#include "langres.h" + +#ifndef NOSTRSAFE +#include +#endif + +/*************************************************** + Externals +***************************************************/ + +extern kmm_module h_khModule; +extern HINSTANCE hInstance; +extern HMODULE hResModule; +extern afs_tk_method tk_method; + +extern const wchar_t * my_facility; + +/* Function declarations */ + +/* in afspext.c */ +khm_int32 KHMAPI +handle_AFS_MSG(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam); + +/* in plugin.c */ +khm_int32 KHMAPI +plugin_msg_proc(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam); + +/* in config_main.c */ +INT_PTR CALLBACK +config_dlgproc(HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam); diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/images/plugin.ico b/src/WINNT/netidmgr_plugin/extensions/sample/images/plugin.ico new file mode 100644 index 0000000000000000000000000000000000000000..99ffbc411b5f9cf6244bd011297fdb6194a5478b GIT binary patch literal 9110 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 U#!gL^-VAqF8Gl23W3Smi0oL6$(EtDd literal 0 HcmV?d00001 diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/lang/en_us/langres.rc b/src/WINNT/netidmgr_plugin/extensions/sample/lang/en_us/langres.rc new file mode 100644 index 0000000000..ae1a6f95b9 --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/lang/en_us/langres.rc @@ -0,0 +1,123 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\langres.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\..\\langres.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_PLUGIN ICON "..\\..\\images\\plugin.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CONFIG DIALOGEX 0, 0, 255, 182 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_CONFIG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 248 + TOPMARGIN, 7 + BOTTOMMARGIN, 175 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_PLUGIN_DESC "My Credentials Provider Plugin" +END + +STRINGTABLE +BEGIN + IDS_GEN_NONE "(none)" + IDS_CFG_SHORT_DESC "My Creds" + IDS_CFG_LONG_DESC "My Creds Options" + IDS_TKMETHOD_SHORT_DESC "My Method" + IDS_TKMETHOD_LONG_DESC "My Token Acquistion Method" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/langres.h b/src/WINNT/netidmgr_plugin/extensions/sample/langres.h new file mode 100644 index 0000000000..4748d0a367 --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/langres.h @@ -0,0 +1,31 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by C:\work\openafs.1.5\src\Winnt\netidmgr_plugin\sample\lang\en_us\langres.rc +// +#define IDS_PLUGIN_DESC 109 +#define IDS_CT_SHORT_DESC 110 +#define IDI_PLUGIN 110 +#define IDS_CT_LONG_DESC 111 +#define IDS_NC_CT_TEMPLATE 112 +#define IDS_NC_CT_TEMPLATE_NL 113 +#define IDD_CONFIG 113 +#define IDS_GEN_NONE 114 +#define IDS_CFG_SHORT_DESC 115 +#define IDS_CFG_LONG_DESC 116 +#define IDS_CFG_IDS_SHORT_DESC 117 +#define IDS_CFG_IDS_LONG_DESC 118 +#define IDS_CFG_ID_SHORT_DESC 119 +#define IDS_CFG_ID_LONG_DESC 120 +#define IDS_TKMETHOD_SHORT_DESC 121 +#define IDS_TKMETHOD_LONG_DESC 122 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 116 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1039 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/main.c b/src/WINNT/netidmgr_plugin/extensions/sample/main.c new file mode 100644 index 0000000000..fdb4a833a0 --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/main.c @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2006 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +#include "credprov.h" + +/* This file provides the entry points for the module. The purpose of + each entry point is explained below. +*/ + +kmm_module h_khModule; /* KMM's handle to this module */ +HINSTANCE hInstance; /* handle to our DLL */ +HMODULE hResModule; /* handle to DLL containing language specific resources */ + +const wchar_t * my_facility = MYPLUGIN_FACILITYW; + +/* locales and n_locales are used to provide information to NetIDMgr + about the locales that we support. Each locale that is supported + is represented by a single line below. NetIDMgr will pick a + suitable locale from this list as described in the documentation + for kmm_set_locale_info(). */ +kmm_module_locale locales[] = { + + /* there needs to be at least one language that is supported. + Here we declare that to be US English, and make it the + default. */ + LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US), + MYPLUGIN_DLLBASEW L"_en_us.dll", /* this is the name of + the DLL. We paste a + trailer to basename + of the DLL. This + DLL should reside in + the same directory + as the plugin + DLL. */ + KMM_MLOC_FLAG_DEFAULT) +}; +int n_locales = ARRAYLENGTH(locales); + +/******************************************************************* + init_module + ***************************************************************** + + This is the entry point for the module. Each module can provide + multiple plugins and each plugin will need a separate entry point. + Generally, the module entry point will set up localized resources + and register the plugins. + +*/ +KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) { + + khm_int32 rv = KHM_ERROR_SUCCESS; + kmm_plugin_reg pi; + wchar_t description[KMM_MAXCCH_DESC]; + int t; + + h_khModule = h_module; + + rv = kmm_set_locale_info(h_module, locales, n_locales); + if(KHM_SUCCEEDED(rv)) { + /* if the call succeeded, then NetIDMgr has picked a localized + resource DLL for us to use. */ + hResModule = kmm_get_resource_hmodule(h_module); + } else + goto _exit; + + /* TODO: Perform any other required initialization operations. */ + + /* register our plugin */ + ZeroMemory(&pi, sizeof(pi)); + + pi.name = MYPLUGIN_NAMEW; + pi.type = KHM_PITYPE_MISC; + + /* An icon is optional, but we provide one anyway. */ + pi.icon = LoadImage(hResModule, MAKEINTRESOURCE(IDI_PLUGIN), + IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE); + pi.flags = 0; + pi.msg_proc = plugin_msg_proc; + pi.description = description; + pi.dependencies = L"AfsCred\0"; + t = LoadString(hResModule, IDS_PLUGIN_DESC, + description, ARRAYLENGTH(description)); + if (!t) + description[0] = L'\0'; + else + description[ARRAYLENGTH(description) - 1] = L'\0'; + + rv = kmm_provide_plugin(h_module, &pi); + + /* TODO: register any additional plugins */ + + /* Returning a successful code (KHM_ERROR_SUCCESS) will cause the + plugins to be initialized. If no plugin is successfully + registered while processing init_module or if a code other than + KHM_ERROR_SUCCESS is returned, the module will be immediately + unloaded. */ + + _exit: + return rv; +} + +/********************************************************** + Exit module + ******************************************************** + + Called by the NetIDMgr module manager when unloading the module. + This will get called even if the module is being unloaded due to an + error code returned by init_module(). This callback is required. */ +KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) { + + /* Unregistering the plugin is not required at this point. */ + + /* TODO: Perform any other required cleanup here. */ + + return KHM_ERROR_SUCCESS; /* the return code is ignored */ +} + +/* General DLL initialization. It is advisable to not do anything + here and also keep in mind that the plugin will be loaded at a time + where some threads have already started. So DLL_THREAD_ATTACH will + not fire for every thread. In addition, the plugin will be + unloaded before the application and all the threads terminate. */ +BOOL WINAPI DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch(fdwReason) { + case DLL_PROCESS_ATTACH: + hInstance = hinstDLL; + break; + + case DLL_PROCESS_DETACH: + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/plugin.c b/src/WINNT/netidmgr_plugin/extensions/sample/plugin.c new file mode 100644 index 0000000000..e13c5389fc --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/plugin.c @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2006 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* $Id$ */ + +#include "credprov.h" +#include "afspext.h" +#include + +/* This file provides the message processing function and the support + routines for implementing our plugin. Note that some of the + message processing routines have been moved to other source files + based on their use. +*/ + +khm_int32 msg_type_afs = -1; +khm_handle g_credset = NULL; +afs_tk_method tk_method = -1; + +/* Handler for system messages. The only two we handle are + KMSG_SYSTEM_INIT and KMSG_SYSTEM_EXIT. */ +khm_int32 KHMAPI +handle_kmsg_system(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + khm_int32 rv = KHM_ERROR_SUCCESS; + + switch (msg_subtype) { + + /* This is the first message that will be received by a + plugin. We use it to perform initialization operations + such as registering any credential types, data types and + attributes. */ + case KMSG_SYSTEM_INIT: + { + wchar_t short_desc[KCDB_MAXCCH_SHORT_DESC]; + wchar_t long_desc[KCDB_MAXCCH_LONG_DESC]; +#ifdef USE_CONFIGURATION_PANELS + khui_config_node_reg creg; +#endif + afs_msg_announce announce; + + if (KHM_FAILED(kmq_find_type(AFS_MSG_TYPENAME, &msg_type_afs))) { + return KHM_ERROR_UNKNOWN; + } + + /* We must first announce our extension plug-in, so that + the AFS plug-in will know we exist */ + announce.cbsize = sizeof(announce); + announce.version = AFS_PLUGIN_VERSION; + announce.name = MYPLUGIN_NAMEW; + + kmq_create_subscription(handle_AFS_MSG, &announce.sub); + + /* Set to TRUE if we are providing a token acquisition + method */ + announce.provide_token_acq = TRUE; + + LoadString(hResModule, IDS_TKMETHOD_SHORT_DESC, + short_desc, ARRAYLENGTH(short_desc)); + + announce.token_acq.short_desc = short_desc; + + LoadString(hResModule, IDS_TKMETHOD_LONG_DESC, + long_desc, ARRAYLENGTH(long_desc)); + + announce.token_acq.long_desc = long_desc; + + if (KHM_FAILED(kmq_send_message(msg_type_afs, + AFS_MSG_ANNOUNCE, 0, &announce))) { + kmq_delete_subscription(announce.sub); + announce.sub = NULL; + + return KHM_ERROR_UNKNOWN; + } + + tk_method = announce.token_acq.method_id; + +#ifdef USE_CONFIGURATION_PANELS + + /* Register our configuration panels. */ + + /* Registering configuration panels is not required for + extension plug-in. As such, this bit of code is + commented out. However, if you wish to provide a + configuration panel, you should uncomment this block + and fill in the stub functions in config_main.c */ + + ZeroMemory(&creg, sizeof(creg)); + + short_desc[0] = L'\0'; + + LoadString(hResModule, IDS_CFG_SHORT_DESC, + short_desc, ARRAYLENGTH(short_desc)); + + long_desc[0] = L'\0'; + + LoadString(hResModule, IDS_CFG_LONG_DESC, + long_desc, ARRAYLENGTH(long_desc)); + + creg.name = CONFIGNODE_MAIN; + creg.short_desc = short_desc; + creg.long_desc = long_desc; + creg.h_module = hResModule; + creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG); + creg.dlg_proc = config_dlgproc; + creg.flags = 0; + + khui_cfg_register(NULL, &creg); +#endif + } + break; + + /* This is the last message that will be received by the + plugin. */ + case KMSG_SYSTEM_EXIT: + { + khui_config_node cnode; + + /* It should not be assumed that initialization of the + plugin went well at this point since we receive a + KMSG_SYSTEM_EXIT even if the initialization failed. */ + + /* Now unregister any configuration nodes we registered. */ + + if (KHM_SUCCEEDED(khui_cfg_open(NULL, CONFIGNODE_MAIN, &cnode))) { + khui_cfg_remove(cnode); + khui_cfg_release(cnode); + } + + /* TODO: Perform additional uninitialization + operations. */ + } + break; + } + + return rv; +} + +/* This is the main message handler for our plugin. All the plugin + messages end up here where we either handle it directly or dispatch + it to other handlers. */ +khm_int32 KHMAPI plugin_msg_proc(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + + switch(msg_type) { + case KMSG_SYSTEM: + return handle_kmsg_system(msg_type, msg_subtype, uparam, vparam); + } + + if (msg_type == msg_type_afs) { + return handle_AFS_MSG(msg_type, msg_subtype, uparam, vparam); + } + + return KHM_ERROR_SUCCESS; +} diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/version.rc b/src/WINNT/netidmgr_plugin/extensions/sample/version.rc new file mode 100644 index 0000000000..cedaf9e53e --- /dev/null +++ b/src/WINNT/netidmgr_plugin/extensions/sample/version.rc @@ -0,0 +1,94 @@ +/* Copyright (c) 2006 Secure Endpoints Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +/* $Id$ */ + +#include "credprov.h" +#include + +/* We use the same version.rc file for the main plugin DLL as well as + for the localized resource DLLs.*/ + +#ifndef LANGVER + +#define STR_FILEDESC "My Credentials Provider Plugin for NetIDMgr" +#define STR_INTNAME MYPLUGIN_NAME +#define STR_ORIGNAME MYPLUGIN_DLLBASE ".dll" + +#else + +#ifdef LANG_en_us + +#define STR_FILEDESC "English(US) language resources for My Credentials Provider" +#define STR_INTNAME MYPLUGIN_DLLBASE "_en_us" +#define STR_ORIGNAME MYPLUGIN_DLLBASE "_en_us.dll" + +#else + +#error Unknown langugae + +#endif + +#endif + +1 VERSIONINFO + FILEVERSION VERSION_LISTC + PRODUCTVERSION VERSION_LISTC + FILEFLAGSMASK KH_VER_FILEFLAGMASK + FILEFLAGS KH_VER_FILEFLAGS + FILEOS KH_VER_FILEOS + FILETYPE KH_VER_FILETYPEDLL + FILESUBTYPE 0 + { + + BLOCK "StringFileInfo" + { + BLOCK "040904b0" + { + VALUE "CompanyName", "My Company" + VALUE "FileDescription", "My OpenAFS NIM Plug-in Extension" + VALUE "FileVersion", VERSION_STRING + VALUE "InternalName", STR_INTNAME + VALUE "LegalCopyright", "(C) 2008 My Company" + VALUE "OriginalFilename", STR_ORIGNAME + VALUE "ProductName", "My Plugin Product" + VALUE "ProductVersion", VERSION_STRING +#ifndef LANGVER + VALUE NIMV_MODULE, MYMODULE_NAME + +/* if more than one plugin is provided by this module, then all of + those plugins should be listed here separated by commas. */ + VALUE NIMV_PLUGINS, MYPLUGIN_NAME + + VALUE NIMV_APIVER, KH_VERSION_STRINGAPI + VALUE NIMV_SUPPORT, "http://example.com/myplugin" +#endif + } + } + + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 1200 + } + }