]>
git.saurik.com Git - apple/security.git/blob - Keychain/SecCFTypes.cpp
a6a0e378fe816a0d3f06d983a88007777436d3e4
2 * Copyright (c) 2002 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.
19 // SecCFTypes.cpp - CF runtime interface
22 #include <Security/SecCFTypes.h>
23 #include <Security/SecRuntime.h>
24 #include <Security/threading.h>
25 #include <Security/Globals.h>
30 namespace KeychainCore
36 static ModuleNexus
<SecCFTypes
> nexus
;
41 } // end namespace KeychainCore
43 } // end namespace Security
45 using namespace KeychainCore
;
47 SecCFTypes::SecCFTypes() :
50 Certificate("SecCertificate"),
51 CertificateRequest("SecCertificateRequest"),
52 Identity("SecIdentity"),
53 IdentityCursor("SecIdentitySearch"),
54 ItemImpl("SecKeychainItem"),
55 KCCursorImpl("SecKeychainSearch"),
56 KeychainImpl("SecKeychain"),
59 PolicyCursor("SecPolicySearch"),
61 TrustedApplication("SecTrustedApplication")
68 CFClass::CFClass(const char *name
)
70 // initialize the CFRuntimeClass structure
75 finalize
= finalizeType
;
78 copyFormattingDesc
= copyFormattingDescType
;
79 copyDebugDesc
= copyDebugDescType
;
82 typeID
= _CFRuntimeRegisterClass(this);
83 assert(typeID
!= _kCFRuntimeNotATypeID
);
87 CFClass::finalizeType(CFTypeRef cf
)
90 * Called on a CFRelease of any Sec object: single thread through
91 * same lock held by public API calls. This is a recursive lock
92 * so it's safe to do this for CF objects allocated and released
93 * within the Sec layer.
95 StLock
<Mutex
> _(globals().apiLock
);
96 SecCFObject
*obj
= SecCFObject::optional(cf
);
102 CFClass::equalType(CFTypeRef cf1
, CFTypeRef cf2
)
104 // CF checks for pointer equality and ensures type equality already
105 return SecCFObject::optional(cf1
)->equal(*SecCFObject::optional(cf2
));
109 CFClass::hashType(CFTypeRef cf
)
111 return SecCFObject::optional(cf
)->hash();
115 CFClass::copyFormattingDescType(CFTypeRef cf
, CFDictionaryRef dict
)
117 return SecCFObject::optional(cf
)->copyFormattingDesc(dict
);
121 CFClass::copyDebugDescType(CFTypeRef cf
)
123 return SecCFObject::optional(cf
)->copyDebugDesc();