sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "CRefSecurityDialog.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
// ----------------------------------------------------------------------------
|
sl@0
|
22 |
// SecurityDialogFactory
|
sl@0
|
23 |
//
|
sl@0
|
24 |
|
sl@0
|
25 |
EXPORT_C MSecurityDialog* SecurityDialogFactory::CreateL()
|
sl@0
|
26 |
{
|
sl@0
|
27 |
return CRefSecurityDialog::NewL();
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
// ----------------------------------------------------------------------------
|
sl@0
|
33 |
// CRefSecurityDialog
|
sl@0
|
34 |
//
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
CRefSecurityDialog::~CRefSecurityDialog()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
delete iRequester;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
void CRefSecurityDialog::Release()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
delete this;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
|
sl@0
|
49 |
CRefSecurityDialog* CRefSecurityDialog::NewL()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
CRefSecurityDialog* self = new (ELeave) CRefSecurityDialog();
|
sl@0
|
52 |
CleanupStack::PushL( self );
|
sl@0
|
53 |
self->ConstructL();
|
sl@0
|
54 |
CleanupStack::Pop( self );
|
sl@0
|
55 |
return self;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
|
sl@0
|
59 |
|
sl@0
|
60 |
void CRefSecurityDialog::ConstructL()
|
sl@0
|
61 |
{
|
sl@0
|
62 |
iRequester = CDialogRequester::NewL( *this );
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
void CRefSecurityDialog::EnterPIN( const TPINParams& aPINParams, TBool aRetry,
|
sl@0
|
68 |
TPINValue& aPINValue, TRequestStatus& aStatus )
|
sl@0
|
69 |
{
|
sl@0
|
70 |
iClientPINValuePtr = &aPINValue;
|
sl@0
|
71 |
DoBasicPINOperation( EEnterPIN, aPINParams, aRetry, iPINValueBuf, aStatus );
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
void CRefSecurityDialog::EnablePIN( const TPINParams& aPINParams, TBool aRetry,
|
sl@0
|
77 |
TPINValue& aPINValue, TRequestStatus& aStatus )
|
sl@0
|
78 |
{
|
sl@0
|
79 |
iClientPINValuePtr = &aPINValue;
|
sl@0
|
80 |
DoBasicPINOperation( EEnablePIN, aPINParams, aRetry, iPINValueBuf, aStatus );
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
|
sl@0
|
84 |
|
sl@0
|
85 |
void CRefSecurityDialog::DisablePIN( const TPINParams& aPINParams, TBool aRetry,
|
sl@0
|
86 |
TPINValue& aPINValue, TRequestStatus& aStatus )
|
sl@0
|
87 |
{
|
sl@0
|
88 |
iClientPINValuePtr = &aPINValue;
|
sl@0
|
89 |
DoBasicPINOperation( EDisablePIN, aPINParams, aRetry, iPINValueBuf, aStatus );
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
|
sl@0
|
94 |
void CRefSecurityDialog::ChangePIN( const TPINParams& aPINParams, TBool aRetry,
|
sl@0
|
95 |
TPINValue& aOldPINValue, TPINValue& aNewPINValue,
|
sl@0
|
96 |
TRequestStatus& aStatus )
|
sl@0
|
97 |
{
|
sl@0
|
98 |
iClientPINValuePtr = &aOldPINValue;
|
sl@0
|
99 |
iClientSecondPINValuePtr = &aNewPINValue;
|
sl@0
|
100 |
DoBasicPINOperation( EChangePIN, aPINParams, aRetry, iTwoPINOutputBuf, aStatus );
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
|
sl@0
|
104 |
|
sl@0
|
105 |
void CRefSecurityDialog::UnblockPIN( const TPINParams& aBlockedPINParams,
|
sl@0
|
106 |
const TPINParams& aUnblockingPINParams, TBool aRetry,
|
sl@0
|
107 |
TPINValue& aUnblockingPINValue, TPINValue& aNewPINValue,
|
sl@0
|
108 |
TRequestStatus& aStatus )
|
sl@0
|
109 |
{
|
sl@0
|
110 |
iCurrentOperation = EUnblockPIN;
|
sl@0
|
111 |
InitClientStatus( aStatus );
|
sl@0
|
112 |
|
sl@0
|
113 |
TUnblockPINInput unblockPINInput;
|
sl@0
|
114 |
unblockPINInput.iOperation = EUnblockPIN;
|
sl@0
|
115 |
if ( aRetry )
|
sl@0
|
116 |
{
|
sl@0
|
117 |
unblockPINInput.iOperation |= EPINValueIncorrect;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
unblockPINInput.iPIN = aBlockedPINParams;
|
sl@0
|
120 |
unblockPINInput.iUnblockPIN = aUnblockingPINParams;
|
sl@0
|
121 |
TUnblockPINInputBuf unblockPINInputBuf( unblockPINInput );
|
sl@0
|
122 |
iUnblockPINInputBuf.Copy( unblockPINInputBuf );
|
sl@0
|
123 |
iClientPINValuePtr = &aUnblockingPINValue;
|
sl@0
|
124 |
iClientSecondPINValuePtr = &aNewPINValue;
|
sl@0
|
125 |
|
sl@0
|
126 |
iRequester->RequestDialog( iUnblockPINInputBuf, iTwoPINOutputBuf );
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
void CRefSecurityDialog::UnblockPINInClear( const TPINParams& aBlockedPINParams,
|
sl@0
|
130 |
const TPINParams& aUnblockingPINParams, TBool aRetry,
|
sl@0
|
131 |
TUnblockPINValue& aUnblockingPINValue, TPINValue& aNewPINValue,
|
sl@0
|
132 |
TRequestStatus& aStatus )
|
sl@0
|
133 |
{
|
sl@0
|
134 |
iCurrentOperation = EUnblockPINInClear;
|
sl@0
|
135 |
InitClientStatus( aStatus );
|
sl@0
|
136 |
|
sl@0
|
137 |
TUnblockPINInput unblockPINInput;
|
sl@0
|
138 |
unblockPINInput.iOperation = EUnblockPINInClear;
|
sl@0
|
139 |
if ( aRetry )
|
sl@0
|
140 |
{
|
sl@0
|
141 |
unblockPINInput.iOperation |= EPINValueIncorrect;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
unblockPINInput.iPIN = aBlockedPINParams;
|
sl@0
|
144 |
unblockPINInput.iUnblockPIN = aUnblockingPINParams;
|
sl@0
|
145 |
TUnblockPINInputBuf unblockPINInputBuf( unblockPINInput );
|
sl@0
|
146 |
|
sl@0
|
147 |
iClientUnblockPINValuePtr = &aUnblockingPINValue;
|
sl@0
|
148 |
iClientSecondPINValuePtr = &aNewPINValue;
|
sl@0
|
149 |
iUnblockPINInputBuf.Copy( unblockPINInputBuf );
|
sl@0
|
150 |
iRequester->RequestDialog( iUnblockPINInputBuf, iUnblockPINInClearOutputBuf );
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
void CRefSecurityDialog::Cancel()
|
sl@0
|
154 |
{
|
sl@0
|
155 |
iRequester->Cancel();
|
sl@0
|
156 |
if (iClientStatus)
|
sl@0
|
157 |
{
|
sl@0
|
158 |
User::RequestComplete(iClientStatus, KErrCancel);
|
sl@0
|
159 |
}
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
void CRefSecurityDialog::PINBlocked( const TPINParams& aPINParams,
|
sl@0
|
163 |
TRequestStatus& aStatus )
|
sl@0
|
164 |
{
|
sl@0
|
165 |
iCurrentOperation = EPINBlocked;
|
sl@0
|
166 |
TPckg<TPINValue> pinValueBuf( KNullDesC() );
|
sl@0
|
167 |
DoBasicPINOperation( EPINBlocked, aPINParams, EFalse, pinValueBuf, aStatus );
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
|
sl@0
|
171 |
void CRefSecurityDialog::TotalBlocked( const TPINParams& aPINParams,
|
sl@0
|
172 |
TRequestStatus& aStatus )
|
sl@0
|
173 |
{
|
sl@0
|
174 |
iCurrentOperation = ETotalBlocked;
|
sl@0
|
175 |
TPckg<TPINValue> pinValueBuf( KNullDesC() );
|
sl@0
|
176 |
DoBasicPINOperation( ETotalBlocked, aPINParams, EFalse, pinValueBuf, aStatus );
|
sl@0
|
177 |
}
|
sl@0
|
178 |
|
sl@0
|
179 |
|
sl@0
|
180 |
|
sl@0
|
181 |
void CRefSecurityDialog::EstablishSecureConnection( const TDesC8& aCertData,
|
sl@0
|
182 |
const RArray<TCTTokenObjectHandle>& aCertHandleList,
|
sl@0
|
183 |
MSecurityDialog::TConnectionType aConnectionType,
|
sl@0
|
184 |
TBool& aDoClientAuthentication, TCTTokenObjectHandle& aCertHandle,
|
sl@0
|
185 |
TRequestStatus& aStatus )
|
sl@0
|
186 |
{
|
sl@0
|
187 |
iCurrentOperation = ESecureConnection;
|
sl@0
|
188 |
InitClientStatus( aStatus );
|
sl@0
|
189 |
|
sl@0
|
190 |
TInt certDataSize = aCertData.Size();
|
sl@0
|
191 |
TSignInput signInput;
|
sl@0
|
192 |
signInput.iOperation = ESecureConnection;
|
sl@0
|
193 |
signInput.iVariableDataSize = certDataSize;
|
sl@0
|
194 |
signInput.iCertHandleArrayTotal = aCertHandleList.Count();
|
sl@0
|
195 |
signInput.iDoClientAuthentication = aDoClientAuthentication;
|
sl@0
|
196 |
signInput.iConnectionType = aConnectionType;
|
sl@0
|
197 |
TPckgC<TSignInput> signInputBufPtr( signInput );
|
sl@0
|
198 |
// iSignInputBuf is persistent because further input processing occurs in the AO before
|
sl@0
|
199 |
// calling the notifier.
|
sl@0
|
200 |
iSignInputBuf.Copy( signInputBufPtr );
|
sl@0
|
201 |
iVariableDataPtr.Set( aCertData );
|
sl@0
|
202 |
|
sl@0
|
203 |
iClientDoClientAuthenticationPtr = &aDoClientAuthentication;
|
sl@0
|
204 |
iClientCertInfoHandlePtr = &aCertHandle;
|
sl@0
|
205 |
|
sl@0
|
206 |
iRequester->RequestVariableBufferDialog( iSignInputBuf, iVariableDataPtr,
|
sl@0
|
207 |
aCertHandleList, iCertInfoHandleBuf );
|
sl@0
|
208 |
}
|
sl@0
|
209 |
|
sl@0
|
210 |
|
sl@0
|
211 |
|
sl@0
|
212 |
void CRefSecurityDialog::SignText( const TDesC& aTextToSign,
|
sl@0
|
213 |
const RArray<TCTTokenObjectHandle>& aCertHandleList,
|
sl@0
|
214 |
TCTTokenObjectHandle& aCertHandle,
|
sl@0
|
215 |
TRequestStatus& aStatus )
|
sl@0
|
216 |
{
|
sl@0
|
217 |
iCurrentOperation = ESignText;
|
sl@0
|
218 |
InitClientStatus( aStatus );
|
sl@0
|
219 |
|
sl@0
|
220 |
TInt textSize = aTextToSign.Size();
|
sl@0
|
221 |
TSignInput signInput;
|
sl@0
|
222 |
signInput.iOperation = ESignText;
|
sl@0
|
223 |
signInput.iVariableDataSize = textSize;
|
sl@0
|
224 |
signInput.iCertHandleArrayTotal = aCertHandleList.Count();
|
sl@0
|
225 |
TPckgC<TSignInput> signInputBufPtr( signInput );
|
sl@0
|
226 |
// iSignInputBuf is persistent because further input processing occurs in the AO before
|
sl@0
|
227 |
// calling the notifier.
|
sl@0
|
228 |
iSignInputBuf.Copy( signInputBufPtr );
|
sl@0
|
229 |
const TUint8* textToSignPtr = reinterpret_cast<const TUint8*>( aTextToSign.Ptr() );
|
sl@0
|
230 |
iVariableDataPtr.Set( textToSignPtr, textSize );
|
sl@0
|
231 |
|
sl@0
|
232 |
iClientCertInfoHandlePtr = &aCertHandle;
|
sl@0
|
233 |
|
sl@0
|
234 |
iRequester->RequestVariableBufferDialog( iSignInputBuf, iVariableDataPtr,
|
sl@0
|
235 |
aCertHandleList, iCertInfoHandleBuf );
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
void CRefSecurityDialog::ServerAuthenticationFailure(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert,TRequestStatus& aStatus )
|
sl@0
|
239 |
{
|
sl@0
|
240 |
iCurrentOperation = EServerAuthenticationFailure;
|
sl@0
|
241 |
InitClientStatus( aStatus );
|
sl@0
|
242 |
|
sl@0
|
243 |
CServerAuthenticationFailureInput* serverAuthenticationFailureInput = NULL;
|
sl@0
|
244 |
TRAPD(err, serverAuthenticationFailureInput = CServerAuthenticationFailureInput::NewL(aServerName, aFailureReason, aEncodedCert));
|
sl@0
|
245 |
|
sl@0
|
246 |
// Ownership of the inputBuffer will pass to the requester.
|
sl@0
|
247 |
HBufC8* inputBuffer = NULL;
|
sl@0
|
248 |
if (err == KErrNone)
|
sl@0
|
249 |
TRAP(err, inputBuffer = serverAuthenticationFailureInput->PackBufferL());
|
sl@0
|
250 |
|
sl@0
|
251 |
delete serverAuthenticationFailureInput;
|
sl@0
|
252 |
|
sl@0
|
253 |
if (err == KErrNone)
|
sl@0
|
254 |
iRequester->RequestDialog(inputBuffer, iServerAuthenticationOutputBuf);
|
sl@0
|
255 |
else
|
sl@0
|
256 |
HandleResponse(err);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
void CRefSecurityDialog::DoBasicPINOperation( TSecurityDialogOperation aOperation,
|
sl@0
|
260 |
const TPINParams& aPINParams, TBool aRetry, TDes8& aPINValue,
|
sl@0
|
261 |
TRequestStatus& aStatus )
|
sl@0
|
262 |
{
|
sl@0
|
263 |
iCurrentOperation = aOperation;
|
sl@0
|
264 |
InitClientStatus( aStatus );
|
sl@0
|
265 |
TPINInput pinInput;
|
sl@0
|
266 |
pinInput.iOperation = aOperation;
|
sl@0
|
267 |
if ( aRetry )
|
sl@0
|
268 |
{
|
sl@0
|
269 |
pinInput.iOperation |= EPINValueIncorrect;
|
sl@0
|
270 |
}
|
sl@0
|
271 |
pinInput.iPIN = aPINParams;
|
sl@0
|
272 |
TPINInputBuf pinInputBuf( pinInput );
|
sl@0
|
273 |
iPINInputBuf.Copy( pinInputBuf );
|
sl@0
|
274 |
iRequester->RequestDialog( iPINInputBuf, aPINValue );
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
|
sl@0
|
278 |
|
sl@0
|
279 |
void CRefSecurityDialog::InitClientStatus( TRequestStatus& aStatus )
|
sl@0
|
280 |
{
|
sl@0
|
281 |
iClientStatus = &aStatus;
|
sl@0
|
282 |
*iClientStatus = KRequestPending;
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
|
sl@0
|
286 |
|
sl@0
|
287 |
void CRefSecurityDialog::HandleResponse( TInt aResult )
|
sl@0
|
288 |
{
|
sl@0
|
289 |
if ( aResult >= KErrNone )
|
sl@0
|
290 |
{
|
sl@0
|
291 |
switch ( iCurrentOperation )
|
sl@0
|
292 |
{
|
sl@0
|
293 |
case EServerAuthenticationFailure:
|
sl@0
|
294 |
{
|
sl@0
|
295 |
TServerAuthenticationFailureDialogResult serverAuthenticationOutput = iServerAuthenticationOutputBuf();
|
sl@0
|
296 |
|
sl@0
|
297 |
if(serverAuthenticationOutput == EContinue)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
aResult = KErrNone;
|
sl@0
|
300 |
}
|
sl@0
|
301 |
else if(serverAuthenticationOutput == EStop)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
aResult = KErrAbort;
|
sl@0
|
304 |
}
|
sl@0
|
305 |
}
|
sl@0
|
306 |
break;
|
sl@0
|
307 |
case ESecureConnection:
|
sl@0
|
308 |
{
|
sl@0
|
309 |
if ( aResult == KClientAuthenticationRequested )
|
sl@0
|
310 |
{
|
sl@0
|
311 |
*iClientDoClientAuthenticationPtr = ETrue;
|
sl@0
|
312 |
aResult = KErrNone;
|
sl@0
|
313 |
}
|
sl@0
|
314 |
else
|
sl@0
|
315 |
{
|
sl@0
|
316 |
*iClientDoClientAuthenticationPtr = EFalse;
|
sl@0
|
317 |
}
|
sl@0
|
318 |
*iClientCertInfoHandlePtr = iCertInfoHandleBuf();
|
sl@0
|
319 |
break;
|
sl@0
|
320 |
}
|
sl@0
|
321 |
case ESignText:
|
sl@0
|
322 |
{
|
sl@0
|
323 |
*iClientCertInfoHandlePtr = iCertInfoHandleBuf();
|
sl@0
|
324 |
break;
|
sl@0
|
325 |
}
|
sl@0
|
326 |
case EEnterPIN:
|
sl@0
|
327 |
case EEnablePIN:
|
sl@0
|
328 |
case EDisablePIN:
|
sl@0
|
329 |
*iClientPINValuePtr = iPINValueBuf();
|
sl@0
|
330 |
break;
|
sl@0
|
331 |
case EChangePIN:
|
sl@0
|
332 |
case EUnblockPIN:
|
sl@0
|
333 |
{
|
sl@0
|
334 |
TTwoPINOutput& twoPINOutput = iTwoPINOutputBuf();
|
sl@0
|
335 |
*iClientPINValuePtr = twoPINOutput.iPINValueToCheck;
|
sl@0
|
336 |
*iClientSecondPINValuePtr = twoPINOutput.iNewPINValue;
|
sl@0
|
337 |
break;
|
sl@0
|
338 |
}
|
sl@0
|
339 |
|
sl@0
|
340 |
case EUnblockPINInClear:
|
sl@0
|
341 |
{
|
sl@0
|
342 |
TUnblockPINInClearOutput& unblockPINOutput = iUnblockPINInClearOutputBuf();
|
sl@0
|
343 |
*iClientUnblockPINValuePtr = unblockPINOutput.iPINValueToCheck;
|
sl@0
|
344 |
*iClientSecondPINValuePtr = unblockPINOutput.iNewPINValue;
|
sl@0
|
345 |
break;
|
sl@0
|
346 |
}
|
sl@0
|
347 |
|
sl@0
|
348 |
case EPINBlocked:
|
sl@0
|
349 |
case ETotalBlocked:
|
sl@0
|
350 |
// No data to return
|
sl@0
|
351 |
break;
|
sl@0
|
352 |
default:
|
sl@0
|
353 |
__ASSERT_DEBUG( EFalse, _L( "Invalid operation" ) );
|
sl@0
|
354 |
}
|
sl@0
|
355 |
}
|
sl@0
|
356 |
|
sl@0
|
357 |
User::RequestComplete( iClientStatus, aResult );
|
sl@0
|
358 |
}
|
sl@0
|
359 |
|
sl@0
|
360 |
|
sl@0
|
361 |
|
sl@0
|
362 |
// ----------------------------------------------------------------------------
|
sl@0
|
363 |
// CDialogRequester
|
sl@0
|
364 |
//
|
sl@0
|
365 |
|
sl@0
|
366 |
CDialogRequester::CDialogRequester( CRefSecurityDialog& aSecDialog )
|
sl@0
|
367 |
: CActive( EPriorityStandard ), iSecDialog( aSecDialog )
|
sl@0
|
368 |
{
|
sl@0
|
369 |
CActiveScheduler::Add( this );
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
|
sl@0
|
373 |
|
sl@0
|
374 |
CDialogRequester::~CDialogRequester()
|
sl@0
|
375 |
{
|
sl@0
|
376 |
Cancel();
|
sl@0
|
377 |
iNotifier.Close();
|
sl@0
|
378 |
}
|
sl@0
|
379 |
|
sl@0
|
380 |
|
sl@0
|
381 |
|
sl@0
|
382 |
CDialogRequester* CDialogRequester::NewL( CRefSecurityDialog& aSecDialog )
|
sl@0
|
383 |
{
|
sl@0
|
384 |
CDialogRequester* self = new (ELeave) CDialogRequester( aSecDialog );
|
sl@0
|
385 |
CleanupStack::PushL( self );
|
sl@0
|
386 |
self->ConstructL();
|
sl@0
|
387 |
CleanupStack::Pop( self );
|
sl@0
|
388 |
return self;
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
|
sl@0
|
392 |
|
sl@0
|
393 |
void CDialogRequester::ConstructL()
|
sl@0
|
394 |
{
|
sl@0
|
395 |
User::LeaveIfError( iNotifier.Connect() );
|
sl@0
|
396 |
}
|
sl@0
|
397 |
|
sl@0
|
398 |
|
sl@0
|
399 |
|
sl@0
|
400 |
void CDialogRequester::RequestDialog( const TDesC8& aData, TDes8& aResponse )
|
sl@0
|
401 |
{
|
sl@0
|
402 |
iNotifier.StartNotifierAndGetResponse( iStatus, KUidSecurityDialogNotifier,
|
sl@0
|
403 |
aData, aResponse );
|
sl@0
|
404 |
iState = KMakingRequest;
|
sl@0
|
405 |
SetActive();
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
|
sl@0
|
409 |
|
sl@0
|
410 |
void CDialogRequester::DoCancel()
|
sl@0
|
411 |
{
|
sl@0
|
412 |
delete iInputBuffer;
|
sl@0
|
413 |
iInputBuffer = NULL;
|
sl@0
|
414 |
iNotifier.CancelNotifier( KUidSecurityDialogNotifier );
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
|
sl@0
|
418 |
|
sl@0
|
419 |
void CDialogRequester::RequestVariableBufferDialog( const TDesC8& aOperationData,
|
sl@0
|
420 |
const TDesC8& aVariableData,
|
sl@0
|
421 |
const RArray<TCTTokenObjectHandle>& aCertHandleList,
|
sl@0
|
422 |
TDes8& aResponse )
|
sl@0
|
423 |
{
|
sl@0
|
424 |
iOperationDataPtr = &aOperationData;
|
sl@0
|
425 |
iVariableDataPtr = &aVariableData;
|
sl@0
|
426 |
iCertHandleListPtr = &aCertHandleList;
|
sl@0
|
427 |
iResponsePtr = &aResponse;
|
sl@0
|
428 |
iState = KFillingVariableInputBuffer;
|
sl@0
|
429 |
SetActive();
|
sl@0
|
430 |
// Complete the AO immediately so that buffer processing can occur in RunL().
|
sl@0
|
431 |
TRequestStatus* statusPtr = &iStatus;
|
sl@0
|
432 |
User::RequestComplete( statusPtr, KErrNone );
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
void CDialogRequester::RequestDialog(HBufC8* aInputBuffer, TDes8& aResponse)
|
sl@0
|
436 |
{
|
sl@0
|
437 |
iInputBuffer = aInputBuffer;
|
sl@0
|
438 |
RequestDialog(*iInputBuffer, aResponse);
|
sl@0
|
439 |
}
|
sl@0
|
440 |
|
sl@0
|
441 |
|
sl@0
|
442 |
void CDialogRequester::RunL()
|
sl@0
|
443 |
{
|
sl@0
|
444 |
switch ( iState )
|
sl@0
|
445 |
{
|
sl@0
|
446 |
case KFillingVariableInputBuffer:
|
sl@0
|
447 |
{
|
sl@0
|
448 |
TInt operationDataSize = iOperationDataPtr->Size();
|
sl@0
|
449 |
TInt variableDataSize = iVariableDataPtr->Size();
|
sl@0
|
450 |
TInt arraySize = sizeof( TCTTokenObjectHandle ) * iCertHandleListPtr->Count();
|
sl@0
|
451 |
TInt bufferSize = operationDataSize + variableDataSize + arraySize;
|
sl@0
|
452 |
iInputBuffer = HBufC8::NewL( bufferSize );
|
sl@0
|
453 |
TPtr8 inputBufferPtr( iInputBuffer->Des() );
|
sl@0
|
454 |
inputBufferPtr.Append( *iOperationDataPtr );
|
sl@0
|
455 |
for ( TInt h = 0, total = iCertHandleListPtr->Count(); h < total; ++h )
|
sl@0
|
456 |
{
|
sl@0
|
457 |
const TCTTokenObjectHandle& certHandle = (*iCertHandleListPtr)[h];
|
sl@0
|
458 |
TPckgC<TCTTokenObjectHandle> certHandleBuf( certHandle );
|
sl@0
|
459 |
inputBufferPtr.Append( certHandleBuf );
|
sl@0
|
460 |
}
|
sl@0
|
461 |
inputBufferPtr.Append( *iVariableDataPtr );
|
sl@0
|
462 |
RequestDialog( *iInputBuffer, *iResponsePtr );
|
sl@0
|
463 |
break;
|
sl@0
|
464 |
}
|
sl@0
|
465 |
case KMakingRequest:
|
sl@0
|
466 |
{
|
sl@0
|
467 |
delete iInputBuffer;
|
sl@0
|
468 |
iInputBuffer = NULL;
|
sl@0
|
469 |
iSecDialog.HandleResponse( iStatus.Int() );
|
sl@0
|
470 |
break;
|
sl@0
|
471 |
}
|
sl@0
|
472 |
default:
|
sl@0
|
473 |
__ASSERT_DEBUG( EFalse, _L( "Invalid state" ) );
|
sl@0
|
474 |
}
|
sl@0
|
475 |
}
|
sl@0
|
476 |
|
sl@0
|
477 |
|
sl@0
|
478 |
|
sl@0
|
479 |
/**
|
sl@0
|
480 |
* RunError should only be called if the buffer allocation fails, in which case
|
sl@0
|
481 |
* let client handle it.
|
sl@0
|
482 |
*/
|
sl@0
|
483 |
TInt CDialogRequester::RunError( TInt aError )
|
sl@0
|
484 |
{
|
sl@0
|
485 |
iSecDialog.HandleResponse( aError );
|
sl@0
|
486 |
return KErrNone;
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
// ----------------------------------------------------------------------------
|
sl@0
|
490 |
// CServerAuthenticationFailureInput
|
sl@0
|
491 |
//
|
sl@0
|
492 |
|
sl@0
|
493 |
CServerAuthenticationFailureInput::CServerAuthenticationFailureInput()
|
sl@0
|
494 |
{
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
|
sl@0
|
498 |
CServerAuthenticationFailureInput::~CServerAuthenticationFailureInput()
|
sl@0
|
499 |
{
|
sl@0
|
500 |
if(iServerName)
|
sl@0
|
501 |
delete iServerName;
|
sl@0
|
502 |
if(iEncodedCert)
|
sl@0
|
503 |
delete iEncodedCert;
|
sl@0
|
504 |
}
|
sl@0
|
505 |
|
sl@0
|
506 |
CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewL(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert, const TBool aCreateOwnBuffers)
|
sl@0
|
507 |
{
|
sl@0
|
508 |
CServerAuthenticationFailureInput* self = CServerAuthenticationFailureInput::NewLC(aServerName, aFailureReason, aEncodedCert, aCreateOwnBuffers);
|
sl@0
|
509 |
CleanupStack::Pop(self);
|
sl@0
|
510 |
return self;
|
sl@0
|
511 |
}
|
sl@0
|
512 |
|
sl@0
|
513 |
CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewLC(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert, const TBool aCreateOwnBuffers)
|
sl@0
|
514 |
{
|
sl@0
|
515 |
CServerAuthenticationFailureInput* self = new(ELeave) CServerAuthenticationFailureInput();
|
sl@0
|
516 |
CleanupStack::PushL(self);
|
sl@0
|
517 |
self->ConstructL(aServerName, aFailureReason, aEncodedCert, aCreateOwnBuffers);
|
sl@0
|
518 |
return self;
|
sl@0
|
519 |
}
|
sl@0
|
520 |
|
sl@0
|
521 |
EXPORT_C CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewL(const TDesC8& aBuffer, const TBool aCreateOwnBuffers)
|
sl@0
|
522 |
{
|
sl@0
|
523 |
CServerAuthenticationFailureInput* self = CServerAuthenticationFailureInput::NewLC(aBuffer, aCreateOwnBuffers);
|
sl@0
|
524 |
CleanupStack::Pop(self);
|
sl@0
|
525 |
return self;
|
sl@0
|
526 |
}
|
sl@0
|
527 |
|
sl@0
|
528 |
EXPORT_C CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewLC(const TDesC8& aBuffer, const TBool aCreateOwnBuffers)
|
sl@0
|
529 |
{
|
sl@0
|
530 |
CServerAuthenticationFailureInput* self = new(ELeave) CServerAuthenticationFailureInput();
|
sl@0
|
531 |
CleanupStack::PushL(self);
|
sl@0
|
532 |
self->ConstructL(aBuffer, aCreateOwnBuffers);
|
sl@0
|
533 |
return self;
|
sl@0
|
534 |
}
|
sl@0
|
535 |
|
sl@0
|
536 |
void CServerAuthenticationFailureInput::ConstructL(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert, const TBool aCreateOwnBuffers)
|
sl@0
|
537 |
{
|
sl@0
|
538 |
iFailureReason = aFailureReason;
|
sl@0
|
539 |
|
sl@0
|
540 |
if (aCreateOwnBuffers)
|
sl@0
|
541 |
{
|
sl@0
|
542 |
iServerName = aServerName.AllocL();
|
sl@0
|
543 |
iServerNamePtr.Set(iServerName->Des());
|
sl@0
|
544 |
iEncodedCert = aEncodedCert.AllocL();
|
sl@0
|
545 |
iEncodedCertPtr.Set(iEncodedCert->Des());
|
sl@0
|
546 |
}
|
sl@0
|
547 |
else
|
sl@0
|
548 |
{
|
sl@0
|
549 |
iServerNamePtr.Set(aServerName);
|
sl@0
|
550 |
iEncodedCertPtr.Set(aEncodedCert);
|
sl@0
|
551 |
}
|
sl@0
|
552 |
}
|
sl@0
|
553 |
|
sl@0
|
554 |
|
sl@0
|
555 |
void CServerAuthenticationFailureInput::ConstructL(const TDesC8& aBuffer, const TBool aCreateOwnBuffers)
|
sl@0
|
556 |
{
|
sl@0
|
557 |
const TServerAuthenticationFailureInput* srvAuthFail =
|
sl@0
|
558 |
reinterpret_cast<const TServerAuthenticationFailureInput*>
|
sl@0
|
559 |
( aBuffer.Ptr() );
|
sl@0
|
560 |
|
sl@0
|
561 |
const TUint8* binaryDataPtr = aBuffer.Ptr() + sizeof(TServerAuthenticationFailureInput);
|
sl@0
|
562 |
|
sl@0
|
563 |
iFailureReason = srvAuthFail->iFailureReason;
|
sl@0
|
564 |
|
sl@0
|
565 |
if(aCreateOwnBuffers)
|
sl@0
|
566 |
{
|
sl@0
|
567 |
TPtrC8 dataPtr(binaryDataPtr, srvAuthFail->iServerNameLength);
|
sl@0
|
568 |
iServerName = dataPtr.AllocL();
|
sl@0
|
569 |
iServerNamePtr.Set(iServerName->Des());
|
sl@0
|
570 |
|
sl@0
|
571 |
dataPtr.Set(binaryDataPtr + srvAuthFail->iServerNameLength, srvAuthFail->iEncodedCertLength);
|
sl@0
|
572 |
iEncodedCert = dataPtr.AllocL();
|
sl@0
|
573 |
iEncodedCertPtr.Set(iEncodedCert->Des());
|
sl@0
|
574 |
}
|
sl@0
|
575 |
else
|
sl@0
|
576 |
{
|
sl@0
|
577 |
iServerNamePtr.Set(binaryDataPtr, srvAuthFail->iServerNameLength);
|
sl@0
|
578 |
iEncodedCertPtr.Set(binaryDataPtr + srvAuthFail->iServerNameLength, srvAuthFail->iEncodedCertLength);
|
sl@0
|
579 |
}
|
sl@0
|
580 |
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
EXPORT_C TValidationError CServerAuthenticationFailureInput::FailureReason()
|
sl@0
|
584 |
{
|
sl@0
|
585 |
return iFailureReason;
|
sl@0
|
586 |
}
|
sl@0
|
587 |
|
sl@0
|
588 |
EXPORT_C void CServerAuthenticationFailureInput::GetServerName(TPtrC8& aServerNamePtr)
|
sl@0
|
589 |
{
|
sl@0
|
590 |
aServerNamePtr.Set(iServerNamePtr);
|
sl@0
|
591 |
}
|
sl@0
|
592 |
|
sl@0
|
593 |
EXPORT_C void CServerAuthenticationFailureInput::GetEncodedCert(TPtrC8& aEncodedCertPtr)
|
sl@0
|
594 |
{
|
sl@0
|
595 |
aEncodedCertPtr.Set(iEncodedCertPtr);
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
EXPORT_C HBufC8* CServerAuthenticationFailureInput::PackBufferL() const
|
sl@0
|
599 |
{
|
sl@0
|
600 |
TServerAuthenticationFailureInput serverAuthenticationInput;
|
sl@0
|
601 |
serverAuthenticationInput.iOperation = EServerAuthenticationFailure;
|
sl@0
|
602 |
serverAuthenticationInput.iFailureReason = iFailureReason;
|
sl@0
|
603 |
serverAuthenticationInput.iServerNameLength = iServerNamePtr.Length();
|
sl@0
|
604 |
serverAuthenticationInput.iEncodedCertLength = iEncodedCertPtr.Length();
|
sl@0
|
605 |
|
sl@0
|
606 |
TServerAuthenticationFailureInputBuf serverAuthenticationInputBuf(serverAuthenticationInput);
|
sl@0
|
607 |
|
sl@0
|
608 |
TInt bufferSize = sizeof(serverAuthenticationInputBuf) + iServerNamePtr.Length() + iEncodedCertPtr.Length();
|
sl@0
|
609 |
HBufC8* packedBuffer = HBufC8::NewL(bufferSize);
|
sl@0
|
610 |
TPtr8 packedBufferPtr(packedBuffer->Des());
|
sl@0
|
611 |
|
sl@0
|
612 |
packedBufferPtr.Append(serverAuthenticationInputBuf);
|
sl@0
|
613 |
packedBufferPtr.Append(iServerNamePtr);
|
sl@0
|
614 |
packedBufferPtr.Append(iEncodedCertPtr);
|
sl@0
|
615 |
|
sl@0
|
616 |
return packedBuffer;
|
sl@0
|
617 |
}
|
sl@0
|
618 |
|