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 void GetDbNames(CSSM_NAME_LIST_PTR
&NameList
);
49 void FreeNameList(CSSM_NAME_LIST
&NameList
);
50 void DbDelete(const char *DbName
,
51 const CSSM_NET_ADDRESS
*DbLocation
,
52 const AccessCredentials
*AccessCred
);
53 void DbCreate(const char *DbName
,
54 const CSSM_NET_ADDRESS
*DbLocation
,
55 const CSSM_DBINFO
&DBInfo
,
56 CSSM_DB_ACCESS_TYPE AccessRequest
,
57 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
58 const void *OpenParameters
,
59 CSSM_DB_HANDLE
&DbHandle
);
60 void DbOpen(const char *DbName
,
61 const CSSM_NET_ADDRESS
*DbLocation
,
62 CSSM_DB_ACCESS_TYPE AccessRequest
,
63 const AccessCredentials
*AccessCred
,
64 const void *OpenParameters
,
65 CSSM_DB_HANDLE
&DbHandle
);
66 void DbClose(CSSM_DB_HANDLE DBHandle
);
67 void CreateRelation(CSSM_DB_HANDLE DBHandle
,
68 CSSM_DB_RECORDTYPE RelationID
,
69 const char *RelationName
,
70 uint32 NumberOfAttributes
,
71 const CSSM_DB_SCHEMA_ATTRIBUTE_INFO
&pAttributeInfo
,
72 uint32 NumberOfIndexes
,
73 const CSSM_DB_SCHEMA_INDEX_INFO
&pIndexInfo
);
74 void DestroyRelation(CSSM_DB_HANDLE DBHandle
,
75 CSSM_DB_RECORDTYPE RelationID
);
77 void Authenticate(CSSM_DB_HANDLE DBHandle
,
78 CSSM_DB_ACCESS_TYPE AccessRequest
,
79 const AccessCredentials
&AccessCred
);
80 void GetDbAcl(CSSM_DB_HANDLE DBHandle
,
81 const CSSM_STRING
*SelectionTag
,
82 uint32
&NumberOfAclInfos
,
83 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
84 void ChangeDbAcl(CSSM_DB_HANDLE DBHandle
,
85 const AccessCredentials
&AccessCred
,
86 const CSSM_ACL_EDIT
&AclEdit
);
87 void GetDbOwner(CSSM_DB_HANDLE DBHandle
,
88 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
89 void ChangeDbOwner(CSSM_DB_HANDLE DBHandle
,
90 const AccessCredentials
&AccessCred
,
91 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
92 void GetDbNameFromHandle(CSSM_DB_HANDLE DBHandle
,
94 void DataInsert(CSSM_DB_HANDLE DBHandle
,
95 CSSM_DB_RECORDTYPE RecordType
,
96 const CSSM_DB_RECORD_ATTRIBUTE_DATA
*Attributes
,
98 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
99 void DataDelete(CSSM_DB_HANDLE DBHandle
,
100 const CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
);
101 void DataModify(CSSM_DB_HANDLE DBHandle
,
102 CSSM_DB_RECORDTYPE RecordType
,
103 CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
,
104 const CSSM_DB_RECORD_ATTRIBUTE_DATA
*AttributesToBeModified
,
105 const CssmData
*DataToBeModified
,
106 CSSM_DB_MODIFY_MODE ModifyMode
);
107 CSSM_HANDLE
DataGetFirst(CSSM_DB_HANDLE DBHandle
,
108 const DLQuery
*Query
,
109 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
111 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
112 bool DataGetNext(CSSM_DB_HANDLE DBHandle
,
113 CSSM_HANDLE ResultsHandle
,
114 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
116 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueId
);
117 void DataAbortQuery(CSSM_DB_HANDLE DBHandle
,
118 CSSM_HANDLE ResultsHandle
);
119 void DataGetFromUniqueRecordId(CSSM_DB_HANDLE DBHandle
,
120 const CSSM_DB_UNIQUE_RECORD
&UniqueRecord
,
121 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
123 void FreeUniqueRecord(CSSM_DB_HANDLE DBHandle
,
124 CSSM_DB_UNIQUE_RECORD
&UniqueRecord
);
125 void PassThrough(CSSM_DB_HANDLE DBHandle
,
126 uint32 PassThroughId
,
127 const void *InputParams
,
128 void **OutputParams
);
130 CssmAllocator
&allocator() { return *static_cast<DatabaseSession
*>(this); }
132 SSDatabase
findDbHandle(CSSM_DB_HANDLE inDbHandle
);
134 CSSM_DB_HANDLE
makeDbHandle(SSDatabase
&inDb
);
135 SSDatabase
killDbHandle(CSSM_DB_HANDLE inDbHandle
);
138 typedef map
<CSSM_DB_HANDLE
, SSDatabase
> DbHandleMap
;
139 DbHandleMap mDbHandleMap
;
141 CSSM_DB_UNIQUE_RECORD_PTR
makeSSUniqueRecord(SSUniqueRecord
&uniqueId
);
142 SSUniqueRecord
killSSUniqueRecord(CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
143 SSUniqueRecord
findSSUniqueRecord(const CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
145 CSSM_DB_UNIQUE_RECORD_PTR
createUniqueRecord(CSSM_HANDLE ref
);
146 CSSM_HANDLE
parseUniqueRecord(const CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
147 void freeUniqueRecord(CSSM_DB_UNIQUE_RECORD
&inUniqueRecord
);
149 Mutex mSSUniqueRecordLock
;
150 typedef map
<CSSM_HANDLE
, SSUniqueRecord
> SSUniqueRecordMap
;
151 SSUniqueRecordMap mSSUniqueRecordMap
;
157 #endif // _H_SSDLSESSION