]> git.saurik.com Git - apple/security.git/blob - AppleCSPDL/SSDLSession.h
Security-30.1.tar.gz
[apple/security.git] / AppleCSPDL / SSDLSession.h
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 // SSDLSession.h - DL session for security server CSP/DL.
21 //
22 #ifndef _H_SSDLSESSION
23 #define _H_SSDLSESSION
24
25 #include <Security/DLsession.h>
26
27 #include "SSDatabase.h"
28
29 class CSPDLPlugin;
30 class SSCSPDLSession;
31
32 class SSDLSession : public DLPluginSession
33 {
34 public:
35 SSCSPDLSession &mSSCSPDLSession;
36
37 SSDLSession(CSSM_MODULE_HANDLE handle,
38 CSPDLPlugin &plug,
39 const CSSM_VERSION &version,
40 uint32 subserviceId,
41 CSSM_SERVICE_TYPE subserviceType,
42 CSSM_ATTACH_FLAGS attachFlags,
43 const CSSM_UPCALLS &upcalls,
44 DatabaseManager &databaseManager,
45 SSCSPDLSession &ssCSPDLSession);
46 ~SSDLSession();
47
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);
76
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,
93 char **DbName);
94 void DataInsert(CSSM_DB_HANDLE DBHandle,
95 CSSM_DB_RECORDTYPE RecordType,
96 const CSSM_DB_RECORD_ATTRIBUTE_DATA *Attributes,
97 const CssmData *Data,
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,
110 CssmData *Data,
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,
115 CssmData *Data,
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,
122 CssmData *Data);
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);
129
130 CssmAllocator &allocator() { return *static_cast<DatabaseSession *>(this); }
131
132 SSDatabase findDbHandle(CSSM_DB_HANDLE inDbHandle);
133 protected:
134 CSSM_DB_HANDLE makeDbHandle(SSDatabase &inDb);
135 SSDatabase killDbHandle(CSSM_DB_HANDLE inDbHandle);
136
137 Mutex mDbHandleLock;
138 typedef map<CSSM_DB_HANDLE, SSDatabase> DbHandleMap;
139 DbHandleMap mDbHandleMap;
140
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);
144
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);
148
149 Mutex mSSUniqueRecordLock;
150 typedef map<CSSM_HANDLE, SSUniqueRecord> SSUniqueRecordMap;
151 SSUniqueRecordMap mSSUniqueRecordMap;
152
153 CssmClient::DL mDL;
154 };
155
156
157 #endif // _H_SSDLSESSION