cryptoservices/filebasedcertificateandkeystores/test/certtool/certtool_import.cpp
changeset 29 ece3df019add
parent 8 35751d3474b7
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
    52 	delete iCertData;	
    52 	delete iCertData;	
    53 	}
    53 	}
    54 
    54 
    55 void CCertToolAdd::ConstructL()
    55 void CCertToolAdd::ConstructL()
    56 	{
    56 	{
    57 
    57 	//The Certificate added is deletable by default.
       
    58 	iIsDeletable = ETrue;
    58 	}
    59 	}
    59 
    60 
    60 
    61 
    61 TCertificateFormat CCertToolAdd::DoRecognizeL(const TDesC8& iData)
    62 TCertificateFormat CCertToolAdd::DoRecognizeL(const TDesC8& iData)
    62 	{
    63 	{
   150 
   151 
   151 		// Use the recognizer to see what kind of certificate we have!
   152 		// Use the recognizer to see what kind of certificate we have!
   152 		TCertificateFormat format = DoRecognizeL(*iCertData);
   153 		TCertificateFormat format = DoRecognizeL(*iCertData);
   153 						
   154 						
   154 		iState = EIntermediate;
   155 		iState = EIntermediate;
       
   156 		
       
   157 		/**
       
   158 		 * If the iIsDeletable variable of iParams is set, parse its value
       
   159 		 * and set the iIsDeletable flag appropriately.
       
   160 		 */
       
   161 		if(iParams->iIsDeletable)
       
   162 		    {
       
   163 		    HBufC* lowerCaseString = HBufC::NewLC(iParams->iIsDeletable->Length());
       
   164 		    TPtr ptr(lowerCaseString->Des());
       
   165 		    
       
   166 		    //Convert to lower case.
       
   167 		    ptr.CopyLC(*iParams->iIsDeletable);
       
   168 		    
       
   169 		    if(ptr.CompareF(_L("n")) == 0 || ptr.CompareF(_L("no")) == 0 )
       
   170 		        {
       
   171 		        iIsDeletable = EFalse;
       
   172 		        }
       
   173             else if (ptr.CompareF(_L("y")) != 0  && ptr.CompareF(_L("yes")) != 0)
       
   174                 {
       
   175                 //Wrong value passed.
       
   176                 User::Leave(KErrArgument);     
       
   177                 }
       
   178 
       
   179 		    CleanupStack::PopAndDestroy(lowerCaseString);            
       
   180 		    }
   155 
   181 
   156 		SetActive();
   182 		SetActive();
   157 		//wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iStatus);
   183 		//wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iStatus);
   158 		wCertStore.Add(*iParams->iLabel, format, EUserCertificate, NULL, NULL, *iCertData, iStatus);
   184 		wCertStore.Add(*iParams->iLabel, format, EUserCertificate, NULL, NULL, *iCertData, iIsDeletable, iStatus);
   159 		CleanupStack::PopAndDestroy(2, &fs);
   185 		CleanupStack::PopAndDestroy(2, &fs);
   160 	}
   186 	}
   161 
   187 
   162 
   188 
   163 void CCertToolAdd::RunL()
   189 void CCertToolAdd::RunL()
   176 				// Not an user certificate add as root!
   202 				// Not an user certificate add as root!
   177 				iState = EFinish;
   203 				iState = EFinish;
   178 				MCTWritableCertStore& wCertStore = iCertStore->WritableCertStore(iParams->iCertstoreIndex);
   204 				MCTWritableCertStore& wCertStore = iCertStore->WritableCertStore(iParams->iCertstoreIndex);
   179 				TCertificateFormat format = DoRecognizeL(*iCertData);
   205 				TCertificateFormat format = DoRecognizeL(*iCertData);
   180 				SetActive();				
   206 				SetActive();				
   181 				wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iStatus);				
   207 				wCertStore.Add(*iParams->iLabel, format, ECACertificate, NULL, NULL, *iCertData, iIsDeletable, iStatus);				
   182 				}
   208 				}
   183 			else 
   209 			else 
   184 				{
   210 				{
   185 				iController->DisplayLocalisedMsgL(R_CERTTOOL_ERR_IMPORTSUCCESS);			
   211 				iController->DisplayLocalisedMsgL(R_CERTTOOL_ERR_IMPORTSUCCESS);			
   186 				CActiveScheduler::Stop();				
   212 				CActiveScheduler::Stop();