]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_mds/lib/MDSDatabase.h
Security-58286.200.222.tar.gz
[apple/security.git] / OSX / libsecurity_mds / lib / MDSDatabase.h
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 #ifndef _MDSDATABASE_H_
20 #define _MDSDATABASE_H_ 1
21
22 #include <security_filedb/AppleDatabase.h>
23 #include <security_utilities/threading.h>
24 #include <map>
25
26 /* This is the concrete DatabaseFactory subclass that creates MDSDatabase instances.
27 Specifically with MDS there are always exactly 2 databases with fixed names. These
28 are both created whenever the first Database is requested from this factory. The
29 contents of these databases is constructed on the fly by scanning the CSSM bundle
30 path for plugins and reading the mds segments from there. Asking
31 for a Database with a name different from the 2 allowed ones will result in an
32 exception being thrown.
33 */
34
35 class MDSDatabaseManager: public AppleDatabaseManager
36 {
37 public:
38 MDSDatabaseManager(const AppleDatabaseTableName *tableNames);
39 Database *make(const DbName &inDbName);
40 };
41
42 /* This is the class which represents each of the two MDS databases. */
43
44 class MDSDatabase: public AppleDatabase
45 {
46 public:
47 MDSDatabase(const DbName &inDbName, const AppleDatabaseTableName *tableNames);
48
49 virtual
50 ~MDSDatabase();
51
52 DbContext *
53 makeDbContext(DatabaseSession &inDatabaseSession,
54 CSSM_DB_ACCESS_TYPE inAccessRequest,
55 const AccessCredentials *inAccessCred,
56 const void *inOpenParameters);
57
58 virtual void
59 dbOpen(DbContext &inDbContext);
60
61 virtual void
62 dbClose();
63
64 virtual void
65 dbCreate(DbContext &inDbContext, const CSSM_DBINFO &inDBInfo,
66 const CSSM_ACL_ENTRY_INPUT *inInitialAclEntry);
67
68 virtual void
69 dbDelete(DatabaseSession &inDatabaseSession,
70 const AccessCredentials *inAccessCred);
71
72 virtual void
73 createRelation (DbContext &dbContext,
74 CSSM_DB_RECORDTYPE inRelationID,
75 const char *inRelationName,
76 uint32 inNumberOfAttributes,
77 const CSSM_DB_SCHEMA_ATTRIBUTE_INFO *inAttributeInfo,
78 uint32 inNumberOfIndexes,
79 const CSSM_DB_SCHEMA_INDEX_INFO &inIndexInfo);
80
81 virtual void
82 destroyRelation (DbContext &dbContext, CSSM_DB_RECORDTYPE inRelationID);
83
84 virtual void
85 authenticate(DbContext &dbContext,
86 CSSM_DB_ACCESS_TYPE inAccessRequest,
87 const AccessCredentials &inAccessCred);
88
89 virtual void
90 getDbAcl(DbContext &dbContext,
91 const CSSM_STRING *inSelectionTag,
92 uint32 &outNumberOfAclInfos,
93 CSSM_ACL_ENTRY_INFO_PTR &outAclInfos);
94
95 virtual void
96 changeDbAcl(DbContext &dbContext,
97 const AccessCredentials &inAccessCred,
98 const CSSM_ACL_EDIT &inAclEdit);
99
100 virtual void
101 getDbOwner(DbContext &dbContext, CSSM_ACL_OWNER_PROTOTYPE &outOwner);
102
103 virtual void
104 changeDbOwner(DbContext &dbContext,
105 const AccessCredentials &inAccessCred,
106 const CSSM_ACL_OWNER_PROTOTYPE &inNewOwner);
107
108 virtual char *
109 getDbNameFromHandle (const DbContext &dbContext) const;
110
111 virtual CSSM_DB_UNIQUE_RECORD_PTR
112 dataInsert (DbContext &dbContext,
113 CSSM_DB_RECORDTYPE RecordType,
114 const CSSM_DB_RECORD_ATTRIBUTE_DATA *inAttributes,
115 const CssmData *inData);
116
117 virtual void
118 dataDelete (DbContext &dbContext,
119 const CSSM_DB_UNIQUE_RECORD &inUniqueRecordIdentifier);
120
121 virtual void
122 dataModify (DbContext &dbContext,
123 CSSM_DB_RECORDTYPE RecordType,
124 CSSM_DB_UNIQUE_RECORD &inoutUniqueRecordIdentifier,
125 const CSSM_DB_RECORD_ATTRIBUTE_DATA *inAttributesToBeModified,
126 const CssmData *inDataToBeModified,
127 CSSM_DB_MODIFY_MODE ModifyMode);
128
129 virtual CSSM_HANDLE
130 dataGetFirst (DbContext &dbContext,
131 const CssmQuery *inQuery,
132 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes,
133 CssmData *inoutData,
134 CSSM_DB_UNIQUE_RECORD_PTR &outUniqueRecord);
135
136 virtual bool
137 dataGetNext (DbContext &dbContext,
138 CSSM_HANDLE inResultsHandle,
139 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes,
140 CssmData *inoutData,
141 CSSM_DB_UNIQUE_RECORD_PTR &outUniqueRecord);
142
143 virtual void
144 dataAbortQuery (DbContext &dbContext,
145 CSSM_HANDLE inResultsHandle);
146
147 virtual void
148 dataGetFromUniqueRecordId (DbContext &dbContext,
149 const CSSM_DB_UNIQUE_RECORD &inUniqueRecord,
150 CSSM_DB_RECORD_ATTRIBUTE_DATA_PTR inoutAttributes,
151 CssmData *inoutData);
152
153 virtual void
154 freeUniqueRecord (DbContext &dbContext,
155 CSSM_DB_UNIQUE_RECORD &inUniqueRecord);
156 };
157
158 #endif //_MDSDATABASE_H_