]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_mds/lib/MDSDatabase.cpp
Security-58286.200.222.tar.gz
[apple/security.git] / OSX / 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 AccessCredentials *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 }
144
145 void
146 MDSDatabase::dataAbortQuery (DbContext &dbContext,
147 CSSM_HANDLE ResultsHandle)
148 {
149 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
150 }
151
152 void
153 MDSDatabase::dataGetFromUniqueRecordId (DbContext &dbContext,
154 const CSSM_DB_UNIQUE_RECORD &UniqueRecord,
155 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes,
156 CssmData *Data)
157 {
158 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
159 }
160
161 void
162 MDSDatabase::freeUniqueRecord (DbContext &dbContext,
163 CSSM_DB_UNIQUE_RECORD &UniqueRecord)
164 {
165 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
166 }
167
168 // Functions that MDS does not support but we must implement to satisfy Database.
169 void
170 MDSDatabase::dbCreate (DbContext &inDbContext, const CSSM_DBINFO &inDBInfo,
171 const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry)
172 {
173 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
174 }
175
176 void
177 MDSDatabase::dbDelete (DatabaseSession &inDatabaseSession,
178 const AccessCredentials *inAccessCred)
179 {
180 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
181 }
182
183 void
184 MDSDatabase::authenticate(DbContext &dbContext,
185 CSSM_DB_ACCESS_TYPE inAccessRequest,
186 const AccessCredentials &inAccessCred)
187 {
188 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
189 }
190
191 void
192 MDSDatabase::getDbAcl(DbContext &dbContext,
193 const CSSM_STRING *inSelectionTag,
194 uint32 &outNumberOfAclInfos,
195 CSSM_ACL_ENTRY_INFO_PTR &outAclInfos)
196 {
197 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
198 }
199
200 void
201 MDSDatabase::changeDbAcl(DbContext &dbContext,
202 const AccessCredentials &inAccessCred,
203 const CSSM_ACL_EDIT &inAclEdit)
204 {
205 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
206 }
207
208 void
209 MDSDatabase::getDbOwner(DbContext &dbContext, CSSM_ACL_OWNER_PROTOTYPE &outOwner)
210 {
211 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
212 }
213
214 void
215 MDSDatabase::changeDbOwner(DbContext &dbContext,
216 const AccessCredentials &inAccessCred,
217 const CSSM_ACL_OWNER_PROTOTYPE &inNewOwner)
218 {
219 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
220 }