]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_mds/lib/MDSDatabase.cpp
Security-57031.40.6.tar.gz
[apple/security.git] / Security / libsecurity_mds / lib / MDSDatabase.cpp
1 /*
2 * Copyright (c) 2000-2001,2011,2014 Apple 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 #include "MDSDatabase.h"
20 #include "MDSSchema.h"
21
22 #include <security_cdsa_plugin/DbContext.h>
23 #include <Security/mds_schema.h>
24 #include <Security/cssmerr.h>
25
26 //
27 // MDSDatabaseManager
28 //
29
30 Database *MDSDatabaseManager::make (const DbName &inDbName)
31 {
32 return new MDSDatabase(inDbName, mTableNames);
33 }
34
35 //
36 // MDSDatabase
37 //
38
39 MDSDatabase::MDSDatabase (const DbName &inDbName, const AppleDatabaseTableName *tableNames)
40 : AppleDatabase(inDbName, tableNames)
41 {
42 }
43
44 MDSDatabase::~MDSDatabase ()
45 {
46 }
47
48 DbContext *
49 MDSDatabase::makeDbContext (DatabaseSession &inDatabaseSession,
50 CSSM_DB_ACCESS_TYPE inAccessRequest,
51 const CSSM_ACCESS_CREDENTIALS *inAccessCred,
52 const void *inOpenParameters)
53 {
54 return new DbContext (*this, inDatabaseSession, inAccessRequest,
55 inAccessCred);
56 }
57
58 void
59 MDSDatabase::dbOpen (DbContext &inDbContext)
60 {
61 // XXX Do something more...
62 }
63
64 void
65 MDSDatabase::dbClose ()
66 {
67 // XXX Do something more...
68 }
69
70 // Creating and destroying relations is not exposed as part of the
71 // MDS interface, so these two methods should never be called.
72
73 void
74 MDSDatabase::createRelation(DbContext &dbContext,
75 CSSM_DB_RECORDTYPE inRelationID,
76 const char *inRelationName,
77 uint32 inNumberOfAttributes,
78 const CSSM_DB_SCHEMA_ATTRIBUTE_INFO &inAttributeInfo,
79 uint32 inNumberOfIndexes,
80 const CSSM_DB_SCHEMA_INDEX_INFO &inIndexInfo)
81 {
82 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
83 }
84
85 void
86 MDSDatabase::destroyRelation(DbContext &dbContext,
87 CSSM_DB_RECORDTYPE inRelationID)
88 {
89 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
90 }
91
92 char *
93 MDSDatabase::getDbNameFromHandle (const DbContext &dbContext) const
94 {
95 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
96 }
97
98 CSSM_DB_UNIQUE_RECORD_PTR
99 MDSDatabase::dataInsert (DbContext &dbContext,
100 CSSM_DB_RECORDTYPE RecordType,
101 const CSSM_DB_RECORD_ATTRIBUTE_DATA *Attributes,
102 const CssmData *Data)
103 {
104 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
105 }
106
107 void
108 MDSDatabase::dataDelete (DbContext &dbContext,
109 const CSSM_DB_UNIQUE_RECORD &UniqueRecordIdentifier)
110 {
111 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
112 }
113
114 void
115 MDSDatabase::dataModify (DbContext &dbContext,
116 CSSM_DB_RECORDTYPE RecordType,
117 CSSM_DB_UNIQUE_RECORD &UniqueRecordIdentifier,
118 const CSSM_DB_RECORD_ATTRIBUTE_DATA *AttributesToBeModified,
119 const CssmData *DataToBeModified,
120 CSSM_DB_MODIFY_MODE ModifyMode)
121 {
122 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
123 }
124
125 CSSM_HANDLE
126 MDSDatabase::dataGetFirst (DbContext &dbContext,
127 const CssmQuery *Query,
128 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes,
129 CssmData *Data,
130 CSSM_DB_UNIQUE_RECORD_PTR &UniqueRecordIdentifier)
131 {
132 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
133 }
134
135 bool
136 MDSDatabase::dataGetNext (DbContext &dbContext,
137 CSSM_HANDLE ResultsHandle,
138 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes,
139 CssmData *Data,
140 CSSM_DB_UNIQUE_RECORD_PTR &UniqueRecordIdentifier)
141 {
142 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
143 return false;
144 }
145
146 void
147 MDSDatabase::dataAbortQuery (DbContext &dbContext,
148 CSSM_HANDLE ResultsHandle)
149 {
150 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
151 }
152
153 void
154 MDSDatabase::dataGetFromUniqueRecordId (DbContext &dbContext,
155 const CSSM_DB_UNIQUE_RECORD &UniqueRecord,
156 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes,
157 CssmData *Data)
158 {
159 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
160 }
161
162 void
163 MDSDatabase::freeUniqueRecord (DbContext &dbContext,
164 CSSM_DB_UNIQUE_RECORD &UniqueRecord)
165 {
166 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
167 }
168
169 // Functions that MDS does not support but we must implement to satisfy Database.
170 void
171 MDSDatabase::dbCreate (DbContext &inDbContext, const CSSM_DBINFO &inDBInfo,
172 const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry)
173 {
174 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
175 }
176
177 void
178 MDSDatabase::dbDelete (DatabaseSession &inDatabaseSession,
179 const CSSM_ACCESS_CREDENTIALS *inAccessCred)
180 {
181 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
182 }
183
184 void
185 MDSDatabase::authenticate(DbContext &dbContext,
186 CSSM_DB_ACCESS_TYPE inAccessRequest,
187 const CSSM_ACCESS_CREDENTIALS &inAccessCred)
188 {
189 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
190 }
191
192 void
193 MDSDatabase::getDbAcl(DbContext &dbContext,
194 const CSSM_STRING *inSelectionTag,
195 uint32 &outNumberOfAclInfos,
196 CSSM_ACL_ENTRY_INFO_PTR &outAclInfos)
197 {
198 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
199 }
200
201 void
202 MDSDatabase::changeDbAcl(DbContext &dbContext,
203 const CSSM_ACCESS_CREDENTIALS &inAccessCred,
204 const CSSM_ACL_EDIT &inAclEdit)
205 {
206 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
207 }
208
209 void
210 MDSDatabase::getDbOwner(DbContext &dbContext, CSSM_ACL_OWNER_PROTOTYPE &outOwner)
211 {
212 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
213 }
214
215 void
216 MDSDatabase::changeDbOwner(DbContext &dbContext,
217 const CSSM_ACCESS_CREDENTIALS &inAccessCred,
218 const CSSM_ACL_OWNER_PROTOTYPE &inNewOwner)
219 {
220 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
221 }