2 * Copyright (c) 2000-2001,2004 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.
20 // MDSSchema.cpp - COPIED FROM libsecurity_mds since this is not exported from
24 // Definitions of structures which define the schema, including attributes
25 // and indexes, for the standard tables that are part of the MDS database.
28 #include "MDSSchema.h"
30 #include <Security/mds_schema.h>
33 * There appears to be a bug in AppleDatabase which prevents our assigning
34 * schema to the meta-tables.
36 #define DEFINE_META_TABLES 0
39 // Schema for the lone table in the Object Directory Database.
41 static const CSSM_DB_ATTRIBUTE_INFO objectAttrs
[] = {
42 DB_ATTRIBUTE(ModuleID
, STRING
),
43 DB_ATTRIBUTE(Manifest
, BLOB
),
44 DB_ATTRIBUTE(ModuleName
, STRING
),
45 DB_ATTRIBUTE(Path
, STRING
),
46 DB_ATTRIBUTE(ProductVersion
, STRING
),
48 /* not in the CDSA spec; denotes a plugin which is statically linked to CSSM */
49 DB_ATTRIBUTE(BuiltIn
, UINT32
),
52 static const CSSM_DB_INDEX_INFO objectIndex
[] = {
53 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
)
56 const RelationInfo kObjectRelation
=
57 RELATION_INFO(MDS_OBJECT_RECORDTYPE
,
62 // Schema for the various tables in the CDSA Directory Database.
66 static const CSSM_DB_ATTRIBUTE_INFO cssmAttrs
[] =
68 DB_ATTRIBUTE(ModuleID
, STRING
),
69 DB_ATTRIBUTE(CDSAVersion
, STRING
),
70 DB_ATTRIBUTE(Vendor
, STRING
),
71 DB_ATTRIBUTE(Desc
, STRING
),
72 DB_ATTRIBUTE(NativeServices
, UINT32
),
75 static const CSSM_DB_INDEX_INFO cssmIndex
[] =
77 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
)
81 static const CSSM_DB_ATTRIBUTE_INFO krmmAttrs
[] =
83 DB_ATTRIBUTE(CSSMGuid
, STRING
),
84 DB_ATTRIBUTE(PolicyType
, UINT32
),
85 DB_ATTRIBUTE(PolicyName
, STRING
),
86 DB_ATTRIBUTE(PolicyPath
, STRING
),
87 DB_ATTRIBUTE(PolicyInfo
, BLOB
),
88 DB_ATTRIBUTE(PolicyManifest
, BLOB
),
90 * This attribute is not defined in the CDSA spec. It's only here, in the schema,
91 * to avoid throwing exceptions when searching a DB for any records associated
92 * with a specified GUID - in all other schemas, a guid is specified as a
95 DB_ATTRIBUTE(ModuleID
, STRING
),
98 static const CSSM_DB_INDEX_INFO krmmIndex
[] =
100 UNIQUE_INDEX_ATTRIBUTE(CSSMGuid
, STRING
),
101 UNIQUE_INDEX_ATTRIBUTE(PolicyType
, UINT32
)
105 static const CSSM_DB_ATTRIBUTE_INFO emmAttrs
[] =
107 DB_ATTRIBUTE(ModuleID
, STRING
),
108 DB_ATTRIBUTE(Manifest
, BLOB
),
109 DB_ATTRIBUTE(ModuleName
, STRING
),
110 DB_ATTRIBUTE(Path
, STRING
),
111 DB_ATTRIBUTE(CDSAVersion
, STRING
),
112 DB_ATTRIBUTE(EMMSpecVersion
, STRING
),
113 DB_ATTRIBUTE(Desc
, STRING
),
114 DB_ATTRIBUTE(PolicyStmt
, BLOB
),
115 DB_ATTRIBUTE(EmmVersion
, STRING
),
116 DB_ATTRIBUTE(EmmVendor
, STRING
),
117 DB_ATTRIBUTE(EmmType
, UINT32
), // does this need a name/value table?
120 static const CSSM_DB_INDEX_INFO emmIndex
[] =
122 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
)
125 // Primary EMM Service Provider Relation.
126 static const CSSM_DB_ATTRIBUTE_INFO emmPrimaryAttrs
[] =
128 DB_ATTRIBUTE(ModuleID
, STRING
),
129 DB_ATTRIBUTE(SSID
, UINT32
),
130 DB_ATTRIBUTE(ServiceType
, UINT32
),
131 DB_ATTRIBUTE(Manifest
, BLOB
),
132 DB_ATTRIBUTE(ModuleName
, STRING
),
133 DB_ATTRIBUTE(ProductVersion
, STRING
),
134 DB_ATTRIBUTE(Vendor
, STRING
),
135 DB_ATTRIBUTE(SampleTypes
, MULTI_UINT32
),
136 DB_ATTRIBUTE(AclSubjectTypes
, MULTI_UINT32
),
137 DB_ATTRIBUTE(AuthTags
, MULTI_UINT32
),
138 DB_ATTRIBUTE(EmmSpecVersion
, STRING
),
141 static const CSSM_DB_INDEX_INFO emmPrimaryIndex
[] =
143 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
144 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
),
145 UNIQUE_INDEX_ATTRIBUTE(ServiceType
, UINT32
)
149 static const CSSM_DB_ATTRIBUTE_INFO commonAttrs
[] =
151 DB_ATTRIBUTE(ModuleID
, STRING
),
152 DB_ATTRIBUTE(Manifest
, BLOB
),
153 DB_ATTRIBUTE(ModuleName
, STRING
),
154 DB_ATTRIBUTE(Path
, STRING
),
155 DB_ATTRIBUTE(CDSAVersion
, STRING
),
156 DB_ATTRIBUTE(Desc
, STRING
),
157 DB_ATTRIBUTE(DynamicFlag
, UINT32
),
158 DB_ATTRIBUTE(MultiThreadFlag
, UINT32
),
159 DB_ATTRIBUTE(ServiceMask
, UINT32
),
162 static const CSSM_DB_INDEX_INFO commonIndex
[] =
164 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
)
167 // CSP Primary Relation.
168 static const CSSM_DB_ATTRIBUTE_INFO cspPrimaryAttrs
[] =
170 DB_ATTRIBUTE(ModuleID
, STRING
),
171 DB_ATTRIBUTE(SSID
, UINT32
),
172 DB_ATTRIBUTE(Manifest
, BLOB
),
173 DB_ATTRIBUTE(ModuleName
, STRING
),
174 DB_ATTRIBUTE(ProductVersion
, STRING
),
175 DB_ATTRIBUTE(Vendor
, STRING
),
176 DB_ATTRIBUTE(CspType
, UINT32
),
177 DB_ATTRIBUTE(CspFlags
, UINT32
),
178 DB_ATTRIBUTE(CspCustomFlags
, UINT32
),
179 DB_ATTRIBUTE(UseeTags
, MULTI_UINT32
),
180 DB_ATTRIBUTE(SampleTypes
, MULTI_UINT32
),
181 DB_ATTRIBUTE(AclSubjectTypes
, MULTI_UINT32
),
182 DB_ATTRIBUTE(AuthTags
, MULTI_UINT32
),
185 static const CSSM_DB_INDEX_INFO cspPrimaryIndex
[] =
187 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
188 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
191 // CSP Capabilities Relation.
192 static const CSSM_DB_ATTRIBUTE_INFO cspCapabilitiesAttrs
[] =
194 DB_ATTRIBUTE(ModuleID
, STRING
),
195 DB_ATTRIBUTE(SSID
, UINT32
),
196 DB_ATTRIBUTE(UseeTag
, UINT32
),
197 DB_ATTRIBUTE(ContextType
, UINT32
),
198 DB_ATTRIBUTE(AlgType
, UINT32
),
199 DB_ATTRIBUTE(GroupId
, UINT32
),
200 DB_ATTRIBUTE(AttributeType
, UINT32
),
201 DB_ATTRIBUTE(AttributeValue
, MULTI_UINT32
),
202 DB_ATTRIBUTE(Description
, STRING
),
205 static const CSSM_DB_INDEX_INFO cspCapabilitiesIndex
[] =
207 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
208 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
),
209 UNIQUE_INDEX_ATTRIBUTE(UseeTag
, UINT32
),
210 UNIQUE_INDEX_ATTRIBUTE(ContextType
, UINT32
),
211 UNIQUE_INDEX_ATTRIBUTE(AlgType
, UINT32
),
212 UNIQUE_INDEX_ATTRIBUTE(GroupId
, UINT32
),
213 UNIQUE_INDEX_ATTRIBUTE(AttributeType
, STRING
)
216 // special case "subschema" for parsing CSPCapabilities. These arrays correspond
217 // dictionaries within a CSPCapabilities info file; they are not part of
218 // our DB's schema. They are declared only to streamline the
219 // MDSAttrParser::parseCspCapabilitiesRecord function. No index info is needed.
221 // top-level info, applied to the dictionary for the whole file.
222 static const CSSM_DB_ATTRIBUTE_INFO kAttributesCSPCapabilitiesDict1
[] =
224 DB_ATTRIBUTE(ModuleID
, STRING
),
225 DB_ATTRIBUTE(SSID
, UINT32
),
227 const RelationInfo CSPCapabilitiesDict1RelInfo
=
229 MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE
, // actually a don't care
230 kAttributesCSPCapabilitiesDict1
,
233 // "Capabilities" is an array of dictionaries of these
234 static const CSSM_DB_ATTRIBUTE_INFO kAttributesCSPCapabilitiesDict2
[] =
236 DB_ATTRIBUTE(AlgType
, UINT32
),
237 DB_ATTRIBUTE(ContextType
, UINT32
),
238 DB_ATTRIBUTE(UseeTag
, UINT32
),
239 DB_ATTRIBUTE(Description
, STRING
),
241 const RelationInfo CSPCapabilitiesDict2RelInfo
=
243 MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE
, // actually a don't care
244 kAttributesCSPCapabilitiesDict2
,
247 // Within a Capabilities array, the Attributes array is an array of
248 // Dictionaries of these.
249 static const CSSM_DB_ATTRIBUTE_INFO kAttributesCSPCapabilitiesDict3
[] =
251 DB_ATTRIBUTE(AttributeType
, UINT32
),
252 DB_ATTRIBUTE(AttributeValue
, MULTI_UINT32
),
254 const RelationInfo CSPCapabilitiesDict3RelInfo
=
256 MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE
, // actually a don't care
257 kAttributesCSPCapabilitiesDict3
,
262 // CSP Encapsulated Products Relation.
263 static const CSSM_DB_ATTRIBUTE_INFO cspEncapsulatedAttrs
[] =
265 DB_ATTRIBUTE(ModuleID
, STRING
),
266 DB_ATTRIBUTE(SSID
, UINT32
),
267 DB_ATTRIBUTE(ProductDesc
, STRING
),
268 DB_ATTRIBUTE(ProductVendor
, STRING
),
269 DB_ATTRIBUTE(ProductVersion
, STRING
),
270 DB_ATTRIBUTE(ProductFlags
, UINT32
),
271 DB_ATTRIBUTE(CustomFlags
, UINT32
),
272 DB_ATTRIBUTE(StandardDesc
, STRING
),
273 DB_ATTRIBUTE(StandardVersion
, STRING
),
274 DB_ATTRIBUTE(ReaderDesc
, STRING
),
275 DB_ATTRIBUTE(ReaderVendor
, STRING
),
276 DB_ATTRIBUTE(ReaderVersion
, STRING
),
277 DB_ATTRIBUTE(ReaderFirmwareVersion
, STRING
),
278 DB_ATTRIBUTE(ReaderFlags
, UINT32
),
279 DB_ATTRIBUTE(ReaderCustomFlags
, UINT32
),
280 DB_ATTRIBUTE(ReaderSerialNumber
, STRING
),
283 static const CSSM_DB_INDEX_INFO cspEncapsulatedIndex
[] =
285 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
286 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
289 // CSP Smartcardinfo Relation.
290 static const CSSM_DB_ATTRIBUTE_INFO cspSmartCardAttrs
[] =
292 DB_ATTRIBUTE(ModuleID
, STRING
),
293 DB_ATTRIBUTE(SSID
, UINT32
),
294 DB_ATTRIBUTE(ScDesc
, STRING
),
295 DB_ATTRIBUTE(ScVendor
, STRING
),
296 DB_ATTRIBUTE(ScVersion
, STRING
),
297 DB_ATTRIBUTE(ScFirmwareVersion
, STRING
),
298 DB_ATTRIBUTE(ScFlags
, UINT32
),
299 DB_ATTRIBUTE(ScCustomFlags
, UINT32
),
300 DB_ATTRIBUTE(ScSerialNumber
, STRING
),
302 static const CSSM_DB_INDEX_INFO cspSmartCardIndex
[] =
304 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
305 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
),
306 UNIQUE_INDEX_ATTRIBUTE(ScDesc
, STRING
),
307 UNIQUE_INDEX_ATTRIBUTE(ScVendor
, STRING
),
308 UNIQUE_INDEX_ATTRIBUTE(ScVersion
, STRING
),
309 UNIQUE_INDEX_ATTRIBUTE(ScFirmwareVersion
, STRING
),
310 UNIQUE_INDEX_ATTRIBUTE(ScFlags
, UINT32
)
313 // DL Primary Relation.
314 static const CSSM_DB_ATTRIBUTE_INFO dlPrimaryAttrs
[] =
316 DB_ATTRIBUTE(ModuleID
, STRING
),
317 DB_ATTRIBUTE(SSID
, UINT32
),
318 DB_ATTRIBUTE(Manifest
, BLOB
),
319 DB_ATTRIBUTE(ModuleName
, STRING
),
320 DB_ATTRIBUTE(ProductVersion
, STRING
),
321 DB_ATTRIBUTE(Vendor
, STRING
),
322 DB_ATTRIBUTE(DLType
, UINT32
),
323 DB_ATTRIBUTE(QueryLimitsFlag
, UINT32
), // a completely bogus attr; see spec
324 DB_ATTRIBUTE(SampleTypes
, MULTI_UINT32
),
325 DB_ATTRIBUTE(AclSubjectTypes
, MULTI_UINT32
),
326 DB_ATTRIBUTE(AuthTags
, MULTI_UINT32
),
327 DB_ATTRIBUTE(ConjunctiveOps
, MULTI_UINT32
),
328 DB_ATTRIBUTE(RelationalOps
, MULTI_UINT32
),
330 static const CSSM_DB_INDEX_INFO dlPrimaryIndex
[] =
332 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
333 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
336 // DL Encapsulated Products Relation.
337 static const CSSM_DB_ATTRIBUTE_INFO dlEncapsulatedAttrs
[] =
339 DB_ATTRIBUTE(ModuleID
, STRING
),
340 DB_ATTRIBUTE(SSID
, UINT32
),
341 DB_ATTRIBUTE(ProductDesc
, STRING
),
342 DB_ATTRIBUTE(ProductVendor
, STRING
),
343 DB_ATTRIBUTE(ProductVersion
, STRING
),
344 DB_ATTRIBUTE(ProductFlags
, UINT32
),
345 DB_ATTRIBUTE(StandardDesc
, STRING
),
346 DB_ATTRIBUTE(StandardVersion
, STRING
),
347 DB_ATTRIBUTE(Protocol
, UINT32
),
348 DB_ATTRIBUTE(RetrievalMode
, UINT32
),
351 static const CSSM_DB_INDEX_INFO dlEncapsulatedIndex
[] =
353 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
354 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
357 // CL Primary Relation.
358 static const CSSM_DB_ATTRIBUTE_INFO clPrimaryAttrs
[] =
360 DB_ATTRIBUTE(ModuleID
, STRING
),
361 DB_ATTRIBUTE(SSID
, UINT32
),
362 DB_ATTRIBUTE(Manifest
, BLOB
),
363 DB_ATTRIBUTE(ModuleName
, STRING
),
364 DB_ATTRIBUTE(ProductVersion
, STRING
),
365 DB_ATTRIBUTE(Vendor
, STRING
),
366 DB_ATTRIBUTE(CertTypeFormat
, UINT32
),
367 DB_ATTRIBUTE(CrlTypeFormat
, UINT32
),
368 DB_ATTRIBUTE(CertFieldNames
, BLOB
),
369 DB_ATTRIBUTE(BundleTypeFormat
, MULTI_UINT32
),
370 DB_ATTRIBUTE(XlationTypeFormat
, MULTI_UINT32
),
371 DB_ATTRIBUTE(TemplateFieldNames
, BLOB
),
374 static const CSSM_DB_INDEX_INFO clPrimaryIndex
[] =
376 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
377 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
380 // CL Encapsulated Products Relation.
381 static const CSSM_DB_ATTRIBUTE_INFO clEncapsulatedAttrs
[] =
383 DB_ATTRIBUTE(ModuleID
, STRING
),
384 DB_ATTRIBUTE(SSID
, UINT32
),
385 DB_ATTRIBUTE(ProductDesc
, STRING
),
386 DB_ATTRIBUTE(ProductVendor
, STRING
),
387 DB_ATTRIBUTE(ProductVersion
, STRING
),
388 DB_ATTRIBUTE(ProductFlags
, UINT32
),
389 DB_ATTRIBUTE(StandardDesc
, STRING
),
390 DB_ATTRIBUTE(StandardVersion
, STRING
),
393 static const CSSM_DB_INDEX_INFO clEncapsulatedIndex
[] =
395 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
396 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
399 // TP Primary Relation.
400 static const CSSM_DB_ATTRIBUTE_INFO tpPrimaryAttrs
[] =
402 DB_ATTRIBUTE(ModuleID
, STRING
),
403 DB_ATTRIBUTE(SSID
, UINT32
),
404 DB_ATTRIBUTE(Manifest
, BLOB
),
405 DB_ATTRIBUTE(ModuleName
, STRING
),
406 DB_ATTRIBUTE(ProductVersion
, STRING
),
407 DB_ATTRIBUTE(Vendor
, STRING
),
408 DB_ATTRIBUTE(CertTypeFormat
, UINT32
),
409 DB_ATTRIBUTE(SampleTypes
, MULTI_UINT32
),
410 DB_ATTRIBUTE(AclSubjectTypes
, MULTI_UINT32
),
411 DB_ATTRIBUTE(AuthTags
, MULTI_UINT32
),
414 static const CSSM_DB_INDEX_INFO tpPrimaryIndex
[] =
416 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
417 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
420 // TP Policy-OIDs Relation.
421 static const CSSM_DB_ATTRIBUTE_INFO tpPolicyOidsAttrs
[] =
423 DB_ATTRIBUTE(ModuleID
, STRING
),
424 DB_ATTRIBUTE(SSID
, UINT32
),
425 DB_ATTRIBUTE(OID
, BLOB
),
426 DB_ATTRIBUTE(Value
, BLOB
),
429 static const CSSM_DB_INDEX_INFO tpPolicyOidsIndex
[] =
431 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
432 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
),
433 UNIQUE_INDEX_ATTRIBUTE(OID
, BLOB
)
436 // special case "subschema" for parsing tpPolicyOidsAttrs. These arrays correspond
437 // dictionaries within a tpPolicyOidsAttrs info file; they are not part of
438 // our DB's schema. They are declared only to streamline the
439 // MDSAttrParser::parseTpPolicyOidsRecord function. No index info is needed.
441 // top-level info, applied to the dictionary for the whole file.
442 static const CSSM_DB_ATTRIBUTE_INFO tpPolicyOidsDict1
[] =
444 DB_ATTRIBUTE(ModuleID
, STRING
),
445 DB_ATTRIBUTE(SSID
, UINT32
),
447 const RelationInfo TpPolicyOidsDict1RelInfo
=
449 MDS_CDSADIR_TP_OIDS_RECORDTYPE
, // actually a don't care
453 // One element of the "Policies" array maps to one of these.
454 static const CSSM_DB_ATTRIBUTE_INFO tpPolicyOidsDict2
[] =
456 DB_ATTRIBUTE(OID
, BLOB
),
457 DB_ATTRIBUTE(Value
, BLOB
),
459 const RelationInfo TpPolicyOidsDict2RelInfo
=
461 MDS_CDSADIR_TP_OIDS_RECORDTYPE
, // actually a don't care
465 // TP Encapsulated Products Relation.
466 static const CSSM_DB_ATTRIBUTE_INFO tpEncapsulatedAttrs
[] =
468 DB_ATTRIBUTE(ModuleID
, STRING
),
469 DB_ATTRIBUTE(SSID
, UINT32
),
470 DB_ATTRIBUTE(ProductDesc
, STRING
),
471 DB_ATTRIBUTE(ProductVendor
, STRING
),
472 DB_ATTRIBUTE(ProductVersion
, STRING
),
473 DB_ATTRIBUTE(ProductFlags
, UINT32
), // vendor-specific, right?
474 DB_ATTRIBUTE(AuthorityRequestType
, MULTI_UINT32
),
475 DB_ATTRIBUTE(StandardDesc
, STRING
),
476 DB_ATTRIBUTE(StandardVersion
, STRING
),
477 DB_ATTRIBUTE(ProtocolDesc
, STRING
),
478 DB_ATTRIBUTE(ProtocolFlags
, UINT32
),
479 DB_ATTRIBUTE(CertClassName
, STRING
),
480 DB_ATTRIBUTE(RootCertificate
, BLOB
),
481 DB_ATTRIBUTE(RootCertTypeFormat
, UINT32
),
483 static const CSSM_DB_INDEX_INFO tpEncapsulatedIndex
[] =
485 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
486 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
489 #if DEFINE_META_TABLES
490 // MDS Schema Relations (meta) Relation.
491 static const CSSM_DB_ATTRIBUTE_INFO mdsSchemaRelationsAttrs
[] =
493 DB_ATTRIBUTE(RelationID
, UINT32
),
494 DB_ATTRIBUTE(RelationName
, STRING
),
497 static const CSSM_DB_INDEX_INFO mdsSchemaRelationsIndex
[] =
499 UNIQUE_INDEX_ATTRIBUTE(RelationID
, UINT32
),
502 // MDS Schema Attributes (meta) Relation.
503 static const CSSM_DB_ATTRIBUTE_INFO mdsSchemaAttributesAttrs
[] =
505 DB_ATTRIBUTE(RelationID
, UINT32
),
506 DB_ATTRIBUTE(AttributeID
, UINT32
),
507 DB_ATTRIBUTE(AttributeNameFormat
, UINT32
),
508 DB_ATTRIBUTE(AttributeName
, STRING
),
509 DB_ATTRIBUTE(AttributeNameID
, BLOB
),
510 DB_ATTRIBUTE(AttributeFormat
, UINT32
),
513 static const CSSM_DB_INDEX_INFO mdsSchemaAttributesIndex
[] =
515 UNIQUE_INDEX_ATTRIBUTE(RelationID
, UINT32
),
516 UNIQUE_INDEX_ATTRIBUTE(AttributeID
, UINT32
)
519 // MDS Schema Indexes (meta) Relation.
520 static const CSSM_DB_ATTRIBUTE_INFO mdsSchemaIndexesAttrs
[] =
522 DB_ATTRIBUTE(RelationID
, UINT32
),
523 DB_ATTRIBUTE(IndexID
, UINT32
),
524 DB_ATTRIBUTE(AttributeID
, UINT32
),
525 DB_ATTRIBUTE(IndexType
, UINT32
),
526 DB_ATTRIBUTE(IndexedDataLocation
, UINT32
),
529 static const CSSM_DB_INDEX_INFO mdsSchemaIndexesIndex
[] =
531 UNIQUE_INDEX_ATTRIBUTE(RelationID
, UINT32
),
532 UNIQUE_INDEX_ATTRIBUTE(IndexID
, UINT32
)
535 #endif /* DEFINE_META_TABLES */
537 // AC Primary Relation.
538 static const CSSM_DB_ATTRIBUTE_INFO acPrimaryAttrs
[] =
540 DB_ATTRIBUTE(ModuleID
, STRING
),
541 DB_ATTRIBUTE(SSID
, UINT32
),
542 DB_ATTRIBUTE(Manifest
, BLOB
),
543 DB_ATTRIBUTE(ModuleName
, STRING
),
544 DB_ATTRIBUTE(ProductVersion
, STRING
),
545 DB_ATTRIBUTE(Vendor
, STRING
),
548 static const CSSM_DB_INDEX_INFO acPrimaryIndex
[] =
550 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
551 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
554 // KR Primary Relation.
555 static const CSSM_DB_ATTRIBUTE_INFO krPrimaryAttrs
[] =
557 DB_ATTRIBUTE(ModuleID
, STRING
),
558 DB_ATTRIBUTE(SSID
, UINT32
),
559 DB_ATTRIBUTE(Manifest
, BLOB
),
560 DB_ATTRIBUTE(ModuleName
, STRING
),
561 DB_ATTRIBUTE(CompatCSSMVersion
, STRING
),
562 DB_ATTRIBUTE(Version
, STRING
),
563 DB_ATTRIBUTE(Vendor
, STRING
),
564 DB_ATTRIBUTE(Description
, STRING
),
565 DB_ATTRIBUTE(ConfigFileLocation
, STRING
),
568 static const CSSM_DB_INDEX_INFO krPrimaryIndex
[] =
570 UNIQUE_INDEX_ATTRIBUTE(ModuleID
, STRING
),
571 UNIQUE_INDEX_ATTRIBUTE(SSID
, UINT32
)
574 // list of all built-in schema for the CDSA Directory DB.
575 const RelationInfo kMDSRelationInfo
[] =
577 RELATION_INFO(MDS_CDSADIR_CSSM_RECORDTYPE
,
580 RELATION_INFO(MDS_CDSADIR_KRMM_RECORDTYPE
,
583 RELATION_INFO(MDS_CDSADIR_EMM_RECORDTYPE
,
586 RELATION_INFO(MDS_CDSADIR_EMM_PRIMARY_RECORDTYPE
,
589 RELATION_INFO(MDS_CDSADIR_COMMON_RECORDTYPE
,
592 RELATION_INFO(MDS_CDSADIR_CSP_PRIMARY_RECORDTYPE
,
595 RELATION_INFO(MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE
,
596 cspCapabilitiesAttrs
,
597 cspCapabilitiesIndex
),
598 RELATION_INFO(MDS_CDSADIR_CSP_ENCAPSULATED_PRODUCT_RECORDTYPE
,
599 cspEncapsulatedAttrs
,
600 cspEncapsulatedIndex
),
601 RELATION_INFO(MDS_CDSADIR_CSP_SC_INFO_RECORDTYPE
,
604 RELATION_INFO(MDS_CDSADIR_DL_PRIMARY_RECORDTYPE
,
607 RELATION_INFO(MDS_CDSADIR_DL_ENCAPSULATED_PRODUCT_RECORDTYPE
,
609 dlEncapsulatedIndex
),
610 RELATION_INFO(MDS_CDSADIR_CL_PRIMARY_RECORDTYPE
,
613 RELATION_INFO(MDS_CDSADIR_CL_ENCAPSULATED_PRODUCT_RECORDTYPE
,
615 clEncapsulatedIndex
),
616 RELATION_INFO(MDS_CDSADIR_TP_PRIMARY_RECORDTYPE
,
619 RELATION_INFO(MDS_CDSADIR_TP_OIDS_RECORDTYPE
,
622 RELATION_INFO(MDS_CDSADIR_TP_ENCAPSULATED_PRODUCT_RECORDTYPE
,
624 tpEncapsulatedIndex
),
625 #if DEFINE_META_TABLES
626 RELATION_INFO(MDS_CDSADIR_MDS_SCHEMA_RELATIONS
,
627 mdsSchemaRelationsAttrs
,
628 mdsSchemaRelationsIndex
),
629 RELATION_INFO(MDS_CDSADIR_MDS_SCHEMA_ATTRIBUTES
,
630 mdsSchemaAttributesAttrs
,
631 mdsSchemaAttributesIndex
),
632 RELATION_INFO(MDS_CDSADIR_MDS_SCHEMA_INDEXES
,
633 mdsSchemaIndexesAttrs
,
634 mdsSchemaIndexesIndex
),
635 #endif /* DEFINE_META_TABLES */
636 RELATION_INFO(MDS_CDSADIR_AC_PRIMARY_RECORDTYPE
,
639 RELATION_INFO(MDS_CDSADIR_KR_PRIMARY_RECORDTYPE
,
644 const unsigned kNumMdsRelations
= sizeof(kMDSRelationInfo
) / sizeof(RelationInfo
);
646 // Map a CSSM_DB_RECORDTYPE to a RelationInfo *.
647 extern const RelationInfo
*MDSRecordTypeToRelation(
648 CSSM_DB_RECORDTYPE recordType
)
650 const RelationInfo
*relInfo
= kMDSRelationInfo
;
653 for(dex
=0; dex
<kNumMdsRelations
; dex
++) {
654 if(relInfo
->DataRecordType
== recordType
) {
659 if(recordType
== MDS_OBJECT_RECORDTYPE
) {
660 return &kObjectRelation
;
665 // same as above, based on record type as string.
666 extern const RelationInfo
*MDSRecordTypeNameToRelation(
667 const char *recordTypeName
)
669 const RelationInfo
*relInfo
= kMDSRelationInfo
;
672 for(dex
=0; dex
<kNumMdsRelations
; dex
++) {
673 if(!strcmp(recordTypeName
, relInfo
->relationName
)) {