2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
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
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.
20 // pluginsession - an attachment session for a CSSM plugin
22 #ifndef _H_PLUGINSESSION
23 #define _H_PLUGINSESSION
25 #include <Security/c++plugin.h>
26 #include <Security/handleobject.h>
27 #include <Security/cssmalloc.h>
30 #ifdef _CPP_PLUGINSESSION
38 // A PluginSession object describes an ongoing connection between a particular
39 // CSSM client and our plugin. Every time CSSM_SPI_ModuleAttach is called
40 // (due to the client calling CSSM_ModuleAttach), a new PluginSession object
41 // is created as a result. Sessions and CSSM_MODULE_HANDLES correspond one-to-one.
43 // PluginSession is meant to be the parent class of your session object.
44 // This is where you store per-session information.
46 class PluginSession
: public CssmAllocator
, public HandledObject
{
48 friend class CssmPlugin
;
50 PluginSession(CSSM_MODULE_HANDLE theHandle
,
52 const CSSM_VERSION
&Version
,
54 CSSM_SERVICE_TYPE SubServiceType
,
55 CSSM_ATTACH_FLAGS AttachFlags
,
56 const CSSM_UPCALLS
&upcalls
);
57 virtual ~PluginSession();
58 virtual void detach();
62 void sendCallback(CSSM_MODULE_EVENT event
,
63 uint32 subId
= uint32(-1),
64 CSSM_SERVICE_TYPE serviceType
= 0) const;
66 static void unimplemented() { CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
); }
69 virtual CSSM_MODULE_FUNCS_PTR
construct() = 0;
72 // implement CssmHeap::Allocator
73 void *malloc(size_t size
) throw(std::bad_alloc
);
74 void *realloc(void *addr
, size_t size
) throw(std::bad_alloc
);
75 void free(void *addr
) throw() { upcalls
.free_func(handle(), addr
); }
77 const CSSM_VERSION
&version() const { return mVersion
; }
78 uint32
subserviceId() const { return mSubserviceId
; }
79 CSSM_SERVICE_TYPE
subserviceType() const { return mSubserviceType
; }
80 CSSM_ATTACH_FLAGS
attachFlags() const { return mAttachFlags
; }
83 CSSM_VERSION mVersion
;
85 CSSM_SERVICE_TYPE mSubserviceType
;
86 CSSM_ATTACH_FLAGS mAttachFlags
;
87 const CSSM_UPCALLS
&upcalls
;
90 } // end namespace Security
92 #ifdef _CPP_PLUGINSESSION
96 #endif //_H_PLUGINSESSION