42 #include "CertSaverAppUi.h" |
44 #include "CertSaverAppUi.h" |
43 #include "CertSaverSyncWrapper.h" |
45 #include "CertSaverSyncWrapper.h" |
44 #include "certsaver.hrh" |
46 #include "certsaver.hrh" |
45 #include "securityuisvariant.hrh" |
47 #include "securityuisvariant.hrh" |
46 |
48 |
|
49 #include <hbdevicemessageboxsymbian.h> |
|
50 #include <hbdevicenotificationdialogsymbian.h> |
|
51 #include <hbsymbianvariant.h> |
|
52 |
|
53 #include "SecQueryUi.h" // needed for label dialog |
|
54 |
47 // CONSTANTS |
55 // CONSTANTS |
|
56 |
48 const TInt32 KWTLSTrusterUID( 268479059 ); |
57 const TInt32 KWTLSTrusterUID( 268479059 ); |
49 const TInt32 KInternetTrusterUID( 268441661 ); |
58 const TInt32 KInternetTrusterUID( 268441661 ); |
50 const TInt32 KApplicationControllerTrusterUID( 268452523 ); |
59 const TInt32 KApplicationControllerTrusterUID( 268452523 ); |
51 const TInt32 KJavaInstallTrusterUID( 270506792 ); |
60 const TInt32 KJavaInstallTrusterUID( 270506792 ); |
52 const TInt32 KOCSPTrusterUID( 268478646 ); |
61 const TInt32 KOCSPTrusterUID( 268478646 ); |
54 |
63 |
55 const TInt KTrusterArrayInitSize( 2 ); |
64 const TInt KTrusterArrayInitSize( 2 ); |
56 |
65 |
57 const TInt KMaxLengthTextMeassageBody( 5000 ); |
66 const TInt KMaxLengthTextMeassageBody( 5000 ); |
58 const TInt KMaxLengthTextDateString( 11 ); // "dd/mm/yyyy0" |
67 const TInt KMaxLengthTextDateString( 11 ); // "dd/mm/yyyy0" |
|
68 const TInt KMaxLengthTextCheckBoxData( 255 ); // "dd/mm/yyyy0" |
59 |
69 |
60 //Issuer and Owner max visible length |
70 //Issuer and Owner max visible length |
61 const TInt KMaxLengthTextCertIdentifierVisible( 1000 ); |
71 const TInt KMaxLengthTextCertIdentifierVisible( 1000 ); |
62 const TInt KAttempts( 3 ); |
72 const TInt KAttempts( 3 ); |
63 |
73 |
64 const TInt KFingerprintLength( 50 ); |
74 const TInt KFingerprintLength( 50 ); |
|
75 const TInt KTokenLength( 32 ); |
65 |
76 |
66 _LIT( KCertSaverListBoxItemPrefix, "1\t" ); |
77 _LIT( KCertSaverListBoxItemPrefix, "1\t" ); |
67 const TInt KItemBufLen = 2 + KMaxName; |
78 const TInt KItemBufLen = 2 + KMaxName; |
68 |
79 |
69 _LIT( KPrivateKeyLabel, "PrivateKey " ); |
80 _LIT( KPrivateKeyLabel, "PrivateKey " ); |
156 TBuf<KPrivaKeyLabelLength> keyLabel( KPrivateKeyLabel ); |
169 TBuf<KPrivaKeyLabelLength> keyLabel( KPrivateKeyLabel ); |
157 TKeyUsagePKCS15 keyUsage = KeyUsageL( keyIdentifier, pkcs8Data->Algorithm() ); |
170 TKeyUsagePKCS15 keyUsage = KeyUsageL( keyIdentifier, pkcs8Data->Algorithm() ); |
158 CleanupStack::PopAndDestroy( pkcs8Data ); |
171 CleanupStack::PopAndDestroy( pkcs8Data ); |
159 if (KeyAlreadyExistsL( startDate, endDate, keyIdentifier, keyUsage) ) |
172 if (KeyAlreadyExistsL( startDate, endDate, keyIdentifier, keyUsage) ) |
160 { |
173 { |
161 User::Leave( KErrNone ); |
174 // used to leave with error none |
|
175 return; |
162 } |
176 } |
163 |
177 |
164 TInt accessType( 0 ); |
178 TInt accessType( 0 ); |
165 |
179 |
166 accessType |= CCTKeyInfo::EExtractable; |
180 accessType |= CCTKeyInfo::EExtractable; |
483 // const TDesC8& aDataToSave) |
502 // const TDesC8& aDataToSave) |
484 // ---------------------------------------------------------- |
503 // ---------------------------------------------------------- |
485 // |
504 // |
486 void CCertSaverModel::CheckFSSpaceL( const TDesC8& aDataToSave ) |
505 void CCertSaverModel::CheckFSSpaceL( const TDesC8& aDataToSave ) |
487 { |
506 { |
|
507 |
488 if (SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, aDataToSave.Size() )) |
508 if (SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, aDataToSave.Size() )) |
489 { |
509 { |
490 HBufC* p = StringLoader::LoadLC( R_CERTSAVER_MEMORY ); |
510 HBufC* p = StringLoader::LoadLC( R_CERTSAVER_MEMORY ); |
491 CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue ); |
511 CHbDeviceMessageBoxSymbian::WarningL(p->Des()); |
492 note->ExecuteLD( p->Des() ); |
|
493 CleanupStack::PopAndDestroy( p ); |
512 CleanupStack::PopAndDestroy( p ); |
494 User::Leave( KErrExitApp ); |
513 User::Leave( KErrExitApp ); |
495 } |
514 } |
496 } |
515 } |
497 |
|
498 // ---------------------------------------------------------- |
516 // ---------------------------------------------------------- |
499 // CCertSaverModel::SaveCertL() |
517 // CCertSaverModel::SaveCertL() |
500 // Saves certificate |
518 // Saves certificate |
501 // ---------------------------------------------------------- |
519 // ---------------------------------------------------------- |
502 // |
520 // |
503 void CCertSaverModel::SaveCertL() |
521 void CCertSaverModel::SaveCertL() |
504 { |
522 { |
|
523 |
505 if ( !CertificateOkL() ) |
524 if ( !CertificateOkL() ) |
506 { |
525 { |
507 User::Leave( KErrCancel ); |
526 User::Leave( KErrCancel ); |
508 } |
527 } |
509 |
528 |
510 HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody ); |
529 HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody ); |
511 TPtr msgPtr = message->Des(); |
530 TPtr msgPtr = message->Des(); |
512 ConstructMessageL( msgPtr ); |
531 ConstructMessageL( msgPtr ); |
513 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *message ); |
532 CHbDeviceMessageBoxSymbian::TButtonId selection = |
514 CleanupStack::PopAndDestroy( message ); |
533 CHbDeviceMessageBoxSymbian::QuestionL(msgPtr, KNullDesC, KNullDesC); |
515 CleanupStack::PushL( dlg ); |
534 TBool doSave= (selection == CHbDeviceMessageBoxSymbian::EAcceptButton); |
516 |
535 CleanupStack::PopAndDestroy(message); |
517 |
|
518 dlg->PrepareLC( R_MESSAGE_QUERY_DOSAVE ); |
|
519 |
|
520 HBufC* header = StringLoader::LoadLC( R_CERTSAVER_DETAILS_HEADING ); |
|
521 dlg->QueryHeading()->SetTextL( header->Des() ); |
|
522 CleanupStack::PopAndDestroy( header ); |
|
523 CleanupStack::Pop( dlg ); |
|
524 TBool doSave = dlg->RunLD(); |
|
525 |
536 |
526 if ( doSave && iCertOwnerType == ECACertificate ) |
537 if ( doSave && iCertOwnerType == ECACertificate ) |
527 { |
538 { |
528 // warn user about security risk |
539 // warn user about security risk |
529 CAknQueryDialog* warningDialog = CAknQueryDialog::NewL(); |
540 HBufC* stringHolder = StringLoader::LoadLC( R_CERTSAVER_WARNING_NOTE ); |
530 doSave = warningDialog->ExecuteLD( R_CERTSAVER_WARNING_NOTE ); |
541 CHbDeviceMessageBoxSymbian::TButtonId selection = |
|
542 CHbDeviceMessageBoxSymbian::QuestionL(stringHolder->Des(),KNullDesC, KNullDesC); |
|
543 CleanupStack::PopAndDestroy(stringHolder); |
|
544 doSave=(selection == CHbDeviceMessageBoxSymbian::EAcceptButton); |
531 } |
545 } |
532 |
546 |
533 if ( doSave ) |
547 if ( doSave ) |
534 { |
548 { |
535 //Check that there still is enough space to store the |
549 //Check that there still is enough space to store the certificate. |
536 //certificate. |
|
537 CheckFSSpaceL( iNewCert->Encoding() ); |
550 CheckFSSpaceL( iNewCert->Encoding() ); |
538 DoSaveCertL(); |
551 DoSaveCertL(); |
539 } |
552 } |
540 else |
553 else |
541 { |
554 { |
542 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
555 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
543 User::Leave( KErrCancel ); |
556 User::Leave( KErrCancel ); |
544 } |
557 } |
545 } |
558 } |
546 |
559 |
|
560 |
547 // ---------------------------------------------------------- |
561 // ---------------------------------------------------------- |
548 // CCertSaverModel::InitCertStoreL() |
562 // CCertSaverModel::InitCertStoreL() |
549 // |
563 // |
550 // ---------------------------------------------------------- |
564 // ---------------------------------------------------------- |
551 // |
565 // |
552 void CCertSaverModel::InitCertStoreL() |
566 void CCertSaverModel::InitCertStoreL() |
553 { |
567 { |
|
568 |
554 if ( !iUnifiedCertStore ) |
569 if ( !iUnifiedCertStore ) |
555 { |
570 { |
556 TRAPD( status, iUnifiedCertStore = CUnifiedCertStore::NewL( iFs, ETrue ) ); |
571 TRAPD( status, iUnifiedCertStore = CUnifiedCertStore::NewL( iFs, ETrue ) ); |
557 if ( status != KErrNone ) |
572 if ( status != KErrNone ) |
558 { |
573 { |
784 // already exist. |
801 // already exist. |
785 // ---------------------------------------------------------- |
802 // ---------------------------------------------------------- |
786 // |
803 // |
787 TInt CCertSaverModel::QueryLabelL( TCertLabel& aLabel, CUnifiedCertStore& aStore ) |
804 TInt CCertSaverModel::QueryLabelL( TCertLabel& aLabel, CUnifiedCertStore& aStore ) |
788 { |
805 { |
|
806 |
789 CCertAttributeFilter* filter = NULL; |
807 CCertAttributeFilter* filter = NULL; |
790 TInt status = KErrNone; |
808 TInt status = KErrNone; |
791 RMPointerArray<CCTCertInfo> entries; |
809 RMPointerArray<CCTCertInfo> entries; |
792 TBool loop = ETrue; |
810 TBool loop = ETrue; |
793 |
811 |
794 while ( loop ) |
812 while ( loop ) |
795 { |
813 { |
796 CAknTextQueryDialog* dialog = CAknTextQueryDialog::NewL( aLabel ); |
814 HBufC* labelprompt = CEikonEnv::Static()->AllocReadResourceLC( R_CERTSAVER_ENTER_LABEL ); |
797 if ( !dialog->ExecuteLD( R_CERTSAVER_LABEL_QUERY ) ) |
815 CSecQueryUi* SecQueryUi = CSecQueryUi::NewL(); |
|
816 TInt queryAccepted = SecQueryUi->SecQueryDialog(labelprompt->Des(), aLabel, |
|
817 1,KMaxCertLabelLength, |
|
818 ESecUiAlphaSupported | |
|
819 ESecUiCancelSupported | |
|
820 ESecUiEmergencyNotSupported); |
|
821 CleanupStack::PopAndDestroy( labelprompt ); |
|
822 delete SecQueryUi; |
|
823 SecQueryUi=NULL; |
|
824 |
|
825 if ( queryAccepted!=KErrNone ) |
798 { |
826 { |
799 // cancel |
827 // cancel |
800 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
828 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
801 return KErrCancel; |
829 return KErrCancel; |
802 } |
830 } |
1106 dateFormatString = iAppUi->CoeEnv()->AllocReadResourceLC( |
1141 dateFormatString = iAppUi->CoeEnv()->AllocReadResourceLC( |
1107 R_QTN_DATE_USUAL_WITH_ZERO ); |
1142 R_QTN_DATE_USUAL_WITH_ZERO ); |
1108 // format the date to user readable format. The format is locale dependent |
1143 // format the date to user readable format. The format is locale dependent |
1109 finishValue.FormatL( finishString, *dateFormatString ); |
1144 finishValue.FormatL( finishString, *dateFormatString ); |
1110 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finishString ); |
1145 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finishString ); |
1111 CleanupStack::PopAndDestroy(); // dateFormatString |
1146 CleanupStack::PopAndDestroy(dateFormatString); // dateFormatString |
1112 aMessage.Append( finishString ); |
1147 aMessage.Append( finishString ); |
1113 AddNewlinesToMessage( aMessage ); |
1148 AddNewlinesToMessage( aMessage ); |
1114 } |
1149 } |
1115 |
1150 |
1116 // ---------------------------------------------------------- |
1151 // ---------------------------------------------------------- |
1118 // Adds two new lines to message. |
1153 // Adds two new lines to message. |
1119 // ---------------------------------------------------------- |
1154 // ---------------------------------------------------------- |
1120 // |
1155 // |
1121 void CCertSaverModel::AddNewlinesToMessage( TDes& aMessage ) const |
1156 void CCertSaverModel::AddNewlinesToMessage( TDes& aMessage ) const |
1122 { |
1157 { |
|
1158 |
1123 aMessage.Append( KDoubleEnter ); |
1159 aMessage.Append( KDoubleEnter ); |
1124 } |
1160 } |
1125 |
1161 |
1126 // ---------------------------------------------------------- |
1162 // ---------------------------------------------------------- |
1127 // CCertSaverModel::CertificateSupported() const |
1163 // CCertSaverModel::CertificateSupported() const |
1128 // Checks that cert is of supported type. |
1164 // Checks that cert is of supported type. |
1129 // ---------------------------------------------------------- |
1165 // ---------------------------------------------------------- |
1130 // |
1166 // |
1131 TBool CCertSaverModel::CertificateSupported() const |
1167 TBool CCertSaverModel::CertificateSupported() const |
1132 { |
1168 { |
|
1169 |
1133 if ( iCertFormat == EX509Certificate && |
1170 if ( iCertFormat == EX509Certificate && |
1134 ( iCertOwnerType == ECACertificate || |
1171 ( iCertOwnerType == ECACertificate || |
1135 iCertOwnerType == EPeerCertificate || |
1172 iCertOwnerType == EPeerCertificate || |
1136 iCertOwnerType == EUserCertificate)) |
1173 iCertOwnerType == EUserCertificate)) |
1137 { |
1174 { |
1205 // Creates and shows a confirmation note. |
1245 // Creates and shows a confirmation note. |
1206 // ---------------------------------------------------------- |
1246 // ---------------------------------------------------------- |
1207 // |
1247 // |
1208 void CCertSaverModel::ShowInformationNoteL( TInt aResourceID ) const |
1248 void CCertSaverModel::ShowInformationNoteL( TInt aResourceID ) const |
1209 { |
1249 { |
|
1250 |
1210 HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID ); |
1251 HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID ); |
1211 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue ); |
1252 CHbDeviceMessageBoxSymbian::InformationL(buffer->Des()); |
1212 note->ExecuteLD( buffer->Des() ); |
|
1213 CleanupStack::PopAndDestroy( buffer ); |
1253 CleanupStack::PopAndDestroy( buffer ); |
1214 } |
1254 } |
1215 // ---------------------------------------------------------- |
1255 // ---------------------------------------------------------- |
1216 // CCertSaverModel::ShowConfirmationNoteL() const |
1256 // CCertSaverModel::ShowConfirmationNoteL() const |
1217 // Creates and shows a confirmation note. |
1257 // Creates and shows a confirmation note. |
1218 // ---------------------------------------------------------- |
1258 // ---------------------------------------------------------- |
1219 // |
1259 // |
1220 void CCertSaverModel::ShowConfirmationNoteL( TInt aResourceID ) const |
1260 void CCertSaverModel::ShowConfirmationNoteL( TInt aResourceID ) const |
1221 { |
1261 { |
|
1262 |
1222 HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID ); |
1263 HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID ); |
1223 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue ); |
1264 CHbDeviceMessageBoxSymbian::WarningL(buffer->Des()); |
1224 note->ExecuteLD( buffer->Des() ); |
|
1225 CleanupStack::PopAndDestroy( buffer ); |
1265 CleanupStack::PopAndDestroy( buffer ); |
1226 } |
1266 } |
1227 |
1267 |
1228 // ---------------------------------------------------------- |
1268 // ---------------------------------------------------------- |
1229 // CCertSaverModel::ShowErrorNoteL() const |
1269 // CCertSaverModel::ShowErrorNoteL() const |
1230 // Creates and shows an error note. |
1270 // Creates and shows an error note. |
1231 // ---------------------------------------------------------- |
1271 // ---------------------------------------------------------- |
1232 // |
1272 // |
1233 void CCertSaverModel::ShowErrorNoteL( TInt aResourceID ) const |
1273 void CCertSaverModel::ShowErrorNoteL( TInt aResourceID ) const |
1234 { |
1274 { |
|
1275 |
1235 HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID ); |
1276 HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID ); |
1236 CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue ); |
1277 //TODO: can be changed when hb supports ErrorL |
1237 note->ExecuteLD(buffer->Des()); |
1278 CHbDeviceMessageBoxSymbian::WarningL(buffer->Des()); |
1238 CleanupStack::PopAndDestroy( buffer ); |
1279 CleanupStack::PopAndDestroy( buffer ); |
1239 } |
1280 } |
1240 |
1281 |
1241 // ---------------------------------------------------------- |
1282 // ---------------------------------------------------------- |
1242 // CCertSaverModel::TrimCertificateFields() const |
1283 // CCertSaverModel::TrimCertificateFields() const |
1312 // Does needed tasks to exit. |
1355 // Does needed tasks to exit. |
1313 // ---------------------------------------------------------- |
1356 // ---------------------------------------------------------- |
1314 // |
1357 // |
1315 TInt CCertSaverModel::QueryTrusterUidsL( RArray<TUid>& aUids ) |
1358 TInt CCertSaverModel::QueryTrusterUidsL( RArray<TUid>& aUids ) |
1316 { |
1359 { |
|
1360 |
1317 TInt ret = KErrCancel; |
1361 TInt ret = KErrCancel; |
1318 CArrayFixFlat<TInt>* selectionArray = |
|
1319 new (ELeave) CArrayFixFlat<TInt>( KTrusterArrayInitSize ); |
|
1320 CleanupStack::PushL( selectionArray ); |
|
1321 CDesCArray* itemsArray = new (ELeave) CDesCArrayFlat( KTrusterArrayInitSize ); |
1362 CDesCArray* itemsArray = new (ELeave) CDesCArrayFlat( KTrusterArrayInitSize ); |
1322 CleanupStack::PushL( itemsArray ); |
1363 CleanupStack::PushL( itemsArray ); |
1323 |
1364 |
1324 CCertificateAppInfoManager* appInfoManager = |
1365 CCertificateAppInfoManager* appInfoManager = |
1325 CCertificateAppInfoManager::NewL( iFs, EFalse ); |
1366 CCertificateAppInfoManager::NewL( iFs, EFalse ); |
1328 const RArray<TCertificateAppInfo>& apps = appInfoManager->Applications(); |
1369 const RArray<TCertificateAppInfo>& apps = appInfoManager->Applications(); |
1329 RArray<TCertificateAppInfo> appsInItemArray( KTrusterArrayInitSize ); |
1370 RArray<TCertificateAppInfo> appsInItemArray( KTrusterArrayInitSize ); |
1330 CleanupClosePushL( appsInItemArray ); |
1371 CleanupClosePushL( appsInItemArray ); |
1331 UpdateTrustListboxItemL( apps, appsInItemArray, *itemsArray ); |
1372 UpdateTrustListboxItemL( apps, appsInItemArray, *itemsArray ); |
1332 |
1373 |
1333 CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( selectionArray ); |
1374 HBufC* title = CEikonEnv::Static()->AllocReadResourceLC( R_CERTSAVER_SELECT_TRUSTED_APPS); |
1334 CleanupStack::PushL( dlg ); |
1375 |
1335 dlg->PrepareLC( R_CERTSAVER_TRUST_SETTINGS_QUERY ); |
1376 RBuf rBuf; // buffer for items with big enough space |
1336 dlg->SetItemTextArray( itemsArray ); |
1377 rBuf.CreateL(KMaxLengthTextMeassageBody); |
1337 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
1378 CleanupClosePushL(rBuf); |
1338 if ( dlg->RunLD() ) |
1379 for(TInt i = 0; i<itemsArray->Count(); i++) |
1339 { |
1380 rBuf.Append( (*itemsArray)[i] ); |
1340 for ( TInt i = 0; i < selectionArray->Count(); ++i ) |
1381 |
1341 { |
1382 CSecQueryUi* SecQueryUi = CSecQueryUi::NewL(); |
1342 TInt ii = (*selectionArray)[ i ]; |
1383 TInt saved = SecQueryUi->SecQueryDialog(*title, rBuf,1,KTokenLength, |
1343 aUids.Append( appsInItemArray[ ii ].Id() ); |
1384 ESecUiAlphaSupported | ESecUiCancelSupported | |
1344 } |
1385 ESecUiBasicTypeMultiCheck | |
|
1386 ESecUiEmergencyNotSupported); |
|
1387 delete SecQueryUi; |
|
1388 SecQueryUi=NULL; |
|
1389 |
|
1390 if (saved==KErrNone) |
|
1391 { |
|
1392 TLex16 lex(rBuf); |
|
1393 TChar ch; |
|
1394 TBuf16<KTokenLength> token; |
|
1395 TInt val; |
|
1396 while((ch = lex.Get()) != 0 ){ |
|
1397 while ((ch = lex.Peek()) != '|' && ch!=0) lex.Inc(); |
|
1398 token.Copy(lex.MarkedToken()); |
|
1399 TLex lexc(token); |
|
1400 if(lexc.Val(val)!=KErrNone) val=0; |
|
1401 if(val<=appsInItemArray.Count()-1) |
|
1402 aUids.Append( appsInItemArray[ val ].Id() ); |
|
1403 lex.Inc(); |
|
1404 lex.Mark(); |
|
1405 } |
1345 ret = KErrNone; |
1406 ret = KErrNone; |
1346 } |
1407 } |
1347 else |
1408 else |
1348 { |
1409 { |
1349 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
1410 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
1350 ret = KErrCancel; |
1411 ret = KErrCancel; |
1351 } |
1412 } |
1352 CleanupStack::Pop( dlg ); |
1413 |
1353 CleanupStack::PopAndDestroy( 4, selectionArray ); |
1414 rBuf.Close(); |
|
1415 CleanupStack::PopAndDestroy(&rBuf); |
|
1416 CleanupStack::PopAndDestroy(title); |
|
1417 CleanupStack::PopAndDestroy(&appsInItemArray); |
|
1418 CleanupStack::PopAndDestroy(appInfoManager); |
|
1419 CleanupStack::PopAndDestroy(itemsArray); |
1354 return ret; |
1420 return ret; |
1355 } |
1421 } |
1356 |
1422 |
1357 // ---------------------------------------------------------- |
1423 // ---------------------------------------------------------- |
1358 // CCertSaverModel::QueryTrustedSiteL() |
1424 // CCertSaverModel::QueryTrustedSiteL() |
1359 // Shows query for trusted site certificate |
1425 // Shows query for trusted site certificate |
1360 // ---------------------------------------------------------- |
1426 // ---------------------------------------------------------- |
1361 // |
1427 // |
1362 TInt CCertSaverModel::QueryTrustedSiteL() |
1428 TInt CCertSaverModel::QueryTrustedSiteL() |
1363 { |
1429 { |
|
1430 |
1364 TInt ret = KErrCancel; |
1431 TInt ret = KErrCancel; |
1365 HBufC* label = NULL; |
1432 HBufC* label = NULL; |
1366 HBufC* secondaryName = NULL; |
1433 HBufC* secondaryName = NULL; |
1367 TCertLabel labelBuf; |
1434 TCertLabel labelBuf; |
1368 |
1435 |
1370 (*(CX509Certificate*)iNewCert), label, secondaryName ); |
1437 (*(CX509Certificate*)iNewCert), label, secondaryName ); |
1371 CleanupStack::PushL( label ); |
1438 CleanupStack::PushL( label ); |
1372 delete secondaryName; |
1439 delete secondaryName; |
1373 secondaryName = NULL; |
1440 secondaryName = NULL; |
1374 labelBuf = label->Des().Left( CERTSAVER_MAX_LABEL_LEN ); |
1441 labelBuf = label->Des().Left( CERTSAVER_MAX_LABEL_LEN ); |
1375 |
|
1376 |
|
1377 HBufC* prompt = StringLoader::LoadLC( R_CERTSAVER_TRUSTEDSITE_WARNING, labelBuf ); |
1442 HBufC* prompt = StringLoader::LoadLC( R_CERTSAVER_TRUSTEDSITE_WARNING, labelBuf ); |
1378 |
1443 CHbDeviceMessageBoxSymbian::TButtonId selection = |
1379 CAknMessageQueryDialog* note = CAknMessageQueryDialog::NewL( *prompt ); |
1444 CHbDeviceMessageBoxSymbian::QuestionL(prompt->Des(), KNullDesC, KNullDesC); |
1380 |
1445 if ( selection == CHbDeviceMessageBoxSymbian::EAcceptButton) |
1381 note->PrepareLC( R_CERTSAVER_TRUSTED_SITE_QUERY ); |
|
1382 note->SetPromptL( *prompt ); |
|
1383 |
|
1384 if ( note->RunLD() ) |
|
1385 { |
1446 { |
1386 ret = KErrNone; |
1447 ret = KErrNone; |
1387 } |
1448 } |
1388 else |
1449 else |
1389 { |
1450 { |
1390 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
1451 ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED ); |
1391 ret = KErrCancel; |
1452 ret = KErrCancel; |
1392 } |
1453 } |
1393 |
|
1394 CleanupStack::PopAndDestroy( prompt ); |
1454 CleanupStack::PopAndDestroy( prompt ); |
1395 |
|
1396 CleanupStack::PopAndDestroy( label ); |
1455 CleanupStack::PopAndDestroy( label ); |
1397 return ret; |
1456 return ret; |
1398 } |
1457 } |
1399 |
1458 |
1400 // ---------------------------------------------------------- |
1459 // ---------------------------------------------------------- |
1489 // Saves content of the PKCS#12 file |
1550 // Saves content of the PKCS#12 file |
1490 // ---------------------------------------------------- |
1551 // ---------------------------------------------------- |
1491 // |
1552 // |
1492 void CCertSaverModel::SavePKCS12L() |
1553 void CCertSaverModel::SavePKCS12L() |
1493 { |
1554 { |
|
1555 |
1494 HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody ); |
1556 HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody ); |
1495 TPtr msgPtr = message->Des(); |
1557 TPtr msgPtr = message->Des(); |
1496 ConstructPKCS12QueryMsgL(msgPtr, iParser.Keys().Count(), |
1558 ConstructPKCS12QueryMsgL(msgPtr, iParser.Keys().Count(), |
1497 iParser.UserCertificates().Count(), |
1559 iParser.UserCertificates().Count(), |
1498 iParser.CACertificates().Count() ); |
1560 iParser.CACertificates().Count() ); |
1499 TBool save = DoMessageQueryL( |
1561 |
1500 R_MESSAGE_QUERY_DOSAVE, R_CERTSAVER_HEADER_PKCS12_FILE_CONTAINS, |
1562 //TODO: Should be in loc file but hardcoded now |
1501 *message ); |
1563 _LIT(KCheckBoxCaption,"Protect with Password|1"); |
1502 CleanupStack::PopAndDestroy( message ); |
1564 TBuf<KMaxLengthTextCheckBoxData> CheckeBoxData(KCheckBoxCaption); |
|
1565 |
|
1566 CSecQueryUi* SecQueryUi = CSecQueryUi::NewL(); |
|
1567 TInt save = SecQueryUi->SecQueryDialog(*message, CheckeBoxData,1,1, |
|
1568 ESecUiAlphaSupported | ESecUiCancelSupported | |
|
1569 ESecUiBasicTypeCheck | ESecUiEmergencyNotSupported); |
|
1570 CleanupStack::Pop(message); |
1503 message = NULL; |
1571 message = NULL; |
1504 if ( !save ) |
1572 delete SecQueryUi; |
|
1573 SecQueryUi=NULL; |
|
1574 |
|
1575 if ( save!=KErrNone ) |
1505 { |
1576 { |
1506 ShowInformationNoteL( R_CERTSAVER_PKCS12_DISCARDED ); |
1577 ShowInformationNoteL( R_CERTSAVER_PKCS12_DISCARDED ); |
1507 User::Leave( KErrExitApp ); |
1578 User::Leave( KErrExitApp ); |
1508 } |
1579 } |
1509 TInt status = KErrNone; |
1580 TInt status = KErrNone; |
1543 } |
1614 } |
1544 } |
1615 } |
1545 if ( iSavedCACertsCount != 0 || iSavedKeysCount != 0 |
1616 if ( iSavedCACertsCount != 0 || iSavedKeysCount != 0 |
1546 || iSavedUserCertsCount != 0 ) |
1617 || iSavedUserCertsCount != 0 ) |
1547 { |
1618 { |
|
1619 HBufC* p = StringLoader::LoadLC( R_CERTSAVER_HEADER_SAVED ); |
1548 message = HBufC::NewLC( KMaxLengthTextMeassageBody ); |
1620 message = HBufC::NewLC( KMaxLengthTextMeassageBody ); |
|
1621 message->Des().Append(p->Des()); |
1549 TPtr msgPtr2 = message->Des(); |
1622 TPtr msgPtr2 = message->Des(); |
1550 ConstructPKCS12QueryMsgL( |
1623 ConstructPKCS12QueryMsgL( |
1551 msgPtr2, iSavedKeysCount, iSavedUserCertsCount, iSavedCACertsCount ); |
1624 msgPtr2, iSavedKeysCount, iSavedUserCertsCount, iSavedCACertsCount ); |
1552 DoMessageQueryL( |
1625 CHbDeviceMessageBoxSymbian::InformationL(message->Des()); |
1553 R_MESSAGE_QUERY_SAVED, R_CERTSAVER_HEADER_SAVED, *message ); |
|
1554 CleanupStack::PopAndDestroy( message ); |
1626 CleanupStack::PopAndDestroy( message ); |
|
1627 CleanupStack::PopAndDestroy( p ); |
1555 } |
1628 } |
1556 else |
1629 else |
1557 { |
1630 { |
1558 ShowInformationNoteL( R_QTN_CM_PKCS12_SAVING_FAILED ); |
1631 ShowInformationNoteL( R_QTN_CM_PKCS12_SAVING_FAILED ); |
1559 } |
1632 CleanupStack::PopAndDestroy( message ); |
1560 } |
1633 } |
1561 |
|
1562 // ---------------------------------------------------------- |
|
1563 // CCertSaverModel::DoMessageQuery() |
|
1564 // Displays message query dialog for user. |
|
1565 // ---------------------------------------------------------- |
|
1566 // |
|
1567 TBool CCertSaverModel::DoMessageQueryL( |
|
1568 TInt aDialogResId, |
|
1569 TInt aHeadingResId, |
|
1570 TDesC& aMessage ) |
|
1571 { |
|
1572 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( aMessage ); |
|
1573 CleanupStack::PushL( dlg ); |
|
1574 dlg->PrepareLC( aDialogResId ); |
|
1575 |
|
1576 HBufC* header = StringLoader::LoadLC( aHeadingResId ); |
|
1577 dlg->QueryHeading()->SetTextL( header->Des() ); |
|
1578 CleanupStack::PopAndDestroy( header ); |
|
1579 CleanupStack::Pop( dlg ); |
|
1580 return dlg->RunLD(); |
|
1581 } |
1634 } |
1582 |
1635 |
1583 // ---------------------------------------------------------- |
1636 // ---------------------------------------------------------- |
1584 // CCertSaverModel::ConstructPKCS12QueryMsgL() const |
1637 // CCertSaverModel::ConstructPKCS12QueryMsgL() const |
1585 // Creates the certificate details message shown to the user. |
1638 // Creates the certificate details message shown to the user. |