1 /* |
|
2 * ============================================================================ |
|
3 * Name : ./accesssec/eapol/eapol_framework/wapi_symbian/wapi_core/symbian/WapiCertificates.cpp |
|
4 * Part of : WAPI / WAPI *** Info from the SWAD |
|
5 * Description : WAPI authentication |
|
6 * Version : %version: 25.1.3 % << Don't touch! Updated by Synergy at check-out. |
|
7 * |
|
8 * Copyright © 2001-2009 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ============================================================================ |
|
17 * Template version: 4.1.1 |
|
18 */ |
|
19 #include "WapiCertificates.h" |
|
20 #include "certificate_store_db_symbian.h" |
|
21 #include "abs_eap_am_tools.h" |
|
22 #include "eap_am_tools_symbian.h" |
|
23 #include "dummy_wapi_core.h" |
|
24 #include "wapi_am_core_symbian.h" |
|
25 #include "ec_certificate_store.h" |
|
26 #include <e32std.h> |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CWapiCertificates::CWapiCertificates() |
|
30 // The constructor does not do anything |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CWapiCertificates::CWapiCertificates(): CActive(CActive::EPriorityStandard) |
|
34 { |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CWapiCertificates::~CWapiCertificates() |
|
39 // The destructor |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C CWapiCertificates::~CWapiCertificates() |
|
43 { |
|
44 if ( iEcCertStore != NULL ) |
|
45 { |
|
46 iEcCertStore->shutdown(); |
|
47 delete iEcCertStore; |
|
48 } |
|
49 if ( iWapiCore != NULL ) |
|
50 { |
|
51 iWapiCore->shutdown(); |
|
52 delete iWapiCore; |
|
53 } |
|
54 delete iCertDB; |
|
55 |
|
56 delete iDummyCore; |
|
57 |
|
58 if ( iAmTools != NULL ) |
|
59 { |
|
60 iAmTools->am_cancel_all_timers(); |
|
61 abs_eap_am_tools_c::delete_abs_eap_am_tools_c(iAmTools); |
|
62 } |
|
63 |
|
64 if(IsActive()) |
|
65 { |
|
66 Cancel(); |
|
67 } |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CWapiCertificates::ConstructL |
|
72 // Symbian 2nd phase constructor can leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CWapiCertificates::ConstructL() |
|
76 { |
|
77 // Create the needed certificate store object |
|
78 iAmTools = abs_eap_am_tools_c::new_abs_eap_am_tools_c(); |
|
79 if ( iAmTools == NULL || iAmTools->get_is_valid() != true ) |
|
80 { |
|
81 User::Leave(KErrGeneral); |
|
82 } |
|
83 |
|
84 EAP_TRACE_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
85 "CWapiCertificates::ConstructL\n" ) ) ); |
|
86 |
|
87 iCertDB = CCertificateStoreDatabase::NewL( iAmTools ); |
|
88 // Open the certificate store connection |
|
89 iCertDB->OpenCertificateStoreL(); |
|
90 |
|
91 // create the dummy core and ec cert store in order to create the |
|
92 // wapi_am_core_symbian object |
|
93 iDummyCore = new(ELeave) dummy_wapi_core_c(); |
|
94 // check if dummyCore is ok |
|
95 if ( iDummyCore->get_is_valid() == false ) |
|
96 { |
|
97 User::Leave( KErrGeneral ); |
|
98 } |
|
99 |
|
100 iWapiCore = wapi_am_core_symbian_c::NewL( iAmTools, iDummyCore, iCertDB, false); |
|
101 |
|
102 iCertDB->SetCorePartner(iWapiCore); |
|
103 |
|
104 iEcCertStore = new(ELeave) ec_certificate_store_c(iAmTools, iDummyCore, iWapiCore , true); |
|
105 |
|
106 eap_status_e status = iEcCertStore->configure(); |
|
107 if(status != eap_status_ok) |
|
108 { |
|
109 User::Leave( KErrGeneral ); |
|
110 } |
|
111 |
|
112 iWapiCore->set_am_certificate_store_partner(iEcCertStore); |
|
113 |
|
114 CActiveScheduler::Add(this); // add this object to the active scheduler |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CWapiCertificates::NewL |
|
119 // Two-phased constructor. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C CWapiCertificates* CWapiCertificates::NewL() |
|
123 { |
|
124 CWapiCertificates* self = new(ELeave) CWapiCertificates(); |
|
125 CleanupStack::PushL(self); |
|
126 self->ConstructL(); |
|
127 CleanupStack::Pop(self); |
|
128 return self; |
|
129 } |
|
130 |
|
131 |
|
132 |
|
133 //------------------------------------------------------------------------------ |
|
134 // CWapiCertificates::GetAllCertificateLabelsL( ) |
|
135 //------------------------------------------------------------------------------ |
|
136 EXPORT_C void CWapiCertificates::GetAllCertificateLabelsL( RArray<TBuf<KMaxLabelLength> > **aUserCerts, RArray<TBuf8<KMaxIdentityLength> >**aUserCertData, |
|
137 RArray<TBuf<KMaxLabelLength> > **aCACerts, RArray<TBuf8<KMaxIdentityLength> >**aCACertData ) |
|
138 { |
|
139 // Use the provided service for reading the list. |
|
140 |
|
141 iWapiCore->GetAllCertificateLabelsL( aUserCerts, aCACerts, aUserCertData, aCACertData, iStatus ); |
|
142 // Let's wait until certificate db get's the job done and return after that |
|
143 SetActive(); |
|
144 iWait.Start(); |
|
145 EAP_TRACE_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
146 "CWapiCertificates::GetAllCertificateLabelsL, status = %d.\n" ), |
|
147 iStatus.Int() ) ); |
|
148 |
|
149 if (*aCACerts) |
|
150 { |
|
151 EAP_TRACE_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
152 "CWapiCertificates::GetAllCertificateLabelsL, CA Count = %d.\n" ), |
|
153 (*aCACerts)->Count() ) ); |
|
154 } |
|
155 if (*aUserCerts) |
|
156 { |
|
157 EAP_TRACE_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
158 "CWapiCertificates::GetAllCertificateLabelsL, Client count = %d.\n" ), |
|
159 (*aUserCerts)->Count() ) ); |
|
160 } |
|
161 |
|
162 if (*aCACerts) |
|
163 { |
|
164 for (TInt aCa = 0; aCa <(*aCACerts)->Count(); aCa++) |
|
165 { |
|
166 TPtrC certPtr; |
|
167 certPtr.Set ((**aCACerts)[aCa]); |
|
168 EAP_TRACE_DATA_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
169 "CaCert:"), certPtr.Ptr(), |
|
170 certPtr.Size() )); |
|
171 } |
|
172 } |
|
173 |
|
174 if (*aUserCerts) |
|
175 { |
|
176 for (TInt aCa = 0; aCa <(*aUserCerts)->Count(); aCa++) |
|
177 { |
|
178 TPtrC certPtr; |
|
179 certPtr.Set ((**aUserCerts)[aCa]); |
|
180 EAP_TRACE_DATA_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
181 "ClientCert:"), certPtr.Ptr(), |
|
182 certPtr.Size() )); |
|
183 } |
|
184 } |
|
185 // Check the status |
|
186 User::LeaveIfError( iStatus.Int() ); |
|
187 return; |
|
188 } |
|
189 |
|
190 //------------------------------------------------------------------------------ |
|
191 // CWapiCertificates::ResetCertificateStore( ) |
|
192 //------------------------------------------------------------------------------ |
|
193 EXPORT_C void CWapiCertificates::ResetCertificateStoreL( ) |
|
194 { |
|
195 // Use the provided service for destroying the certificate store |
|
196 TInt error = iCertDB->DestroyCertificateStore( ); |
|
197 // Leave if error returned |
|
198 User::LeaveIfError( error ); |
|
199 } |
|
200 |
|
201 //------------------------------------------------------------------------------ |
|
202 // CWapiCertificates::GetConfiguration(TInt aId, TDes& aCACert, TDes& aUserCert) |
|
203 //------------------------------------------------------------------------------ |
|
204 EXPORT_C void CWapiCertificates::GetConfigurationL( const TInt aId, TDes& aCACert, TDes& aUserCert ) |
|
205 { |
|
206 // Use the provided service for getting the selected CA and user certificates |
|
207 iCertDB->GetConfigurationL( aId, aCACert, aUserCert ); |
|
208 } |
|
209 |
|
210 //------------------------------------------------------------------------------ |
|
211 // CWapiCertificates::SetCACert( TInt aId, const TBuf8<KMaxIdentityLength> aSelectedCert ) |
|
212 //------------------------------------------------------------------------------ |
|
213 EXPORT_C void CWapiCertificates::SetCACertL( const TInt aId, const TBuf8<KMaxIdentityLength> aSelectedCert ) |
|
214 { |
|
215 // Use the provided service for setting the selected CA certificate |
|
216 iCertDB->SetCACertL( aId, aSelectedCert ); |
|
217 } |
|
218 |
|
219 //------------------------------------------------------------------------------ |
|
220 // CWapiCertificates::SetUserCert( TInt aId, const TBuf8<KMaxIdentityLength> aSelectedCert ) |
|
221 //------------------------------------------------------------------------------ |
|
222 EXPORT_C void CWapiCertificates::SetUserCertL( const TInt aId, const TBuf8<KMaxIdentityLength> aSelectedCert) |
|
223 { |
|
224 // Use the provided service for setting the selected user certificate |
|
225 iCertDB->SetUserCertL( aId, aSelectedCert ); |
|
226 } |
|
227 |
|
228 //------------------------------------------------------------------------------ |
|
229 // CWapiCertificates::DeleteAPSpecificDataL( TInt aId ) |
|
230 //------------------------------------------------------------------------------ |
|
231 EXPORT_C void CWapiCertificates::DeleteAPSpecificDataL( const TInt aId ) |
|
232 { |
|
233 // Use the provided service for deleting the rows mathing the id |
|
234 iCertDB->DeleteAPSpecificDataL( aId ); |
|
235 } |
|
236 |
|
237 // ================= protected: from CActive ======================= |
|
238 |
|
239 // --------------------------------------------------------- |
|
240 // CWapiCertificates::RunL() |
|
241 // --------------------------------------------------------- |
|
242 // |
|
243 void CWapiCertificates::RunL() |
|
244 { |
|
245 EAP_TRACE_DEBUG( iAmTools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
246 "CWapiCertificates::RunL() IN, iStatus=%d.\n"), iStatus.Int() ) ); |
|
247 |
|
248 // This is needed to continue the execution after Wait.Start(); |
|
249 iWait.AsyncStop(); |
|
250 return; |
|
251 } // CWapiCertificates::RunL() |
|
252 |
|
253 |
|
254 // --------------------------------------------------------- |
|
255 // CWapiCertificates::RunL() |
|
256 // --------------------------------------------------------- |
|
257 // |
|
258 void CWapiCertificates::DoCancel() |
|
259 { |
|
260 if( iStatus == KRequestPending ) |
|
261 { |
|
262 TRequestStatus * reqStat = &iStatus; |
|
263 User::RequestComplete(reqStat, KErrCancel); |
|
264 } |
|
265 } |
|
266 |
|
267 // End of file |
|