]> git.saurik.com Git - apple/security.git/blob - Keychain/DefaultKeychain.h
Security-54.1.tar.gz
[apple/security.git] / Keychain / DefaultKeychain.h
1 /*
2 * Copyright (c) 2000-2002 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 // DefaultKeychain.h - Default Keychain singleton
20 //
21 #ifndef _SECURITY_DEFAULTKEYCHAIN_H_
22 #define _SECURITY_DEFAULTKEYCHAIN_H_
23
24 #include <Security/DLDBListCFPref.h>
25 #include <Security/Keychains.h>
26
27 namespace Security
28 {
29
30 namespace KeychainCore
31 {
32
33 //---------------------------------------------------------------------------------
34 // Default keychain
35 //
36 // Note that this is strictly a user preference setting, indicating which keychain
37 // should be used to add items to. No validity checking should be done on it in
38 // this class, since it may not be available right now (e.g. on a network volume)
39 //----------------------------------------------------------------------------------
40
41 class Keychain;
42
43 class DefaultKeychain
44 {
45 public:
46 DefaultKeychain();
47
48 // Set/Get via DLDbIdentifier
49 void dLDbIdentifier(const DLDbIdentifier& keychainID);
50 DefaultKeychain &operator =(const DLDbIdentifier& keychainID)
51 { dLDbIdentifier(keychainID); return *this; }
52
53 void reload(bool force = false);
54 DLDbIdentifier dLDbIdentifier();
55 operator DLDbIdentifier () { return dLDbIdentifier(); }
56
57 // Remove if passed in DLDbIdentifier is currently the default
58 void remove(const DLDbIdentifier& keychainID);
59
60 // Set/Get via Keychain
61 void keychain(const Keychain& keychain);
62 DefaultKeychain &operator =(const Keychain& inKeychain) { keychain(inKeychain); return *this; }
63
64 Keychain keychain();
65 operator Keychain () { return keychain(); }
66
67 void unset(); // Who needs a default keychain anyway.
68 bool isSet();
69 private:
70 DLDbListCFPref mPref;
71 DLDbIdentifier defaultID;
72 };
73
74 } // end namespace KeychainCore
75
76 } // end namespace Security
77
78 #endif // !_SECURITY_DEFAULTKEYCHAIN_H_