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