]> git.saurik.com Git - apple/security.git/blob - cdsa/mds/MDSAttrParser.h
Security-164.1.tar.gz
[apple/security.git] / cdsa / mds / MDSAttrParser.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, 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 /*
20 File: MDSAttrParser.h
21
22 Contains: Classes to parse XML plists and fill in MDS DBs with the
23 attributes found there.
24
25 Copyright: (c) 2001 Apple Computer, Inc., all rights reserved.
26 */
27
28 #ifndef _MDS_ATTR_PARSER_H_
29 #define _MDS_ATTR_PARSER_H_ 1
30
31 #include <Security/cssmtype.h>
32 #include "MDSSession.h"
33 #include "MDSDictionary.h"
34 #include "MDSAttrStrings.h"
35 #include <CoreFoundation/CoreFoundation.h>
36
37 /*
38 * Hard-coded strings, which we attempt to keep to a minimum
39 */
40
41 /* extension of a bundle's MDS files */
42 #define MDS_INFO_TYPE "mdsinfo"
43
44 /* key in an MDS info file determining whether it's for CSSM, plugin, or
45 * Plugin-specific MDS record type */
46 #define MDS_INFO_FILE_TYPE "MdsFileType"
47
48 /* Values for MDS_INFO_FILE_TYPE */
49 #define MDS_INFO_FILE_TYPE_CSSM "CSSM"
50 #define MDS_INFO_FILE_TYPE_PLUGIN "PluginCommon"
51 #define MDS_INFO_FILE_TYPE_RECORD "PluginSpecific"
52
53 /* For MDS_INFO_FILE_TYPE_RECORD files, this key is used to find the
54 * CSSM_DB_RECORDTYPE associated with the file's info. */
55 #define MDS_INFO_FILE_RECORD_TYPE "MdsRecordType"
56
57 /* key for file description string, for debugging and documentation (since
58 * PropertyListEditor does not support comments) */
59 #define MDS_INFO_FILE_DESC "MdsFileDescription"
60
61
62 namespace Security
63 {
64
65 /*
66 * The purpose of the MDSAttrParser class is to process a set of plist files
67 * in a specified bundle or framework, parsing them to create data which
68 * is written to a pair of open DBs. Each plist file represents the bundle's
69 * entries for one or more MDS relations. Typically a bundle will have
70 * multiple plist files.
71 */
72
73 /* base class for all parsers */
74 class MDSAttrParser
75 {
76 public:
77 MDSAttrParser(
78 const char *bundlePath,
79 MDSSession &dl,
80 CSSM_DB_HANDLE objectHand,
81 CSSM_DB_HANDLE cdsaDirHand);
82 virtual ~MDSAttrParser();
83
84 /* the bulk of the work */
85 void parseAttrs();
86
87 private:
88 void logFileError(
89 const char *op,
90 CFURLRef file,
91 CFStringRef errStr, // optional if you have it
92 SInt32 *errNo); // optional if you have it
93
94 /*
95 * Parse a CSSM info file.
96 */
97 void parseCssmInfo(
98 MDSDictionary *theDict);
99
100 /*
101 * Parse a Plugin Common info file.
102 */
103 void parsePluginCommon(
104 MDSDictionary *theDict);
105
106 /*
107 * Parse a Plugin-specific file.
108 */
109 void parsePluginSpecific(
110 MDSDictionary *theDict);
111
112 /*
113 * Given an open dictionary (representing a parsed XML file), create
114 * an MDS_OBJECT_RECORDTYPE record and add it to mObjectHand. This is
115 * used by both parseCssmInfo and parsePluginCommon.
116 */
117 void parseObjectRecord(
118 MDSDictionary *dict);
119
120 /*
121 * Given an open dictionary and a RelationInfo defining a schema, fetch all
122 * attributes associated with the specified schema from the dictionary
123 * and write them to specified DB.
124 */
125 void parseMdsRecord(
126 MDSDictionary *mdsDict,
127 const RelationInfo *relInfo,
128 CSSM_DB_HANDLE dbHand);
129
130 /*
131 * Special case handlers for MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE and
132 * MDS_CDSADIR_TP_OIDS_RECORDTYPE.
133 */
134 void parseCspCapabilitiesRecord(
135 MDSDictionary *mdsDict);
136 void parseTpPolicyOidsRecord(
137 MDSDictionary *mdsDict);
138
139 private:
140 /* could be Security.framework or a loadable bundle anywhere */
141 CFBundleRef mBundle;
142 char *mPath;
143
144 /* a DL session and two open DBs - one for object directory, one for
145 * CDSA directory */
146 MDSSession &mDl;
147 CSSM_DB_HANDLE mObjectHand;
148 CSSM_DB_HANDLE mCdsaDirHand;
149 };
150
151
152 } // end namespace Security
153
154 #endif /* _MDS_ATTR_PARSER_H_ */