2 * Copyright (c) 2000-2001 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.
20 File: StorageManager.h
22 Contains: Working with multiple keychains
24 Copyright: 2000 by Apple Computer, Inc., all rights reserved.
29 #ifndef _H_STORAGEMANAGER_
30 #define _H_STORAGEMANAGER_
33 #include <Security/multidldb.h>
34 #include <Security/DLDBListCFPref.h>
35 #include <Security/Keychains.h>
40 namespace KeychainCore
45 NOCOPY(StorageManager
)
50 //bool onlist(const Keychain & keychain);
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.
58 void reload(bool force
= false);
60 void add(const Keychain
& keychainToAdd
); // Only add if not there yet. Doesn't write out CFPref
62 // Vector-like methods.
64 Keychain
at(unsigned int ix
);
65 Keychain
operator[](unsigned int ix
);
67 void erase(const Keychain
& keychainToRemove
);
69 KCCursor
createCursor(const SecKeychainAttributeList
*attrList
);
70 KCCursor
createCursor(SecItemClass itemClass
, const SecKeychainAttributeList
*attrList
);
72 // Create KC if it doesn't exist, add to cache, but don't modify search list.
73 Keychain
keychain(const DLDbIdentifier
&dlDbIdentifier
);
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
);
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
84 // Login keychain support
85 void login(ConstStringPtr name
, ConstStringPtr password
);
86 void login(UInt32 nameLength
, const void *name
, UInt32 passwordLength
, const void *password
);
88 void changeLoginPassword(ConstStringPtr oldPassword
, ConstStringPtr newPassword
);
89 void changeLoginPassword(UInt32 oldPasswordLength
, const void *oldPassword
, UInt32 newPasswordLength
, const void *newPassword
);
92 typedef map
<DLDbIdentifier
, Keychain
> KeychainMap
;
93 typedef set
<KeychainSchema
> KeychainSchemaSet
;
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
);
99 //Mutex mKeychainsLock;
100 DLDbListCFPref mSavedList
;
101 KeychainMap mKeychains
; // the array of Keychains
102 CssmClient::MultiDLDb mMultiDLDb
;
103 KeychainSchemaSet mKeychainSchemaSet
;
106 } // end namespace KeychainCore
108 } // end namespace Security
110 #endif /* _H_STORAGEMANAGER_ */