1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/cryptotokenfw/source/ctframework/SecurityDialog.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,618 @@
1.4 +/*
1.5 +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "CRefSecurityDialog.h"
1.23 +
1.24 +// ----------------------------------------------------------------------------
1.25 +// SecurityDialogFactory
1.26 +//
1.27 +
1.28 +EXPORT_C MSecurityDialog* SecurityDialogFactory::CreateL()
1.29 + {
1.30 + return CRefSecurityDialog::NewL();
1.31 + }
1.32 +
1.33 +
1.34 +
1.35 +// ----------------------------------------------------------------------------
1.36 +// CRefSecurityDialog
1.37 +//
1.38 +
1.39 +
1.40 +
1.41 +CRefSecurityDialog::~CRefSecurityDialog()
1.42 + {
1.43 + delete iRequester;
1.44 + }
1.45 +
1.46 +void CRefSecurityDialog::Release()
1.47 + {
1.48 + delete this;
1.49 + }
1.50 +
1.51 +
1.52 +CRefSecurityDialog* CRefSecurityDialog::NewL()
1.53 + {
1.54 + CRefSecurityDialog* self = new (ELeave) CRefSecurityDialog();
1.55 + CleanupStack::PushL( self );
1.56 + self->ConstructL();
1.57 + CleanupStack::Pop( self );
1.58 + return self;
1.59 + }
1.60 +
1.61 +
1.62 +
1.63 +void CRefSecurityDialog::ConstructL()
1.64 + {
1.65 + iRequester = CDialogRequester::NewL( *this );
1.66 + }
1.67 +
1.68 +
1.69 +
1.70 +void CRefSecurityDialog::EnterPIN( const TPINParams& aPINParams, TBool aRetry,
1.71 + TPINValue& aPINValue, TRequestStatus& aStatus )
1.72 + {
1.73 + iClientPINValuePtr = &aPINValue;
1.74 + DoBasicPINOperation( EEnterPIN, aPINParams, aRetry, iPINValueBuf, aStatus );
1.75 + }
1.76 +
1.77 +
1.78 +
1.79 +void CRefSecurityDialog::EnablePIN( const TPINParams& aPINParams, TBool aRetry,
1.80 + TPINValue& aPINValue, TRequestStatus& aStatus )
1.81 + {
1.82 + iClientPINValuePtr = &aPINValue;
1.83 + DoBasicPINOperation( EEnablePIN, aPINParams, aRetry, iPINValueBuf, aStatus );
1.84 + }
1.85 +
1.86 +
1.87 +
1.88 +void CRefSecurityDialog::DisablePIN( const TPINParams& aPINParams, TBool aRetry,
1.89 + TPINValue& aPINValue, TRequestStatus& aStatus )
1.90 + {
1.91 + iClientPINValuePtr = &aPINValue;
1.92 + DoBasicPINOperation( EDisablePIN, aPINParams, aRetry, iPINValueBuf, aStatus );
1.93 + }
1.94 +
1.95 +
1.96 +
1.97 +void CRefSecurityDialog::ChangePIN( const TPINParams& aPINParams, TBool aRetry,
1.98 + TPINValue& aOldPINValue, TPINValue& aNewPINValue,
1.99 + TRequestStatus& aStatus )
1.100 + {
1.101 + iClientPINValuePtr = &aOldPINValue;
1.102 + iClientSecondPINValuePtr = &aNewPINValue;
1.103 + DoBasicPINOperation( EChangePIN, aPINParams, aRetry, iTwoPINOutputBuf, aStatus );
1.104 + }
1.105 +
1.106 +
1.107 +
1.108 +void CRefSecurityDialog::UnblockPIN( const TPINParams& aBlockedPINParams,
1.109 + const TPINParams& aUnblockingPINParams, TBool aRetry,
1.110 + TPINValue& aUnblockingPINValue, TPINValue& aNewPINValue,
1.111 + TRequestStatus& aStatus )
1.112 + {
1.113 + iCurrentOperation = EUnblockPIN;
1.114 + InitClientStatus( aStatus );
1.115 +
1.116 + TUnblockPINInput unblockPINInput;
1.117 + unblockPINInput.iOperation = EUnblockPIN;
1.118 + if ( aRetry )
1.119 + {
1.120 + unblockPINInput.iOperation |= EPINValueIncorrect;
1.121 + }
1.122 + unblockPINInput.iPIN = aBlockedPINParams;
1.123 + unblockPINInput.iUnblockPIN = aUnblockingPINParams;
1.124 + TUnblockPINInputBuf unblockPINInputBuf( unblockPINInput );
1.125 + iUnblockPINInputBuf.Copy( unblockPINInputBuf );
1.126 + iClientPINValuePtr = &aUnblockingPINValue;
1.127 + iClientSecondPINValuePtr = &aNewPINValue;
1.128 +
1.129 + iRequester->RequestDialog( iUnblockPINInputBuf, iTwoPINOutputBuf );
1.130 + }
1.131 +
1.132 +void CRefSecurityDialog::UnblockPINInClear( const TPINParams& aBlockedPINParams,
1.133 + const TPINParams& aUnblockingPINParams, TBool aRetry,
1.134 + TUnblockPINValue& aUnblockingPINValue, TPINValue& aNewPINValue,
1.135 + TRequestStatus& aStatus )
1.136 + {
1.137 + iCurrentOperation = EUnblockPINInClear;
1.138 + InitClientStatus( aStatus );
1.139 +
1.140 + TUnblockPINInput unblockPINInput;
1.141 + unblockPINInput.iOperation = EUnblockPINInClear;
1.142 + if ( aRetry )
1.143 + {
1.144 + unblockPINInput.iOperation |= EPINValueIncorrect;
1.145 + }
1.146 + unblockPINInput.iPIN = aBlockedPINParams;
1.147 + unblockPINInput.iUnblockPIN = aUnblockingPINParams;
1.148 + TUnblockPINInputBuf unblockPINInputBuf( unblockPINInput );
1.149 +
1.150 + iClientUnblockPINValuePtr = &aUnblockingPINValue;
1.151 + iClientSecondPINValuePtr = &aNewPINValue;
1.152 + iUnblockPINInputBuf.Copy( unblockPINInputBuf );
1.153 + iRequester->RequestDialog( iUnblockPINInputBuf, iUnblockPINInClearOutputBuf );
1.154 + }
1.155 +
1.156 +void CRefSecurityDialog::Cancel()
1.157 + {
1.158 + iRequester->Cancel();
1.159 + if (iClientStatus)
1.160 + {
1.161 + User::RequestComplete(iClientStatus, KErrCancel);
1.162 + }
1.163 + }
1.164 +
1.165 +void CRefSecurityDialog::PINBlocked( const TPINParams& aPINParams,
1.166 + TRequestStatus& aStatus )
1.167 + {
1.168 + iCurrentOperation = EPINBlocked;
1.169 + TPckg<TPINValue> pinValueBuf( KNullDesC() );
1.170 + DoBasicPINOperation( EPINBlocked, aPINParams, EFalse, pinValueBuf, aStatus );
1.171 + }
1.172 +
1.173 +
1.174 +void CRefSecurityDialog::TotalBlocked( const TPINParams& aPINParams,
1.175 + TRequestStatus& aStatus )
1.176 + {
1.177 + iCurrentOperation = ETotalBlocked;
1.178 + TPckg<TPINValue> pinValueBuf( KNullDesC() );
1.179 + DoBasicPINOperation( ETotalBlocked, aPINParams, EFalse, pinValueBuf, aStatus );
1.180 + }
1.181 +
1.182 +
1.183 +
1.184 +void CRefSecurityDialog::EstablishSecureConnection( const TDesC8& aCertData,
1.185 + const RArray<TCTTokenObjectHandle>& aCertHandleList,
1.186 + MSecurityDialog::TConnectionType aConnectionType,
1.187 + TBool& aDoClientAuthentication, TCTTokenObjectHandle& aCertHandle,
1.188 + TRequestStatus& aStatus )
1.189 + {
1.190 + iCurrentOperation = ESecureConnection;
1.191 + InitClientStatus( aStatus );
1.192 +
1.193 + TInt certDataSize = aCertData.Size();
1.194 + TSignInput signInput;
1.195 + signInput.iOperation = ESecureConnection;
1.196 + signInput.iVariableDataSize = certDataSize;
1.197 + signInput.iCertHandleArrayTotal = aCertHandleList.Count();
1.198 + signInput.iDoClientAuthentication = aDoClientAuthentication;
1.199 + signInput.iConnectionType = aConnectionType;
1.200 + TPckgC<TSignInput> signInputBufPtr( signInput );
1.201 + // iSignInputBuf is persistent because further input processing occurs in the AO before
1.202 + // calling the notifier.
1.203 + iSignInputBuf.Copy( signInputBufPtr );
1.204 + iVariableDataPtr.Set( aCertData );
1.205 +
1.206 + iClientDoClientAuthenticationPtr = &aDoClientAuthentication;
1.207 + iClientCertInfoHandlePtr = &aCertHandle;
1.208 +
1.209 + iRequester->RequestVariableBufferDialog( iSignInputBuf, iVariableDataPtr,
1.210 + aCertHandleList, iCertInfoHandleBuf );
1.211 + }
1.212 +
1.213 +
1.214 +
1.215 +void CRefSecurityDialog::SignText( const TDesC& aTextToSign,
1.216 + const RArray<TCTTokenObjectHandle>& aCertHandleList,
1.217 + TCTTokenObjectHandle& aCertHandle,
1.218 + TRequestStatus& aStatus )
1.219 + {
1.220 + iCurrentOperation = ESignText;
1.221 + InitClientStatus( aStatus );
1.222 +
1.223 + TInt textSize = aTextToSign.Size();
1.224 + TSignInput signInput;
1.225 + signInput.iOperation = ESignText;
1.226 + signInput.iVariableDataSize = textSize;
1.227 + signInput.iCertHandleArrayTotal = aCertHandleList.Count();
1.228 + TPckgC<TSignInput> signInputBufPtr( signInput );
1.229 + // iSignInputBuf is persistent because further input processing occurs in the AO before
1.230 + // calling the notifier.
1.231 + iSignInputBuf.Copy( signInputBufPtr );
1.232 + const TUint8* textToSignPtr = reinterpret_cast<const TUint8*>( aTextToSign.Ptr() );
1.233 + iVariableDataPtr.Set( textToSignPtr, textSize );
1.234 +
1.235 + iClientCertInfoHandlePtr = &aCertHandle;
1.236 +
1.237 + iRequester->RequestVariableBufferDialog( iSignInputBuf, iVariableDataPtr,
1.238 + aCertHandleList, iCertInfoHandleBuf );
1.239 + }
1.240 +
1.241 +void CRefSecurityDialog::ServerAuthenticationFailure(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert,TRequestStatus& aStatus )
1.242 + {
1.243 + iCurrentOperation = EServerAuthenticationFailure;
1.244 + InitClientStatus( aStatus );
1.245 +
1.246 + CServerAuthenticationFailureInput* serverAuthenticationFailureInput = NULL;
1.247 + TRAPD(err, serverAuthenticationFailureInput = CServerAuthenticationFailureInput::NewL(aServerName, aFailureReason, aEncodedCert));
1.248 +
1.249 + // Ownership of the inputBuffer will pass to the requester.
1.250 + HBufC8* inputBuffer = NULL;
1.251 + if (err == KErrNone)
1.252 + TRAP(err, inputBuffer = serverAuthenticationFailureInput->PackBufferL());
1.253 +
1.254 + delete serverAuthenticationFailureInput;
1.255 +
1.256 + if (err == KErrNone)
1.257 + iRequester->RequestDialog(inputBuffer, iServerAuthenticationOutputBuf);
1.258 + else
1.259 + HandleResponse(err);
1.260 + }
1.261 +
1.262 +void CRefSecurityDialog::DoBasicPINOperation( TSecurityDialogOperation aOperation,
1.263 + const TPINParams& aPINParams, TBool aRetry, TDes8& aPINValue,
1.264 + TRequestStatus& aStatus )
1.265 + {
1.266 + iCurrentOperation = aOperation;
1.267 + InitClientStatus( aStatus );
1.268 + TPINInput pinInput;
1.269 + pinInput.iOperation = aOperation;
1.270 + if ( aRetry )
1.271 + {
1.272 + pinInput.iOperation |= EPINValueIncorrect;
1.273 + }
1.274 + pinInput.iPIN = aPINParams;
1.275 + TPINInputBuf pinInputBuf( pinInput );
1.276 + iPINInputBuf.Copy( pinInputBuf );
1.277 + iRequester->RequestDialog( iPINInputBuf, aPINValue );
1.278 + }
1.279 +
1.280 +
1.281 +
1.282 +void CRefSecurityDialog::InitClientStatus( TRequestStatus& aStatus )
1.283 + {
1.284 + iClientStatus = &aStatus;
1.285 + *iClientStatus = KRequestPending;
1.286 + }
1.287 +
1.288 +
1.289 +
1.290 +void CRefSecurityDialog::HandleResponse( TInt aResult )
1.291 + {
1.292 + if ( aResult >= KErrNone )
1.293 + {
1.294 + switch ( iCurrentOperation )
1.295 + {
1.296 + case EServerAuthenticationFailure:
1.297 + {
1.298 + TServerAuthenticationFailureDialogResult serverAuthenticationOutput = iServerAuthenticationOutputBuf();
1.299 +
1.300 + if(serverAuthenticationOutput == EContinue)
1.301 + {
1.302 + aResult = KErrNone;
1.303 + }
1.304 + else if(serverAuthenticationOutput == EStop)
1.305 + {
1.306 + aResult = KErrAbort;
1.307 + }
1.308 + }
1.309 + break;
1.310 + case ESecureConnection:
1.311 + {
1.312 + if ( aResult == KClientAuthenticationRequested )
1.313 + {
1.314 + *iClientDoClientAuthenticationPtr = ETrue;
1.315 + aResult = KErrNone;
1.316 + }
1.317 + else
1.318 + {
1.319 + *iClientDoClientAuthenticationPtr = EFalse;
1.320 + }
1.321 + *iClientCertInfoHandlePtr = iCertInfoHandleBuf();
1.322 + break;
1.323 + }
1.324 + case ESignText:
1.325 + {
1.326 + *iClientCertInfoHandlePtr = iCertInfoHandleBuf();
1.327 + break;
1.328 + }
1.329 + case EEnterPIN:
1.330 + case EEnablePIN:
1.331 + case EDisablePIN:
1.332 + *iClientPINValuePtr = iPINValueBuf();
1.333 + break;
1.334 + case EChangePIN:
1.335 + case EUnblockPIN:
1.336 + {
1.337 + TTwoPINOutput& twoPINOutput = iTwoPINOutputBuf();
1.338 + *iClientPINValuePtr = twoPINOutput.iPINValueToCheck;
1.339 + *iClientSecondPINValuePtr = twoPINOutput.iNewPINValue;
1.340 + break;
1.341 + }
1.342 +
1.343 + case EUnblockPINInClear:
1.344 + {
1.345 + TUnblockPINInClearOutput& unblockPINOutput = iUnblockPINInClearOutputBuf();
1.346 + *iClientUnblockPINValuePtr = unblockPINOutput.iPINValueToCheck;
1.347 + *iClientSecondPINValuePtr = unblockPINOutput.iNewPINValue;
1.348 + break;
1.349 + }
1.350 +
1.351 + case EPINBlocked:
1.352 + case ETotalBlocked:
1.353 + // No data to return
1.354 + break;
1.355 + default:
1.356 + __ASSERT_DEBUG( EFalse, _L( "Invalid operation" ) );
1.357 + }
1.358 + }
1.359 +
1.360 + User::RequestComplete( iClientStatus, aResult );
1.361 + }
1.362 +
1.363 +
1.364 +
1.365 +// ----------------------------------------------------------------------------
1.366 +// CDialogRequester
1.367 +//
1.368 +
1.369 +CDialogRequester::CDialogRequester( CRefSecurityDialog& aSecDialog )
1.370 + : CActive( EPriorityStandard ), iSecDialog( aSecDialog )
1.371 + {
1.372 + CActiveScheduler::Add( this );
1.373 + }
1.374 +
1.375 +
1.376 +
1.377 +CDialogRequester::~CDialogRequester()
1.378 + {
1.379 + Cancel();
1.380 + iNotifier.Close();
1.381 + }
1.382 +
1.383 +
1.384 +
1.385 +CDialogRequester* CDialogRequester::NewL( CRefSecurityDialog& aSecDialog )
1.386 + {
1.387 + CDialogRequester* self = new (ELeave) CDialogRequester( aSecDialog );
1.388 + CleanupStack::PushL( self );
1.389 + self->ConstructL();
1.390 + CleanupStack::Pop( self );
1.391 + return self;
1.392 + }
1.393 +
1.394 +
1.395 +
1.396 +void CDialogRequester::ConstructL()
1.397 + {
1.398 + User::LeaveIfError( iNotifier.Connect() );
1.399 + }
1.400 +
1.401 +
1.402 +
1.403 +void CDialogRequester::RequestDialog( const TDesC8& aData, TDes8& aResponse )
1.404 + {
1.405 + iNotifier.StartNotifierAndGetResponse( iStatus, KUidSecurityDialogNotifier,
1.406 + aData, aResponse );
1.407 + iState = KMakingRequest;
1.408 + SetActive();
1.409 + }
1.410 +
1.411 +
1.412 +
1.413 +void CDialogRequester::DoCancel()
1.414 + {
1.415 + delete iInputBuffer;
1.416 + iInputBuffer = NULL;
1.417 + iNotifier.CancelNotifier( KUidSecurityDialogNotifier );
1.418 + }
1.419 +
1.420 +
1.421 +
1.422 +void CDialogRequester::RequestVariableBufferDialog( const TDesC8& aOperationData,
1.423 + const TDesC8& aVariableData,
1.424 + const RArray<TCTTokenObjectHandle>& aCertHandleList,
1.425 + TDes8& aResponse )
1.426 + {
1.427 + iOperationDataPtr = &aOperationData;
1.428 + iVariableDataPtr = &aVariableData;
1.429 + iCertHandleListPtr = &aCertHandleList;
1.430 + iResponsePtr = &aResponse;
1.431 + iState = KFillingVariableInputBuffer;
1.432 + SetActive();
1.433 + // Complete the AO immediately so that buffer processing can occur in RunL().
1.434 + TRequestStatus* statusPtr = &iStatus;
1.435 + User::RequestComplete( statusPtr, KErrNone );
1.436 + }
1.437 +
1.438 +void CDialogRequester::RequestDialog(HBufC8* aInputBuffer, TDes8& aResponse)
1.439 +{
1.440 +iInputBuffer = aInputBuffer;
1.441 +RequestDialog(*iInputBuffer, aResponse);
1.442 +}
1.443 +
1.444 +
1.445 +void CDialogRequester::RunL()
1.446 + {
1.447 + switch ( iState )
1.448 + {
1.449 + case KFillingVariableInputBuffer:
1.450 + {
1.451 + TInt operationDataSize = iOperationDataPtr->Size();
1.452 + TInt variableDataSize = iVariableDataPtr->Size();
1.453 + TInt arraySize = sizeof( TCTTokenObjectHandle ) * iCertHandleListPtr->Count();
1.454 + TInt bufferSize = operationDataSize + variableDataSize + arraySize;
1.455 + iInputBuffer = HBufC8::NewL( bufferSize );
1.456 + TPtr8 inputBufferPtr( iInputBuffer->Des() );
1.457 + inputBufferPtr.Append( *iOperationDataPtr );
1.458 + for ( TInt h = 0, total = iCertHandleListPtr->Count(); h < total; ++h )
1.459 + {
1.460 + const TCTTokenObjectHandle& certHandle = (*iCertHandleListPtr)[h];
1.461 + TPckgC<TCTTokenObjectHandle> certHandleBuf( certHandle );
1.462 + inputBufferPtr.Append( certHandleBuf );
1.463 + }
1.464 + inputBufferPtr.Append( *iVariableDataPtr );
1.465 + RequestDialog( *iInputBuffer, *iResponsePtr );
1.466 + break;
1.467 + }
1.468 + case KMakingRequest:
1.469 + {
1.470 + delete iInputBuffer;
1.471 + iInputBuffer = NULL;
1.472 + iSecDialog.HandleResponse( iStatus.Int() );
1.473 + break;
1.474 + }
1.475 + default:
1.476 + __ASSERT_DEBUG( EFalse, _L( "Invalid state" ) );
1.477 + }
1.478 + }
1.479 +
1.480 +
1.481 +
1.482 +/**
1.483 + * RunError should only be called if the buffer allocation fails, in which case
1.484 + * let client handle it.
1.485 + */
1.486 +TInt CDialogRequester::RunError( TInt aError )
1.487 + {
1.488 + iSecDialog.HandleResponse( aError );
1.489 + return KErrNone;
1.490 + }
1.491 +
1.492 +// ----------------------------------------------------------------------------
1.493 +// CServerAuthenticationFailureInput
1.494 +//
1.495 +
1.496 +CServerAuthenticationFailureInput::CServerAuthenticationFailureInput()
1.497 + {
1.498 + }
1.499 +
1.500 +
1.501 +CServerAuthenticationFailureInput::~CServerAuthenticationFailureInput()
1.502 + {
1.503 + if(iServerName)
1.504 + delete iServerName;
1.505 + if(iEncodedCert)
1.506 + delete iEncodedCert;
1.507 + }
1.508 +
1.509 +CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewL(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert, const TBool aCreateOwnBuffers)
1.510 + {
1.511 + CServerAuthenticationFailureInput* self = CServerAuthenticationFailureInput::NewLC(aServerName, aFailureReason, aEncodedCert, aCreateOwnBuffers);
1.512 + CleanupStack::Pop(self);
1.513 + return self;
1.514 + }
1.515 +
1.516 +CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewLC(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert, const TBool aCreateOwnBuffers)
1.517 + {
1.518 + CServerAuthenticationFailureInput* self = new(ELeave) CServerAuthenticationFailureInput();
1.519 + CleanupStack::PushL(self);
1.520 + self->ConstructL(aServerName, aFailureReason, aEncodedCert, aCreateOwnBuffers);
1.521 + return self;
1.522 + }
1.523 +
1.524 +EXPORT_C CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewL(const TDesC8& aBuffer, const TBool aCreateOwnBuffers)
1.525 + {
1.526 + CServerAuthenticationFailureInput* self = CServerAuthenticationFailureInput::NewLC(aBuffer, aCreateOwnBuffers);
1.527 + CleanupStack::Pop(self);
1.528 + return self;
1.529 + }
1.530 +
1.531 +EXPORT_C CServerAuthenticationFailureInput* CServerAuthenticationFailureInput::NewLC(const TDesC8& aBuffer, const TBool aCreateOwnBuffers)
1.532 + {
1.533 + CServerAuthenticationFailureInput* self = new(ELeave) CServerAuthenticationFailureInput();
1.534 + CleanupStack::PushL(self);
1.535 + self->ConstructL(aBuffer, aCreateOwnBuffers);
1.536 + return self;
1.537 + }
1.538 +
1.539 +void CServerAuthenticationFailureInput::ConstructL(const TDesC8& aServerName,const TValidationError& aFailureReason, const TDesC8& aEncodedCert, const TBool aCreateOwnBuffers)
1.540 + {
1.541 + iFailureReason = aFailureReason;
1.542 +
1.543 + if (aCreateOwnBuffers)
1.544 + {
1.545 + iServerName = aServerName.AllocL();
1.546 + iServerNamePtr.Set(iServerName->Des());
1.547 + iEncodedCert = aEncodedCert.AllocL();
1.548 + iEncodedCertPtr.Set(iEncodedCert->Des());
1.549 + }
1.550 + else
1.551 + {
1.552 + iServerNamePtr.Set(aServerName);
1.553 + iEncodedCertPtr.Set(aEncodedCert);
1.554 + }
1.555 + }
1.556 +
1.557 +
1.558 +void CServerAuthenticationFailureInput::ConstructL(const TDesC8& aBuffer, const TBool aCreateOwnBuffers)
1.559 + {
1.560 + const TServerAuthenticationFailureInput* srvAuthFail =
1.561 + reinterpret_cast<const TServerAuthenticationFailureInput*>
1.562 + ( aBuffer.Ptr() );
1.563 +
1.564 + const TUint8* binaryDataPtr = aBuffer.Ptr() + sizeof(TServerAuthenticationFailureInput);
1.565 +
1.566 + iFailureReason = srvAuthFail->iFailureReason;
1.567 +
1.568 + if(aCreateOwnBuffers)
1.569 + {
1.570 + TPtrC8 dataPtr(binaryDataPtr, srvAuthFail->iServerNameLength);
1.571 + iServerName = dataPtr.AllocL();
1.572 + iServerNamePtr.Set(iServerName->Des());
1.573 +
1.574 + dataPtr.Set(binaryDataPtr + srvAuthFail->iServerNameLength, srvAuthFail->iEncodedCertLength);
1.575 + iEncodedCert = dataPtr.AllocL();
1.576 + iEncodedCertPtr.Set(iEncodedCert->Des());
1.577 + }
1.578 + else
1.579 + {
1.580 + iServerNamePtr.Set(binaryDataPtr, srvAuthFail->iServerNameLength);
1.581 + iEncodedCertPtr.Set(binaryDataPtr + srvAuthFail->iServerNameLength, srvAuthFail->iEncodedCertLength);
1.582 + }
1.583 +
1.584 + }
1.585 +
1.586 +EXPORT_C TValidationError CServerAuthenticationFailureInput::FailureReason()
1.587 + {
1.588 + return iFailureReason;
1.589 + }
1.590 +
1.591 +EXPORT_C void CServerAuthenticationFailureInput::GetServerName(TPtrC8& aServerNamePtr)
1.592 + {
1.593 + aServerNamePtr.Set(iServerNamePtr);
1.594 + }
1.595 +
1.596 +EXPORT_C void CServerAuthenticationFailureInput::GetEncodedCert(TPtrC8& aEncodedCertPtr)
1.597 + {
1.598 + aEncodedCertPtr.Set(iEncodedCertPtr);
1.599 + }
1.600 +
1.601 +EXPORT_C HBufC8* CServerAuthenticationFailureInput::PackBufferL() const
1.602 + {
1.603 + TServerAuthenticationFailureInput serverAuthenticationInput;
1.604 + serverAuthenticationInput.iOperation = EServerAuthenticationFailure;
1.605 + serverAuthenticationInput.iFailureReason = iFailureReason;
1.606 + serverAuthenticationInput.iServerNameLength = iServerNamePtr.Length();
1.607 + serverAuthenticationInput.iEncodedCertLength = iEncodedCertPtr.Length();
1.608 +
1.609 + TServerAuthenticationFailureInputBuf serverAuthenticationInputBuf(serverAuthenticationInput);
1.610 +
1.611 + TInt bufferSize = sizeof(serverAuthenticationInputBuf) + iServerNamePtr.Length() + iEncodedCertPtr.Length();
1.612 + HBufC8* packedBuffer = HBufC8::NewL(bufferSize);
1.613 + TPtr8 packedBufferPtr(packedBuffer->Des());
1.614 +
1.615 + packedBufferPtr.Append(serverAuthenticationInputBuf);
1.616 + packedBufferPtr.Append(iServerNamePtr);
1.617 + packedBufferPtr.Append(iEncodedCertPtr);
1.618 +
1.619 + return packedBuffer;
1.620 + }
1.621 +