]> git.saurik.com Git - apple/security.git/blob - Keychain/Certificate.h
Security-54.1.tar.gz
[apple/security.git] / Keychain / Certificate.h
1 /*
2 * Copyright (c) 2002 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 // Certificate.h - Certificate objects
20 //
21 #ifndef _SECURITY_CERTIFICATE_H_
22 #define _SECURITY_CERTIFICATE_H_
23
24 #include <Security/Item.h>
25
26 // @@@ This should not be here.
27 #include <Security/SecBase.h>
28 #include <Security/clclient.h>
29 namespace Security
30 {
31
32 namespace KeychainCore
33 {
34
35 class Certificate : public ItemImpl
36 {
37 NOCOPY(Certificate)
38 public:
39 static CL clForType(CSSM_CERT_TYPE type);
40
41 // new item constructor
42 Certificate(const CSSM_DATA &data, CSSM_CERT_TYPE type, CSSM_CERT_ENCODING encoding);
43
44 // db item contstructor
45 Certificate(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmClient::DbUniqueRecord &uniqueId);
46
47 // PrimaryKey item contstructor
48 Certificate(const Keychain &keychain, const PrimaryKey &primaryKey);
49
50 Certificate(Certificate &certificate);
51 virtual ~Certificate();
52
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
56
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();
63
64 bool operator < (Certificate &other);
65 bool operator == (Certificate &other);
66
67 protected:
68 virtual PrimaryKey add(Keychain &keychain);
69 CSSM_HANDLE certHandle();
70
71 CSSM_DATA_PTR *copyFieldValues(const CSSM_OID &field);
72 void releaseFieldValues(const CSSM_OID &field, CSSM_DATA_PTR *fieldValues);
73
74 void addParsedAttribute(const CSSM_DB_ATTRIBUTE_INFO &info, const CSSM_OID &field);
75
76 CSSM_DATA_PTR copyFirstFieldValue(const CSSM_OID &field);
77 void releaseFieldValue(const CSSM_OID &field, CSSM_DATA_PTR fieldValue);
78
79 void publicKeyHash(CssmData &digestData);
80 void addLabel();
81 void populateAttributes();
82
83 private:
84 bool mHaveTypeAndEncoding;
85 CSSM_CERT_TYPE mType;
86 CSSM_CERT_ENCODING mEncoding;
87 CssmClient::CL mCL;
88 CSSM_HANDLE mCertHandle;
89 };
90
91 } // end namespace KeychainCore
92
93 } // end namespace Security
94
95 #endif // !_SECURITY_CERTIFICATE_H_