vpnengine/pkiservice/src/pkisupport.cpp
branchRCL_3
changeset 49 5960d2d03390
parent 41 e06095241a65
equal deleted inserted replaced
46:29c8f9bc68e1 49:5960d2d03390
     1 /*
     1 /*
     2 * Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   261                                                       (TPKICertificateOwnerType)currentCertInfo->CertificateOwnerType(),
   261                                                       (TPKICertificateOwnerType)currentCertInfo->CertificateOwnerType(),
   262                                                       storeType);  
   262                                                       storeType);  
   263     CleanupStack::PushL(newMapping);
   263     CleanupStack::PushL(newMapping);
   264     
   264     
   265     newMapping->SetMapDeletable(currentCertInfo->IsDeletable());
   265     newMapping->SetMapDeletable(currentCertInfo->IsDeletable());
   266     newMapping->SetMapApplicationsL(iApplUids);
   266     newMapping->SetMapApplications(iApplUids);
   267     iApplUids.Reset();
   267     iApplUids.Reset();
   268     User::LeaveIfError(iMapper.AddMapping(newMapping));
   268     User::LeaveIfError(iMapper.AddMapping(newMapping));
   269             
   269             
   270     CleanupStack::Pop(newMapping);
   270     CleanupStack::Pop(newMapping);
   271     CleanupStack::PopAndDestroy(certificate);
   271     CleanupStack::PopAndDestroy(certificate);
   431     
   431     
   432     iSupportStatus = iStatus.Int();
   432     iSupportStatus = iStatus.Int();
   433 	if((iSupportStatus == KErrNotSupported) && 
   433 	if((iSupportStatus == KErrNotSupported) && 
   434 	    iToggleSwitch && (iInitState == EInitCompleteImportCerts))
   434 	    iToggleSwitch && (iInitState == EInitCompleteImportCerts))
   435 		{
   435 		{
   436 		// Some implementations of "Java Trust Root" certstore return KErrNotSupported
   436 		// Some implementations of MIDP2 certstore return KErrNotSupported
   437 		// when calling iCertStore->Applications()
   437 		// when calling iCertStore->Applications()
   438 		LOG_1("CPKISupport::RunL ignore error :%d", iSupportStatus);
   438 		LOG_1("CPKISupport::RunL ignore error :%d", iSupportStatus);
   439 		iSupportStatus = KErrNone;		
   439 		iSupportStatus = KErrNone;		
   440 		}
   440 		}
   441 		
   441 		
   765 
   765 
   766 
   766 
   767 /**
   767 /**
   768     Removes all unnecessary certificates from the certificate
   768     Removes all unnecessary certificates from the certificate
   769     list before generating the local mapping data.
   769     list before generating the local mapping data.
   770     More specifically, all "Java Trust Root" and non X509 certificates are removed.
   770     More specifically, all MIDP2 and non X509 certificates are removed.
   771     ("Java Trust Root" certificates can never have a "VPN" trust setting.)
   771     (MIDP2 certificates can never have a "VPN" trust setting.)
   772     
   772     
   773     iListCleaned instance variable is used to limit the frequency
   773     iListCleaned instance variable is used to limit the frequency
   774     of this cleanup - it's only necessary once, during PKI startup.
   774     of this cleanup - it's only necessary once, during PKI startup.
   775 */
   775 */
   776 void CPKISupport::CleanupCertListL() 
   776 void CPKISupport::CleanupCertListL() 
   777     {
   777     {
   778     LOG_("Removing invalid certs (\"Java Trust Root\" certs)");
   778     LOG_("Removing invalid certs (MIDP2 certs)");
   779 
   779 
   780     TInt certcount = iCerts.Count();
   780     TInt certcount = iCerts.Count();
   781     _LIT(KJavaTrustRootLabel, "Java Trust Root");
   781     _LIT(KMidp2Label, "MIDP2");
   782     LOG_1("Total cert count, before cleanup: %d", iCerts.Count());
   782     LOG_1("Total cert count, before cleanup: %d", iCerts.Count());
   783     RMPointerArray<CCTCertInfo> removedInfos;
   783     RMPointerArray<CCTCertInfo> removedInfos;
   784     CleanupClosePushL(removedInfos);
   784     CleanupClosePushL(removedInfos);
   785     for (TInt i = certcount - 1; i >= 0; i--) 
   785     for (TInt i = certcount - 1; i >= 0; i--) 
   786         {
   786         {
   787         CCTCertInfo* info = iCerts[i];
   787         CCTCertInfo* info = iCerts[i];
   788         if (info->Label().Compare(KJavaTrustRootLabel) == 0 ||
   788         if (info->Label().Compare(KMidp2Label) == 0 ||
   789             info->CertificateFormat() != EX509Certificate) 
   789             info->CertificateFormat() != EX509Certificate) 
   790             {
   790             {
   791             // CCTCertInfo has private destructor
   791             // CCTCertInfo has private destructor
   792             removedInfos.AppendL( info );
   792             removedInfos.AppendL( info );
   793             iCerts.Remove(i);
   793             iCerts.Remove(i);
   831                 ListAllCertificatesL();
   831                 ListAllCertificatesL();
   832                 }
   832                 }
   833             break;
   833             break;
   834         case EInitRetrieveCertList:
   834         case EInitRetrieveCertList:
   835             LOG_("CPKISupport::DoRunOperationL() EInitRetrieveCertList");
   835             LOG_("CPKISupport::DoRunOperationL() EInitRetrieveCertList");
   836             // Cert list might be new. Remove all "Java Trust Root" certificates first,
   836             // Cert list might be new. Remove all MIDP2 certificates first,
   837             // if it hasn't been already done
   837             // if it hasn't been already done
   838             CleanupCertListL();
   838             CleanupCertListL();
   839             iInitState = EInitCompleteImportCerts;
   839             iInitState = EInitCompleteImportCerts;
   840             if(iImportCounter < iCerts.Count())
   840             if(iImportCounter < iCerts.Count())
   841                 {
   841                 {
  1017                     break;
  1017                     break;
  1018                     }
  1018                     }
  1019                 case ESSComplete:
  1019                 case ESSComplete:
  1020                     if(iCurrentFunction == PkiService::EApplications)
  1020                     if(iCurrentFunction == PkiService::EApplications)
  1021                         {
  1021                         {
  1022                         iWrapper.SetApplicationsL(iApplUids);
  1022                         iWrapper.SetApplications(iApplUids);
  1023                         }
  1023                         }
  1024                             
  1024                             
  1025                     iSubState = ESSCompleteRequest;
  1025                     iSubState = ESSCompleteRequest;
  1026                     break;
  1026                     break;
  1027                 default:
  1027                 default:
  1160     iCerts.Close();
  1160     iCerts.Close();
  1161     iSubState = ESSContinue;
  1161     iSubState = ESSContinue;
  1162 	iApplUids.Close();
  1162 	iApplUids.Close();
  1163 	for(TInt i = 0;i<aApplUids.Count();i++)
  1163 	for(TInt i = 0;i<aApplUids.Count();i++)
  1164 		{
  1164 		{
  1165 		iApplUids.AppendL(aApplUids[i]);
  1165 		iApplUids.Append(aApplUids[i]);
  1166 		}
  1166 		}
  1167     SetCallerStatusPending( aStatus );
  1167     SetCallerStatusPending( aStatus );
  1168     SelectCertificateL(aLabel);
  1168     SelectCertificateL(aLabel);
  1169 }
  1169 }
  1170 
  1170