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