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 // SSDLSession.h - DL session for security server CSP/DL.
22 #ifndef _H_SSDLSESSION
23 #define _H_SSDLSESSION
25 #include <Security/DLsession.h>
27 #include "SSDatabase.h"
32 class SSDLSession
: public DLPluginSession
35 SSCSPDLSession
&mSSCSPDLSession
;
37 SSDLSession(CSSM_MODULE_HANDLE handle
,
39 const CSSM_VERSION
&version
,
41 CSSM_SERVICE_TYPE subserviceType
,
42 CSSM_ATTACH_FLAGS attachFlags
,
43 const CSSM_UPCALLS
&upcalls
,
44 DatabaseManager
&databaseManager
,
45 SSCSPDLSession
&ssCSPDLSession
);
48 SecurityServer::ClientSession
&clientSession()
49 { return mClientSession
; }
50 void GetDbNames(CSSM_NAME_LIST_PTR
&NameList
);
51 void FreeNameList(CSSM_NAME_LIST
&NameList
);
52 void DbDelete(const char *DbName
,
53 const CSSM_NET_ADDRESS
*DbLocation
,
54 const AccessCredentials
*AccessCred
);
55 void DbCreate(const char *DbName
,
56 const CSSM_NET_ADDRESS
*DbLocation
,
57 const CSSM_DBINFO
&DBInfo
,
58 CSSM_DB_ACCESS_TYPE AccessRequest
,
59 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
60 const void *OpenParameters
,
61 CSSM_DB_HANDLE
&DbHandle
);
62 void DbOpen(const char *DbName
,
63 const CSSM_NET_ADDRESS
*DbLocation
,
64 CSSM_DB_ACCESS_TYPE AccessRequest
,
65 const AccessCredentials
*AccessCred
,
66 const void *OpenParameters
,
67 CSSM_DB_HANDLE
&DbHandle
);
68 void DbClose(CSSM_DB_HANDLE DBHandle
);
69 void CreateRelation(CSSM_DB_HANDLE DBHandle
,
70 CSSM_DB_RECORDTYPE RelationID
,
71 const char *RelationName
,
72 uint32 NumberOfAttributes
,
73 const CSSM_DB_SCHEMA_ATTRIBUTE_INFO
&pAttributeInfo
,
74 uint32 NumberOfIndexes
,
75 const CSSM_DB_SCHEMA_INDEX_INFO
&pIndexInfo
);
76 void DestroyRelation(CSSM_DB_HANDLE DBHandle
,
77 CSSM_DB_RECORDTYPE RelationID
);
79 void Authenticate(CSSM_DB_HANDLE DBHandle
,
80 CSSM_DB_ACCESS_TYPE AccessRequest
,
81 const AccessCredentials
&AccessCred
);
82 void GetDbAcl(CSSM_DB_HANDLE DBHandle
,
83 const CSSM_STRING
*SelectionTag
,
84 uint32
&NumberOfAclInfos
,
85 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
86 void ChangeDbAcl(CSSM_DB_HANDLE DBHandle
,
87 const AccessCredentials
&AccessCred
,
88 const CSSM_ACL_EDIT
&AclEdit
);
89 void GetDbOwner(CSSM_DB_HANDLE DBHandle
,
90 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
91 void ChangeDbOwner(CSSM_DB_HANDLE DBHandle
,
92 const AccessCredentials
&AccessCred
,
93 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
94 void GetDbNameFromHandle(CSSM_DB_HANDLE DBHandle
,
96 void DataInsert(CSSM_DB_HANDLE DBHandle
,
97 CSSM_DB_RECORDTYPE RecordType
,
98 const CSSM_DB_RECORD_ATTRIBUTE_DATA
*Attributes
,
100 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
101 void DataDelete(CSSM_DB_HANDLE DBHandle
,
102 const CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
);
103 void DataModify(CSSM_DB_HANDLE DBHandle
,
104 CSSM_DB_RECORDTYPE RecordType
,
105 CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
,
106 const CSSM_DB_RECORD_ATTRIBUTE_DATA
*AttributesToBeModified
,
107 const CssmData
*DataToBeModified
,
108 CSSM_DB_MODIFY_MODE ModifyMode
);
109 CSSM_HANDLE
DataGetFirst(CSSM_DB_HANDLE DBHandle
,
110 const DLQuery
*Query
,
111 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
113 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
114 bool DataGetNext(CSSM_DB_HANDLE DBHandle
,
115 CSSM_HANDLE ResultsHandle
,
116 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
118 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
119 void DataAbortQuery(CSSM_DB_HANDLE DBHandle
,
120 CSSM_HANDLE ResultsHandle
);
121 void DataGetFromUniqueRecordId(CSSM_DB_HANDLE DBHandle
,
122 const CSSM_DB_UNIQUE_RECORD
&UniqueRecord
,
123 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
125 void FreeUniqueRecord(CSSM_DB_HANDLE DBHandle
,
126 CSSM_DB_UNIQUE_RECORD
&UniqueRecord
);
127 void PassThrough(CSSM_DB_HANDLE DBHandle
,
128 uint32 PassThroughId
,
129 const void *InputParams
,
130 void **OutputParams
);
132 CssmAllocator
&allocator() { return *static_cast<DatabaseSession
*>(this); }
134 SSDatabase
findDbHandle(CSSM_DB_HANDLE inDbHandle
);
136 CSSM_DB_HANDLE
makeDbHandle(SSDatabase
&inDb
);
137 SSDatabase
killDbHandle(CSSM_DB_HANDLE inDbHandle
);
140 typedef map
<CSSM_DB_HANDLE
, SSDatabase
> DbHandleMap
;
141 DbHandleMap mDbHandleMap
;
143 CSSM_DB_UNIQUE_RECORD_PTR
makeSSUniqueRecord(SSUniqueRecord
&uniqueId
);
144 SSUniqueRecord
killSSUniqueRecord(CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
145 SSUniqueRecord
findSSUniqueRecord(const CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
147 CSSM_DB_UNIQUE_RECORD_PTR
createUniqueRecord(CSSM_HANDLE ref
);
148 CSSM_HANDLE
parseUniqueRecord(const CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
149 void freeUniqueRecord(CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
151 Mutex mSSUniqueRecordLock
;
152 typedef map
<CSSM_HANDLE
, SSUniqueRecord
> SSUniqueRecordMap
;
153 SSUniqueRecordMap mSSUniqueRecordMap
;
156 SecurityServer::ClientSession mClientSession
;
160 #endif // _H_SSDLSESSION