2 * Copyright (c) 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.
19 // Certificate.h - Certificate objects
21 #ifndef _SECURITY_CERTIFICATE_H_
22 #define _SECURITY_CERTIFICATE_H_
24 #include <Security/Item.h>
26 // @@@ This should not be here.
27 #include <Security/SecBase.h>
28 #include <Security/clclient.h>
32 namespace KeychainCore
35 class Certificate
: public ItemImpl
39 static CL
clForType(CSSM_CERT_TYPE type
);
41 // new item constructor
42 Certificate(const CSSM_DATA
&data
, CSSM_CERT_TYPE type
, CSSM_CERT_ENCODING encoding
);
44 // db item contstructor
45 Certificate(const Keychain
&keychain
, const PrimaryKey
&primaryKey
, const CssmClient::DbUniqueRecord
&uniqueId
);
47 // PrimaryKey item contstructor
48 Certificate(const Keychain
&keychain
, const PrimaryKey
&primaryKey
);
50 Certificate(Certificate
&certificate
);
51 virtual ~Certificate();
53 virtual void update();
54 virtual Item
copyTo(const Keychain
&keychain
);
55 virtual void didModify(); // Forget any attributes and data we just wrote to the db
57 const CssmData
&data();
58 CSSM_CERT_TYPE
type();
59 CSSM_CERT_ENCODING
encoding();
60 void getSubject(CSSM_X509_NAME
&outSubject
);
61 void getIssuer(CSSM_X509_NAME
&outName
);
62 CSSM_CL_HANDLE
clHandle();
64 bool operator < (Certificate
&other
);
65 bool operator == (Certificate
&other
);
68 virtual PrimaryKey
add(Keychain
&keychain
);
69 CSSM_HANDLE
certHandle();
71 CSSM_DATA_PTR
*copyFieldValues(const CSSM_OID
&field
);
72 void releaseFieldValues(const CSSM_OID
&field
, CSSM_DATA_PTR
*fieldValues
);
74 void addParsedAttribute(const CSSM_DB_ATTRIBUTE_INFO
&info
, const CSSM_OID
&field
);
76 CSSM_DATA_PTR
copyFirstFieldValue(const CSSM_OID
&field
);
77 void releaseFieldValue(const CSSM_OID
&field
, CSSM_DATA_PTR fieldValue
);
79 void publicKeyHash(CssmData
&digestData
);
81 void populateAttributes();
84 bool mHaveTypeAndEncoding
;
86 CSSM_CERT_ENCODING mEncoding
;
88 CSSM_HANDLE mCertHandle
;
91 } // end namespace KeychainCore
93 } // end namespace Security
95 #endif // !_SECURITY_CERTIFICATE_H_