]> git.saurik.com Git - apple/security.git/blob - Keychain/StorageManager.h
Security-30.1.tar.gz
[apple/security.git] / Keychain / StorageManager.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: StorageManager.h
21
22 Contains: Working with multiple keychains
23
24 Copyright: 2000 by Apple Computer, Inc., all rights reserved.
25
26 To Do:
27 */
28
29 #ifndef _H_STORAGEMANAGER_
30 #define _H_STORAGEMANAGER_
31
32 #include <list>
33 #include <Security/multidldb.h>
34 #include <Security/DLDBListCFPref.h>
35 #include <Security/Keychains.h>
36
37 namespace Security
38 {
39
40 namespace KeychainCore
41 {
42
43 class StorageManager
44 {
45 NOCOPY(StorageManager)
46 public:
47 StorageManager();
48 ~StorageManager() {}
49
50 //bool onlist(const Keychain & keychain);
51
52 // These will call addAndNotify() if the specified keychain already exists
53 Keychain make(const char *fullPathName);
54 void created(const Keychain &keychain); // Be notified a Keychain just got created.
55
56 // Misc
57 void lockAll();
58 void reload(bool force = false);
59
60 void add(const Keychain& keychainToAdd); // Only add if not there yet. Doesn't write out CFPref
61
62 // Vector-like methods.
63 size_t size();
64 Keychain at(unsigned int ix);
65 Keychain operator[](unsigned int ix);
66
67 void erase(const Keychain& keychainToRemove);
68
69 KCCursor createCursor(const SecKeychainAttributeList *attrList);
70 KCCursor createCursor(SecItemClass itemClass, const SecKeychainAttributeList *attrList);
71
72 // Create KC if it doesn't exist, add to cache, but don't modify search list.
73 Keychain keychain(const DLDbIdentifier &dlDbIdentifier);
74
75 // Create KC if it doesn't exist, add it to the search list if it is not already on it.
76 Keychain makeKeychain(const DLDbIdentifier &dlDbIdentifier);
77
78
79 // Keychain list maintenance
80 void remove(const list<SecKeychainRef>& kcsToRemove); // remove keychains from list
81 void replace(const list<SecKeychainRef>& newKCList); // replace keychains list with new list
82 void convert(const list<SecKeychainRef>& SecKeychainRefList,CssmClient::DLDbList& dldbList); // maybe should be private
83
84 // Login keychain support
85 void login(ConstStringPtr name, ConstStringPtr password);
86 void login(UInt32 nameLength, const void *name, UInt32 passwordLength, const void *password);
87 void logout();
88 void changeLoginPassword(ConstStringPtr oldPassword, ConstStringPtr newPassword);
89 void changeLoginPassword(UInt32 oldPasswordLength, const void *oldPassword, UInt32 newPasswordLength, const void *newPassword);
90
91 private:
92 typedef map<DLDbIdentifier, Keychain> KeychainMap;
93 typedef set<KeychainSchema> KeychainSchemaSet;
94
95 // Only add if not there yet. Writes out CFPref and broadcasts KCPrefListChanged notification
96 void addAndNotify(const Keychain& keychainToAdd);
97 KeychainSchema keychainSchemaFor(const CssmClient::Db &db);
98
99 //Mutex mKeychainsLock;
100 DLDbListCFPref mSavedList;
101 KeychainMap mKeychains; // the array of Keychains
102 CssmClient::MultiDLDb mMultiDLDb;
103 KeychainSchemaSet mKeychainSchemaSet;
104 };
105
106 } // end namespace KeychainCore
107
108 } // end namespace Security
109
110 #endif /* _H_STORAGEMANAGER_ */
111