1/* 2 * Copyright (c) 2000-2004 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// mds_standard - standard-defined MDS record types 21// 22#include <security_cdsa_client/mds_standard.h> 23#include <security_cdsa_client/dlquery.h> 24 25 26namespace Security { 27namespace MDSClient { 28 29 30// 31// CDSA Common relation (one record per module) 32// 33static const char * const commonAttributes[] = { 34 "ModuleID", 35 "ModuleName", 36 "Path", 37 "Desc", 38 "DynamicFlag", 39 "MultiThreadFlag", 40 "ServiceMask", 41 NULL 42}; 43Common::Common() : Record(commonAttributes) { } 44 45string Common::moduleID() const { return mAttributes[0]; } 46string Common::moduleName() const { return mAttributes[1]; } 47string Common::path() const { return mAttributes[2]; } 48string Common::description() const { return mAttributes[3]; } 49bool Common::dynamic() const { return mAttributes[4]; } 50bool Common::singleThreaded() const { return !mAttributes[5]; } 51CSSM_SERVICE_MASK Common::serviceMask() const { return mAttributes[6]; } 52 53 54// 55// Common::Carrier draws in the Common fields for anything with 56// a ModuleID attribute (which must be the first attribute listed) 57// 58Common::Carrier::~Carrier() { } 59 60Common &Common::Carrier::common() const 61{ 62 if (!mCommon) { 63 const CssmDbRecordAttributeData &attrs 64 = dynamic_cast<const Record *>(this)->attributes(); 65 RefPointer<Common> rpc; 66 rpc = Table<Common>(mds()).fetch( 67 Attribute("ModuleID") == string(attrs[0]), 68 CSSMERR_DL_ENDOFDATA); 69 mCommon = rpc; 70 } 71 return *mCommon; 72} 73 74 75// 76// Attributes that are common to all primary relations 77// 78static const char * const primaryAttributes[] = { 79 "ModuleID", 80 "SSID", 81 "ModuleName", 82 "ProductVersion", 83 "Vendor", 84 NULL 85}; 86PrimaryRecord::PrimaryRecord(const char * const * names) 87 : Record(primaryAttributes) 88{ 89 addAttributes(names); 90} 91 92string PrimaryRecord::moduleID() const { return mAttributes[0]; } 93uint32 PrimaryRecord::subserviceID() const { return mAttributes[1]; } 94string PrimaryRecord::moduleName() const { return mAttributes[2]; } 95string PrimaryRecord::productVersion() const { return mAttributes[3]; } 96string PrimaryRecord::vendor() const { return mAttributes[4]; } 97 98 99// 100// CSP Primary relation (one record per CSP SSID) 101// 102static const char * const cspAttributes[] = { 103 // up to Vendor is handled by PrimaryRecord 104 "CspType", 105 "CspFlags", 106 NULL 107}; 108CSP::CSP() : PrimaryRecord(cspAttributes) { } 109 110uint32 CSP::cspType() const { return mAttributes[5]; } 111CSSM_CSP_FLAGS CSP::cspFlags() const { return mAttributes[6]; } 112 113 114// 115// CSP capabilities relation 116// 117static const char * const capAttributes[] = { 118 "ModuleID", 119 "SSID", 120 "ContextType", 121 "AlgType", 122 "GroupId", 123 "AttributeType", 124 "Description", 125 NULL 126}; 127CSPCapabilities::CSPCapabilities() : Record(capAttributes) { } 128 129string CSPCapabilities::moduleID() const { return mAttributes[0]; } 130uint32 CSPCapabilities::subserviceID() const { return mAttributes[1]; } 131uint32 CSPCapabilities::contextType() const { return mAttributes[2]; } 132uint32 CSPCapabilities::algorithm() const { return mAttributes[3]; } 133uint32 CSPCapabilities::group() const { return mAttributes[4]; } 134uint32 CSPCapabilities::attribute() const { return mAttributes[5]; } 135string CSPCapabilities::description() const { return mAttributes[6]; } 136 137 138// 139// CSP SmartcardInfo relation (one record per smartcard token present) 140// 141static const char * const scAttributes[] = { 142 "ModuleID", 143 "SSID", 144 "ScDesc", 145 "ScVendor", 146 "ScVersion", 147 "ScFirmwareVersion", 148 "ScFlags", 149 "ScCustomFlags", 150 "ScSerialNumber", 151 NULL 152}; 153SmartcardInfo::SmartcardInfo() : Record(scAttributes) { } 154 155string SmartcardInfo::moduleID() const { return mAttributes[0]; } 156uint32 SmartcardInfo::subserviceID() const { return mAttributes[1]; } 157string SmartcardInfo::description() const { return mAttributes[2]; } 158string SmartcardInfo::vendor() const { return mAttributes[3]; } 159string SmartcardInfo::version() const { return mAttributes[4]; } 160string SmartcardInfo::firmware() const { return mAttributes[5]; } 161CSSM_SC_FLAGS SmartcardInfo::flags() const { return mAttributes[6]; } 162CSSM_SC_FLAGS SmartcardInfo::customFlags() const { return mAttributes[7]; } 163string SmartcardInfo::serial() const { return mAttributes[8]; } 164 165 166// 167// DL Primary relation (one record per DL SSID) 168// 169static const char * const dlAttributes[] = { 170 // up to Vendor is handled by PrimaryRecord 171 "DLType", 172 "QueryLimitsFlag", 173 NULL 174}; 175DL::DL() : PrimaryRecord(dlAttributes) { } 176 177uint32 DL::dlType() const { return mAttributes[5]; } 178uint32 DL::queryLimits() const { return mAttributes[6]; } 179 180 181// 182// CL Primary relation (one record per CL SSID) 183// 184static const char * const clAttributes[] = { 185 // up to Vendor is handled by PrimaryRecord 186 "CertTypeFormat", 187 "CrlTypeFormat", 188 NULL 189}; 190CL::CL() : PrimaryRecord(clAttributes) { } 191 192uint32 CL::certTypeFormat() const { return mAttributes[5]; } 193uint32 CL::crlTypeFormat() const { return mAttributes[6]; } 194 195 196// 197// TP Primary relation (one record per TP SSID) 198// 199static const char * const tpAttributes[] = { 200 // up to Vendor is handled by PrimaryRecord 201 "CertTypeFormat", 202 NULL 203}; 204TP::TP() : PrimaryRecord(tpAttributes) { } 205 206uint32 TP::certTypeFormat() const { return mAttributes[5]; } 207 208 209// 210// TP Policy-OIDS relation (one record per supported policy and TP) 211// 212static const char * const policyAttributes[] = { 213 "ModuleID", 214 "SSID", 215 "OID", 216 "Value", 217 NULL 218}; 219PolicyOids::PolicyOids() : Record(policyAttributes) { } 220 221string PolicyOids::moduleID() const { return mAttributes[0]; } 222uint32 PolicyOids::subserviceID() const { return mAttributes[1]; } 223CssmData PolicyOids::oid() const { return mAttributes[2]; } 224CssmData PolicyOids::value() const { return mAttributes[3]; } 225 226 227} // end namespace MDSClient 228} // end namespace Security 229