]>
git.saurik.com Git - apple/security.git/blob - Keychain/Item.h
8c0e9c24d0190fb5e058e75060949a06c44c2c99
2 * Copyright (c) 2000-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.
22 #ifndef _SECURITY_ITEM_H_
23 #define _SECURITY_ITEM_H_
25 #include <Security/Keychains.h>
26 #include <Security/PrimaryKey.h>
27 #include <Security/securestorage.h>
28 #include <Security/Access.h>
33 using namespace CssmClient
;
35 namespace KeychainCore
39 class ItemImpl
: public SecCFObject
43 friend class KeychainImpl
;
45 // new item constructors
46 ItemImpl(SecItemClass itemClass
, OSType itemCreator
, UInt32 length
, const void* data
);
48 ItemImpl(SecItemClass itemClass
, SecKeychainAttributeList
*attrList
, UInt32 length
, const void* data
);
50 // db item contstructor
51 ItemImpl(const Keychain
&keychain
, const PrimaryKey
&primaryKey
, const CssmClient::DbUniqueRecord
&uniqueId
);
53 // PrimaryKey item contstructor
54 ItemImpl(const Keychain
&keychain
, const PrimaryKey
&primaryKey
);
56 ItemImpl(ItemImpl
&item
);
58 void getAttributeFrom(CssmDbAttributeData
*data
, SecKeychainAttribute
&attr
, UInt32
*actualLength
);
59 void getClass(SecKeychainAttribute
&attr
, UInt32
*actualLength
);
62 // Methods called by KeychainImpl;
64 // Add the receiver to keychain
65 virtual PrimaryKey
add(Keychain
&keychain
);
67 // Get the default value for an attribute
68 static const CSSM_DATA
&defaultAttributeValue(const CSSM_DB_ATTRIBUTE_INFO
&info
);
72 bool isPersistant() const;
73 bool isModified() const;
75 virtual void update();
77 // put a copy of the item into a given keychain
78 virtual Item
copyTo(const Keychain
&keychain
, Access
*newAccess
= NULL
);
80 CSSM_DB_RECORDTYPE
recordType() const;
82 // Used for writing the record to the database.
83 CssmClient::DbUniqueRecord
dbUniqueRecord();
84 const CssmClient::DbAttributes
*modifiedAttributes() const;
85 const CssmData
*modifiedData() const;
86 virtual void didModify(); // Forget any attributes and data we just wrote to the db
88 Keychain
keychain() const;
89 PrimaryKey
primaryKey() const;
90 bool operator <(const ItemImpl
&other
) const;
92 void getAttribute(SecKeychainAttribute
& attr
, UInt32
*actualLength
);
93 void getData(CssmDataContainer
& outData
);
95 void modifyContent(const SecKeychainAttributeList
*attrList
, UInt32 dataLength
, const void *inData
);
96 void getContent(SecItemClass
*itemClass
, SecKeychainAttributeList
*attrList
, UInt32
*length
, void **outData
);
97 static void freeContent(SecKeychainAttributeList
*attrList
, void *data
);
98 static void freeAttributesAndData(SecKeychainAttributeList
*attrList
, void *data
);
100 void getAttributesAndData(SecKeychainAttributeInfo
*info
, SecItemClass
*itemClass
, SecKeychainAttributeList
**attrList
, UInt32
*length
, void **outData
);
101 void modifyAttributesAndData(const SecKeychainAttributeList
*attrList
, UInt32 dataLength
, const void *inData
);
103 void setAttribute(SecKeychainAttribute
& attr
);
104 void setAttribute(const CssmDbAttributeInfo
&info
, const CssmPolyData
&data
);
105 void setData(UInt32 length
,const void *data
);
106 void setAccess(Access
*newAccess
);
111 void getContent(DbAttributes
*dbAttributes
, CssmDataContainer
*itemData
);
112 void getLocalContent(SecKeychainAttributeList
&attributeList
);
114 bool useSecureStorage(const CssmClient::Db
&db
);
117 auto_ptr
<CssmDataContainer
> mData
;
118 auto_ptr
<CssmClient::DbAttributes
> mDbAttributes
;
119 RefPointer
<Access
> mAccess
;
122 CssmClient::DbUniqueRecord mUniqueId
;
124 PrimaryKey mPrimaryKey
;
128 class Item
: public RefPointer
<ItemImpl
>
132 Item(ItemImpl
*impl
);
133 Item(SecItemClass itemClass
, OSType itemCreator
, UInt32 length
, const void* data
);
134 Item(SecItemClass itemClass
, SecKeychainAttributeList
*attrList
, UInt32 length
, const void* data
);
135 Item(const Keychain
&keychain
, const PrimaryKey
&primaryKey
, const CssmClient::DbUniqueRecord
&uniqueId
);
136 Item(const Keychain
&keychain
, const PrimaryKey
&primaryKey
);
137 Item(ItemImpl
&item
);
141 } // end namespace KeychainCore
143 } // end namespace Security
145 #endif // !_SECURITY_ITEM_H_