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.
19 #include "MDSDatabase.h"
20 #include "MDSSchema.h"
22 #include <Security/DbContext.h>
23 #include <Security/mds_schema.h>
24 #include <Security/cssmerr.h>
30 Database
*MDSDatabaseManager::make (const DbName
&inDbName
)
32 return new MDSDatabase(inDbName
, mTableNames
);
39 MDSDatabase::MDSDatabase (const DbName
&inDbName
, const AppleDatabaseTableName
*tableNames
)
40 : AppleDatabase(inDbName
, tableNames
)
44 MDSDatabase::~MDSDatabase ()
49 MDSDatabase::makeDbContext (DatabaseSession
&inDatabaseSession
,
50 CSSM_DB_ACCESS_TYPE inAccessRequest
,
51 const CSSM_ACCESS_CREDENTIALS
*inAccessCred
,
52 const void *inOpenParameters
)
54 return new DbContext (*this, inDatabaseSession
, inAccessRequest
,
59 MDSDatabase::dbOpen (DbContext
&inDbContext
)
61 // XXX Do something more...
65 MDSDatabase::dbClose ()
67 // XXX Do something more...
70 // Creating and destroying relations is not exposed as part of the
71 // MDS interface, so these two methods should never be called.
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
)
82 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
86 MDSDatabase::destroyRelation(DbContext
&dbContext
,
87 CSSM_DB_RECORDTYPE inRelationID
)
89 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
93 MDSDatabase::getDbNameFromHandle (const DbContext
&dbContext
) const
95 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
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
)
104 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
108 MDSDatabase::dataDelete (DbContext
&dbContext
,
109 const CSSM_DB_UNIQUE_RECORD
&UniqueRecordIdentifier
)
111 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
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
)
122 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
126 MDSDatabase::dataGetFirst (DbContext
&dbContext
,
127 const DLQuery
*Query
,
128 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
130 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueRecordIdentifier
)
132 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
136 MDSDatabase::dataGetNext (DbContext
&dbContext
,
137 CSSM_HANDLE ResultsHandle
,
138 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
140 CSSM_DB_UNIQUE_RECORD_PTR
&UniqueRecordIdentifier
)
142 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
147 MDSDatabase::dataAbortQuery (DbContext
&dbContext
,
148 CSSM_HANDLE ResultsHandle
)
150 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
154 MDSDatabase::dataGetFromUniqueRecordId (DbContext
&dbContext
,
155 const CSSM_DB_UNIQUE_RECORD
&UniqueRecord
,
156 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR Attributes
,
159 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
163 MDSDatabase::freeUniqueRecord (DbContext
&dbContext
,
164 CSSM_DB_UNIQUE_RECORD
&UniqueRecord
)
166 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
169 // Functions that MDS does not support but we must implement to satisfy Database.
171 MDSDatabase::dbCreate (DbContext
&inDbContext
, const CSSM_DBINFO
&inDBInfo
,
172 const CSSM_ACL_ENTRY_INPUT
*inInitialAclEntry
)
174 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
178 MDSDatabase::dbDelete (DatabaseSession
&inDatabaseSession
,
179 const CSSM_ACCESS_CREDENTIALS
*inAccessCred
)
181 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
185 MDSDatabase::authenticate(DbContext
&dbContext
,
186 CSSM_DB_ACCESS_TYPE inAccessRequest
,
187 const CSSM_ACCESS_CREDENTIALS
&inAccessCred
)
189 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
193 MDSDatabase::getDbAcl(DbContext
&dbContext
,
194 const CSSM_STRING
*inSelectionTag
,
195 uint32
&outNumberOfAclInfos
,
196 CSSM_ACL_ENTRY_INFO_PTR
&outAclInfos
)
198 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
202 MDSDatabase::changeDbAcl(DbContext
&dbContext
,
203 const CSSM_ACCESS_CREDENTIALS
&inAccessCred
,
204 const CSSM_ACL_EDIT
&inAclEdit
)
206 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
210 MDSDatabase::getDbOwner(DbContext
&dbContext
, CSSM_ACL_OWNER_PROTOTYPE
&outOwner
)
212 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
216 MDSDatabase::changeDbOwner(DbContext
&dbContext
,
217 const CSSM_ACCESS_CREDENTIALS
&inAccessCred
,
218 const CSSM_ACL_OWNER_PROTOTYPE
&inNewOwner
)
220 CssmError ::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);