|
1 /* |
|
2 * Copyright (c) 2004 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: Trust Settings management class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //INCLUDES |
|
20 #include "WimTrustSettingsMgmt.h" |
|
21 #include "WimCertInfo.h" |
|
22 #include "WimTrace.h" |
|
23 |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // RWimTrustSettingsMgmt::RWimTrustSettingsMgmt() |
|
27 // Default constructor |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 RWimTrustSettingsMgmt::RWimTrustSettingsMgmt() : iPckgBufTrustSettings( NULL ), |
|
31 iCertPkcg( NULL ) |
|
32 { |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // RWimTrustSettingsMgmt::ClientSessionL() |
|
37 // Return new RWimTrustSettingsMgmt object |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 RWimTrustSettingsMgmt* RWimTrustSettingsMgmt::ClientSessionL() |
|
41 { |
|
42 RWimTrustSettingsMgmt* self = new( ELeave ) RWimTrustSettingsMgmt; |
|
43 CleanupStack::PushL( self ); |
|
44 User::LeaveIfError( self->Connect() ); |
|
45 CleanupStack::Pop( self ); |
|
46 _WIMTRACE ( _L( "RWimTrustSettingsMgmt::ClientSessionL()" ) ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // RWimTrustSettingsMgmt::~RWimTrustSettingsMgmt() |
|
52 // Destructor, all allocated memory is released. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 RWimTrustSettingsMgmt::~RWimTrustSettingsMgmt() |
|
56 { |
|
57 _WIMTRACE ( _L( "RWimTrustSettingsMgmt::~RWimTrustSettingsMgmt()" ) ); |
|
58 DeleteBuffers(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // RWimTrustSettingsMgmt::GetTrustSettings() |
|
63 // Return trust settings for given certificate. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void RWimTrustSettingsMgmt::GetTrustSettingsL( |
|
67 const CWimCertInfo& aCert, |
|
68 TRequestStatus& aStatus ) |
|
69 { |
|
70 _WIMTRACE ( _L( "RWimTrustSettingsMgmt::GetTrustSettings()" ) ); |
|
71 |
|
72 TTrustSettings trustSettings; |
|
73 trustSettings.iTrusted = EFalse; // Initialised to remove warning |
|
74 |
|
75 if ( iPckgBufTrustSettings || iCertPkcg ) |
|
76 { |
|
77 DeleteBuffers(); |
|
78 } |
|
79 iPckgBufTrustSettings = new( ELeave ) CWimCertPckgBuf<TTrustSettings>( |
|
80 trustSettings ); |
|
81 TWimCertInfoPckg* certInfo = aCert.ExternalizeL(); |
|
82 |
|
83 iCertPkcg = new( ELeave ) CWimCertPckgBuf<TWimCertInfoPckg>( *certInfo ); |
|
84 |
|
85 TIpcArgs args; |
|
86 args.Set( 0, iCertPkcg->PckgBuf() ); |
|
87 args.Set( 1, iPckgBufTrustSettings->PckgBuf() ); |
|
88 |
|
89 SendReceiveData( EGetTrustSettings, args, aStatus ); |
|
90 |
|
91 delete certInfo; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // RWimTrustSettingsMgmt::SetApplicabilityL() |
|
96 // Set applicability for certificate. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void RWimTrustSettingsMgmt::SetApplicabilityL( |
|
100 const CWimCertInfo& aCert, |
|
101 const RArray<TUid>& aApplications, |
|
102 TRequestStatus& aStatus ) |
|
103 { |
|
104 _WIMTRACE ( _L( "RWimTrustSettingsMgmt::SetApplicabilityL()" ) ); |
|
105 |
|
106 TInt applicationCount = aApplications.Count(); |
|
107 |
|
108 // Check that there is no more applications than allocated in array for |
|
109 if ( applicationCount > KMaxApplicationCount ) |
|
110 { |
|
111 User::Leave( KErrOverflow ); |
|
112 } |
|
113 |
|
114 TTrustSettings trustSettings; |
|
115 for ( TInt i = 0; i < applicationCount; i++ ) |
|
116 { |
|
117 trustSettings.iUids[i] = aApplications[i].iUid; |
|
118 } |
|
119 trustSettings.iApplicationCount = aApplications.Count(); |
|
120 |
|
121 if ( iPckgBufTrustSettings || iCertPkcg ) |
|
122 { |
|
123 DeleteBuffers(); |
|
124 } |
|
125 iPckgBufTrustSettings = new( ELeave ) CWimCertPckgBuf<TTrustSettings>( |
|
126 trustSettings ); |
|
127 |
|
128 TWimCertInfoPckg* certInfo = aCert.ExternalizeL(); |
|
129 |
|
130 iCertPkcg = new( ELeave ) CWimCertPckgBuf<TWimCertInfoPckg>( *certInfo ); |
|
131 |
|
132 TIpcArgs args; |
|
133 args.Set( 0, iCertPkcg->PckgBuf() ); |
|
134 args.Set( 1, iPckgBufTrustSettings->PckgBuf() ); |
|
135 |
|
136 SendReceiveData( ESetApplicability, args, aStatus ); |
|
137 |
|
138 delete certInfo; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // RWimTrustSettingsMgmt::SetTrustL() |
|
143 // Set trust flag for certificate. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void RWimTrustSettingsMgmt::SetTrustL( |
|
147 const CWimCertInfo& aCert, |
|
148 TBool aTrusted, |
|
149 TRequestStatus& aStatus ) |
|
150 { |
|
151 _WIMTRACE ( _L( "RWimTrustSettingsMgmt::SetTrustL()" ) ); |
|
152 |
|
153 TTrustSettings trustSettings; |
|
154 trustSettings.iTrusted = aTrusted; |
|
155 |
|
156 if ( iPckgBufTrustSettings || iCertPkcg ) |
|
157 { |
|
158 DeleteBuffers(); |
|
159 } |
|
160 iPckgBufTrustSettings = new( ELeave ) CWimCertPckgBuf<TTrustSettings>( |
|
161 trustSettings ); |
|
162 |
|
163 TWimCertInfoPckg* certInfo = aCert.ExternalizeL(); |
|
164 |
|
165 iCertPkcg = new( ELeave ) CWimCertPckgBuf<TWimCertInfoPckg>( *certInfo ); |
|
166 |
|
167 TIpcArgs args; |
|
168 args.Set( 0, iCertPkcg->PckgBuf() ); |
|
169 args.Set( 1, iPckgBufTrustSettings->PckgBuf() ); |
|
170 |
|
171 SendReceiveData( ESetTrust, args, aStatus ); |
|
172 |
|
173 delete certInfo; |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // RWimTrustSettingsMgmt::SetDefaultTrustSettingsL() |
|
178 // Set default trust settings for certificate. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void RWimTrustSettingsMgmt::SetDefaultTrustSettingsL( |
|
182 const CWimCertInfo& aCert, |
|
183 TBool aAddApps, |
|
184 TRequestStatus& aStatus ) |
|
185 { |
|
186 _WIMTRACE ( _L( "RWimTrustSettingsMgmt::SetDefaultTrustSettingsL()" ) ); |
|
187 |
|
188 if ( iPckgBufTrustSettings || iCertPkcg ) |
|
189 { |
|
190 DeleteBuffers(); |
|
191 } |
|
192 TWimCertInfoPckg* certInfo = aCert.ExternalizeL(); |
|
193 |
|
194 iCertPkcg = new( ELeave ) CWimCertPckgBuf<TWimCertInfoPckg>( *certInfo ); |
|
195 |
|
196 TIpcArgs args; |
|
197 args.Set( 0, iCertPkcg->PckgBuf() ); |
|
198 args.Set( 1, aAddApps ); |
|
199 |
|
200 SendReceiveData( ESetDefaultTrustSettings, args, aStatus ); |
|
201 |
|
202 delete certInfo; |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // RWimTrustSettingsMgmt::RemoveTrustSettingsL() |
|
207 // Remove trust settings of given certificate |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 void RWimTrustSettingsMgmt::RemoveTrustSettingsL( |
|
211 const CWimCertInfo& aCert, |
|
212 TRequestStatus& aStatus ) |
|
213 { |
|
214 _WIMTRACE( _L( "RWimTrustSettingsMgmt::RemoveTrustSettingsL()" ) ); |
|
215 |
|
216 if ( iPckgBufTrustSettings || iCertPkcg ) |
|
217 { |
|
218 DeleteBuffers(); |
|
219 } |
|
220 TWimCertInfoPckg* certInfo = aCert.ExternalizeL(); |
|
221 |
|
222 iCertPkcg = new( ELeave ) CWimCertPckgBuf<TWimCertInfoPckg>( *certInfo ); |
|
223 |
|
224 TIpcArgs args; |
|
225 args.Set( 0, iCertPkcg->PckgBuf() ); |
|
226 |
|
227 SendReceiveData( ERemoveTrustSettings, args, aStatus ); |
|
228 |
|
229 delete certInfo; |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // RWimTrustSettingsMgmt::CancelDoing |
|
234 // Cancel any asynchronous operation ongoing |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void RWimTrustSettingsMgmt::CancelDoing() |
|
238 { |
|
239 _WIMTRACE( _L( "RWimTrustSettingsMgmt::CancelDoing()" ) ); |
|
240 |
|
241 TIpcArgs args; |
|
242 |
|
243 SendReceiveData( ECancelTrustSettings, args ); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // RWimTrustSettingsMgmt::TrustSettingsPckg |
|
248 // Return pointer to trust settings package. |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 CWimCertPckgBuf<TTrustSettings>* RWimTrustSettingsMgmt::TrustSettingsPckg() |
|
252 { |
|
253 return iPckgBufTrustSettings; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // RWimTrustSettingsMgmt::DeleteBuffers |
|
258 // Deletes packet buffers |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void RWimTrustSettingsMgmt::DeleteBuffers() |
|
262 { |
|
263 _WIMTRACE( _L( "RWimTrustSettingsMgmt::DeleteBuffers()" ) ); |
|
264 |
|
265 delete iCertPkcg; |
|
266 delete iPckgBufTrustSettings; |
|
267 iCertPkcg = NULL; |
|
268 iPckgBufTrustSettings = NULL; |
|
269 } |
|
270 |
|
271 // End of File |