2 * Copyright (c) 2000-2001,2011,2014 Apple 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.
22 Contains: Classes to parse XML plists and fill in MDS DBs with the
23 attributes found there.
25 Copyright (c) 2001,2011,2014 Apple Inc. All Rights Reserved.
28 #ifndef _MDS_ATTR_PARSER_H_
29 #define _MDS_ATTR_PARSER_H_ 1
31 #include <Security/cssmtype.h>
32 #include "MDSSession.h"
33 #include "MDSDictionary.h"
34 #include "MDSAttrStrings.h"
35 #include <CoreFoundation/CoreFoundation.h>
38 * Hard-coded strings, which we attempt to keep to a minimum
41 /* extension of a bundle's MDS files */
42 #define MDS_INFO_TYPE "mdsinfo"
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"
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"
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"
57 /* key for file description string, for debugging and documentation (since
58 * PropertyListEditor does not support comments) */
59 #define MDS_INFO_FILE_DESC "MdsFileDescription"
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.
73 /* base class for all parsers */
78 const char *bundlePath
,
80 CSSM_DB_HANDLE objectHand
,
81 CSSM_DB_HANDLE cdsaDirHand
);
82 virtual ~MDSAttrParser();
84 /* the bulk of the work */
85 void parseAttrs(CFStringRef subdir
= NULL
);
87 /* parse a single file, by path URL -- throws on parse error */
88 void parseFile(CFURLRef theFileUrl
, CFStringRef subdir
= NULL
);
90 void setDefaults(const MDS_InstallDefaults
*defaults
) { mDefaults
= defaults
; }
92 const char *guid() { return mGuid
; }
98 CFStringRef errStr
, // optional if you have it
99 SInt32
*errNo
); // optional if you have it
102 * Parse a CSSM info file.
105 MDSDictionary
*theDict
);
108 * Parse a Plugin Common info file.
110 void parsePluginCommon(
111 MDSDictionary
*theDict
);
114 * Parse a Plugin-specific file.
116 void parsePluginSpecific(
117 MDSDictionary
*theDict
);
120 * Given an open dictionary (representing a parsed XML file), create
121 * an MDS_OBJECT_RECORDTYPE record and add it to mObjectHand. This is
122 * used by both parseCssmInfo and parsePluginCommon.
124 void parseObjectRecord(
125 MDSDictionary
*dict
);
128 * Given an open dictionary and a RelationInfo defining a schema, fetch all
129 * attributes associated with the specified schema from the dictionary
130 * and write them to specified DB.
133 MDSDictionary
*mdsDict
,
134 const RelationInfo
*relInfo
,
135 CSSM_DB_HANDLE dbHand
);
138 * Special case handlers for MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE and
139 * MDS_CDSADIR_TP_OIDS_RECORDTYPE.
141 void parseCspCapabilitiesRecord(
142 MDSDictionary
*mdsDict
);
143 void parseTpPolicyOidsRecord(
144 MDSDictionary
*mdsDict
);
147 /* could be Security.framework or a loadable bundle anywhere */
151 /* a DL session and two open DBs - one for object directory, one for
154 CSSM_DB_HANDLE mObjectHand
;
155 CSSM_DB_HANDLE mCdsaDirHand
;
157 char *mGuid
; // should this be a CFStringRef instead?
159 // Guid/SSID defaults
160 const MDS_InstallDefaults
*mDefaults
;
164 } // end namespace Security
166 #endif /* _MDS_ATTR_PARSER_H_ */