]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
1 | /* |
2 | * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. | |
3 | * | |
4 | * The contents of this file constitute Original Code as defined in and are | |
5 | * subject to the Apple Public Source License Version 1.2 (the 'License'). | |
6 | * You may not use this file except in compliance with the License. Please obtain | |
7 | * a copy of the License at http://www.apple.com/publicsource and read it before | |
8 | * using this file. | |
9 | * | |
10 | * This Original Code and all software distributed under the License are | |
11 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS | |
12 | * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT | |
13 | * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | |
14 | * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the | |
15 | * specific language governing rights and limitations under the License. | |
16 | */ | |
17 | ||
18 | ||
19 | // | |
20 | // modloader.h - CSSM module loader interface | |
21 | // | |
22 | // This is a thin abstraction of plugin module loading/handling for CSSM. | |
23 | // The resulting module ("Plugin") notion is specific to CSSM plugin modules. | |
24 | // This implementation uses MacOS X bundles. | |
25 | // | |
26 | #ifndef _H_MODLOADER | |
27 | #define _H_MODLOADER | |
28 | ||
29 | #include <exception> | |
30 | #include <Security/utilities.h> | |
31 | #include <Security/osxsigning.h> | |
32 | #include <Security/cssmint.h> | |
33 | #include <map> | |
34 | #include <string> | |
35 | ||
36 | ||
37 | namespace Security { | |
38 | ||
39 | ||
40 | // | |
41 | // An abstract representation of a loadable plugin. | |
42 | // Note that "loadable" doesn't mean that actual code loading | |
43 | // is necessarily happening, but let's just assume it might. | |
44 | // | |
45 | class Plugin { | |
46 | NOCOPY(Plugin) | |
47 | public: | |
48 | Plugin() { } | |
49 | virtual ~Plugin() { } | |
50 | ||
51 | virtual void load() = 0; | |
52 | virtual void unload() = 0; | |
53 | virtual bool isLoaded() const = 0; | |
54 | ||
55 | virtual CSSM_RETURN CSSM_SPI_ModuleLoad (const CSSM_GUID *CssmGuid, | |
56 | const CSSM_GUID *ModuleGuid, | |
57 | CSSM_SPI_ModuleEventHandler CssmNotifyCallback, | |
58 | void *CssmNotifyCallbackCtx) = 0; | |
59 | virtual CSSM_RETURN CSSM_SPI_ModuleUnload (const CSSM_GUID *CssmGuid, | |
60 | const CSSM_GUID *ModuleGuid, | |
61 | CSSM_SPI_ModuleEventHandler CssmNotifyCallback, | |
62 | void *CssmNotifyCallbackCtx) = 0; | |
63 | virtual CSSM_RETURN CSSM_SPI_ModuleAttach (const CSSM_GUID *ModuleGuid, | |
64 | const CSSM_VERSION *Version, | |
65 | uint32 SubserviceID, | |
66 | CSSM_SERVICE_TYPE SubServiceType, | |
67 | CSSM_ATTACH_FLAGS AttachFlags, | |
68 | CSSM_MODULE_HANDLE ModuleHandle, | |
69 | CSSM_KEY_HIERARCHY KeyHierarchy, | |
70 | const CSSM_GUID *CssmGuid, | |
71 | const CSSM_GUID *ModuleManagerGuid, | |
72 | const CSSM_GUID *CallerGuid, | |
73 | const CSSM_UPCALLS *Upcalls, | |
74 | CSSM_MODULE_FUNCS_PTR *FuncTbl) = 0; | |
75 | virtual CSSM_RETURN CSSM_SPI_ModuleDetach (CSSM_MODULE_HANDLE ModuleHandle) = 0; | |
76 | }; | |
77 | ||
78 | ||
79 | // | |
80 | // The supervisor class that manages searching and loading. | |
81 | // | |
82 | class ModuleLoader { | |
83 | NOCOPY(ModuleLoader) | |
84 | public: | |
85 | ModuleLoader(); | |
86 | ||
87 | Plugin *operator () (const char *path); | |
88 | ||
89 | private: | |
90 | // the table of all loaded modules | |
91 | typedef map<string, Plugin *> PluginTable; | |
92 | PluginTable mPlugins; | |
93 | }; | |
94 | ||
95 | ||
96 | ||
97 | } // end namespace Security | |
98 | ||
99 | ||
100 | #endif //_H_MODLOADER |