windows-netidmgr-extension-sample-20080217
authorAsanka Herath <asanka@secure-endpoints.com>
Sun, 17 Feb 2008 14:33:26 +0000 (14:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 17 Feb 2008 14:33:26 +0000 (14:33 +0000)
LICENSE MIT

A sample template for constructing Network Identity Manager OpenAFS
Provider Extensions for obtaining and identifying new token types.

src/WINNT/netidmgr_plugin/extensions/sample/Makefile [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/README [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/afspext.c [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/config_main.c [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/credprov.h [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/images/plugin.ico [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/lang/en_us/langres.rc [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/langres.h [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/main.c [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/plugin.c [new file with mode: 0644]
src/WINNT/netidmgr_plugin/extensions/sample/version.rc [new file with mode: 0644]

diff --git a/src/WINNT/netidmgr_plugin/extensions/sample/Makefile b/src/WINNT/netidmgr_plugin/extensions/sample/Makefile
new file mode 100644 (file)
index 0000000..6c5e8ed
--- /dev/null
@@ -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 <Win32.Mak>
+
+# 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_???) <any additional manifests that need to be merged in>
+#
+
+!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 (file)
index 0000000..64afcda
--- /dev/null
@@ -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\<Module name>]
+       "ImagePath"="<path>"
+
+    The <path> should be the full path to the plug-in DLL.
+
+    <Module name> 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 (file)
index 0000000..4960e31
--- /dev/null
@@ -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<assert.h>
+
+/* 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 (file)
index 0000000..9a338a8
--- /dev/null
@@ -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 <assert.h>
+
+/* 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 (file)
index 0000000..6d617f2
--- /dev/null
@@ -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<windows.h>
+/* include the standard NetIDMgr header files */
+#include<netidmgr.h>
+
+/* And the AFS plug-in extension header file */
+#include "afspext.h"
+#include<tchar.h>
+
+/* declarations for language resources */
+#include "langres.h"
+
+#ifndef NOSTRSAFE
+#include<strsafe.h>
+#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 (file)
index 0000000..99ffbc4
Binary files /dev/null and b/src/WINNT/netidmgr_plugin/extensions/sample/images/plugin.ico differ
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 (file)
index 0000000..ae1a6f9
--- /dev/null
@@ -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 (file)
index 0000000..4748d0a
--- /dev/null
@@ -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 (file)
index 0000000..fdb4a83
--- /dev/null
@@ -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 (file)
index 0000000..e13c538
--- /dev/null
@@ -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<assert.h>
+
+/* 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 (file)
index 0000000..cedaf9e
--- /dev/null
@@ -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<netidmgr_version.h>
+
+/* 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
+    }
+  }