|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Provides functionality for adding certificate ino cert store |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NATIVECERTIFICATEMANAGER_H |
|
20 #define NATIVECERTIFICATEMANAGER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "functionserver.h" |
|
24 #include "fs_methodcall.h" |
|
25 #include <e32base.h> |
|
26 #include <f32file.h> |
|
27 #include <ct/rmpointerarray.h> |
|
28 #include <cctcertinfo.h> |
|
29 #include <ct/tcttokenobjecthandle.h> |
|
30 #include <openssl/x509.h> |
|
31 #include "s60commonutils.h" |
|
32 #include <string> |
|
33 |
|
34 using namespace java::util; |
|
35 // CONSTANTS |
|
36 |
|
37 // Key usage constants |
|
38 const TInt KSTSKeyUsageAuthentication = 0; |
|
39 const TInt KSTSKeyUsageNonRepudiation = 1; |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CUnifiedCertStore; |
|
43 class CUnifiedKeyStore; |
|
44 class CCTKeyInfo; |
|
45 class CX500DistinguishedName; |
|
46 class CX520AttributeTypeAndValue; |
|
47 class CPKCS10Request; |
|
48 class MPKIDialog; |
|
49 class CCMSIssuerAndSerialNumber; |
|
50 using namespace java::util; |
|
51 |
|
52 // CLASS DECLARATION |
|
53 |
|
54 /** |
|
55 * Provides functionality for adding certificate into CUnified cert store |
|
56 */ |
|
57 |
|
58 NONSHARABLE_CLASS(NativeCertificateManager): public CActive, public FunctionServer |
|
59 { |
|
60 private: // type definitions |
|
61 enum TCertState |
|
62 { |
|
63 EValidating |
|
64 }; |
|
65 |
|
66 public: // Constructors and destructor |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 static NativeCertificateManager* NewL(X509* aCert); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~NativeCertificateManager(); |
|
77 |
|
78 public: // New functions |
|
79 |
|
80 int AddCertificate(); |
|
81 |
|
82 int doValidationL(); |
|
83 |
|
84 int validation(); |
|
85 |
|
86 void doClose(); |
|
87 |
|
88 static int validateX509Certificate(X509 *aCert); |
|
89 |
|
90 int doValidateX509Certificate(); |
|
91 |
|
92 void MyAdd(); |
|
93 |
|
94 void doAdd(); |
|
95 |
|
96 public: // CActive |
|
97 |
|
98 /** |
|
99 * Handles an active object's request completion event. |
|
100 */ |
|
101 void RunL(); |
|
102 |
|
103 /** |
|
104 * Handles a leave occurring in the request completion event handler RunL(). |
|
105 */ |
|
106 TInt RunError(TInt aError); |
|
107 |
|
108 /** |
|
109 * Implements cancellation of an outstanding request. |
|
110 */ |
|
111 void DoCancel(); |
|
112 |
|
113 private: |
|
114 |
|
115 // From FunctionServer |
|
116 virtual void vmAttached(); |
|
117 virtual void doServerSideInit(); |
|
118 void AddToScheduler(); |
|
119 |
|
120 /** |
|
121 * C++ default constructor. |
|
122 */ |
|
123 NativeCertificateManager(); |
|
124 |
|
125 /** |
|
126 * By default Symbian 2nd phase constructor is private. |
|
127 */ |
|
128 void ConstructL(X509* aCert); |
|
129 |
|
130 /** |
|
131 * Completes current asynchronic operation. |
|
132 * If aError is not KErrNone, sets iError before calling |
|
133 * iWait->AsyncStop(). |
|
134 * @param aError return value from the completed operation. |
|
135 */ |
|
136 void Complete(TInt aError); |
|
137 |
|
138 /** |
|
139 * Waits for the current asynchronic operation to complete. |
|
140 * Leaves with the error code if the asynchronic operation fails. |
|
141 */ |
|
142 void WaitForCompletion(); |
|
143 |
|
144 /** |
|
145 * Retrieves the certificate to be removed, in order to check |
|
146 * the Issuer and SerialNumber of the certificate |
|
147 */ |
|
148 |
|
149 /** |
|
150 * Adds a certificate |
|
151 */ |
|
152 void AddL(); |
|
153 |
|
154 private: // Data |
|
155 |
|
156 // internal state |
|
157 TCertState iState; |
|
158 |
|
159 // internal error variable |
|
160 TInt iError; |
|
161 |
|
162 // Waits for the operation to complete. Owned. |
|
163 CActiveSchedulerWait* iWait; |
|
164 |
|
165 // Used by CUnifiedCertStore |
|
166 RFs iFileServer; |
|
167 |
|
168 int iCertVerErrCode; |
|
169 |
|
170 X509* iCert; |
|
171 |
|
172 TInt lab; |
|
173 }; |
|
174 |
|
175 #endif // NATIVECERTIFICATEMANAGER_H |