policymanagement/policyengine/policyengineserver/src/PolicyProcessor.cpp
changeset 73 ae69c2e8bc34
parent 66 08c8318ec9cb
equal deleted inserted replaced
71:d2517372cc44 73:ae69c2e8bc34
   179         {       
   179         {       
   180         return KErrInUse;    
   180         return KErrInUse;    
   181         }
   181         }
   182     
   182     
   183     iStore = CCertStore::NewL();
   183     iStore = CCertStore::NewL();
   184     iStore->InitializeCertStore();
   184     iStore->InitializeCertStoreL();
   185     TInt res = iStore->AddCert(iCertBuffer);
   185     TInt res = iStore->AddCert(iCertBuffer);
   186     if(res == KErrNone)
   186     if(res == KErrNone)
   187         {        
   187         {        
   188         //update the new counter value in CR
   188         //update the new counter value in CR
   189         iStore->UpdateLabelCounterInCR();  
   189         iStore->UpdateLabelCounterInCR();  
   221        {
   221        {
   222        delete iStore;
   222        delete iStore;
   223        iStore = NULL;
   223        iStore = NULL;
   224        }
   224        }
   225     iStore = CCertStore::NewL();
   225     iStore = CCertStore::NewL();
   226     iStore->InitializeCertStore();    
   226     iStore->InitializeCertStoreL();    
   227     
   227     
   228     TInt res;
   228     TInt res;
   229     if(label->Des() == KNullDesC)
   229     if(label->Des() == KNullDesC)
   230         {
   230         {
   231         // If NULL is passed for removing label then remove the current label
   231         // If NULL is passed for removing label then remove the current label
   516 				}
   516 				}
   517 
   517 
   518 				CAttribute * attribute = CAttribute::NewL( aAttributeId, 
   518 				CAttribute * attribute = CAttribute::NewL( aAttributeId, 
   519 													   aAttributeValue, 
   519 													   aAttributeValue, 
   520 													   aDataType);
   520 													   aDataType);
   521 			
   521 				CleanupStack::PushL(attribute);
   522 				//append attribute to attribute list
   522 				//append attribute to attribute list
   523 				list->AppendL( attribute);
   523 				list->AppendL( attribute);
       
   524 				CleanupStack::Pop(attribute);
   524 			}
   525 			}
   525 		}
   526 		}
   526 
   527 
   527 		iProcessorState++;		
   528 		iProcessorState++;		
   528 		SetActive();
   529 		SetActive();
   890     return counter;
   891     return counter;
   891     }
   892     }
   892 
   893 
   893 
   894 
   894 // -----------------------------------------------------------------------------
   895 // -----------------------------------------------------------------------------
   895 // CPolicyProcessor::UpdateSilentTrustServerId()
   896 // CPolicyProcessor::UpdateSilentTrustServerIdL()
   896 // -----------------------------------------------------------------------------
   897 // -----------------------------------------------------------------------------
   897 //
   898 //
   898 void CPolicyProcessor::UpdateSilentTrustServerId()
   899 void CPolicyProcessor::UpdateSilentTrustServerIdL()
   899     { 
   900     { 
   900     RDEBUG("CPolicyProcessor::UpdateSilentTrustServerId" );
   901     RDEBUG("CPolicyProcessor::UpdateSilentTrustServerId" );
   901     //get server id and store in cenrep
   902     //get server id and store in cenrep
   902     //connect to DM util client...
   903     //connect to DM util client...
   903     RDMUtil dmutil;
   904     RDMUtil dmutil;
   904     dmutil.Connect();
   905     User::LeaveIfError(dmutil.Connect());
   905     CleanupClosePushL( dmutil);
   906     CleanupClosePushL( dmutil);
   906     
   907     
   907     //..and get server id
   908     //..and get server id
   908     TBuf8<KMaxServerIdLength> serverid;
   909     TBuf8<KMaxServerIdLength> serverid;
   909     dmutil.GetDMSessionServerId( serverid);
   910     dmutil.GetDMSessionServerId( serverid);
   910     CleanupStack::PopAndDestroy( &dmutil); 
   911     CleanupStack::PopAndDestroy( &dmutil); 
   911     
   912     
   912     TInt ret;
   913     CRepository* rep = CRepository::NewL( KCRUidPolicyManagementUtilInternalKeys );
   913     TRAPD( err, 
   914     CleanupStack::PushL( rep );
   914       {
   915     rep->Set( KTrustedServerId, serverid );
   915         CRepository* rep = CRepository::NewL( KCRUidPolicyManagementUtilInternalKeys );
   916     CleanupStack::PopAndDestroy( rep );
   916         CleanupStack::PushL( rep );
       
   917         ret = rep->Set( KTrustedServerId, serverid );
       
   918         CleanupStack::PopAndDestroy( rep );
       
   919       } );
       
   920 
       
   921     }
   917     }
   922 
   918 
   923 // -----------------------------------------------------------------------------
   919 // -----------------------------------------------------------------------------
   924 // CPolicyProcessor::CorporateUserAcceptFunctionL()
   920 // CPolicyProcessor::CorporateUserAcceptFunctionL()
   925 // -----------------------------------------------------------------------------
   921 // -----------------------------------------------------------------------------
   959                 {
   955                 {
   960                 delete iStore;
   956                 delete iStore;
   961                 iStore = NULL;
   957                 iStore = NULL;
   962                 }
   958                 }
   963         iStore = CCertStore::NewL();
   959         iStore = CCertStore::NewL();
   964         iStore->InitializeCertStore();
   960         iStore->InitializeCertStoreL();
   965         HBufC* certLabel = iStore->GetCurrentCertLabel();       
   961         HBufC* certLabel = iStore->GetCurrentCertLabel();       
   966         const TDesC8& fingerPrintSilent = iStore->RetrieveCertFPrint(*certLabel);      
   962         const TDesC8& fingerPrintSilent = iStore->RetrieveCertFPrint(*certLabel);      
   967         
   963         
   968         // Compare the fingerprints of cert stored with received from server  
   964         // Compare the fingerprints of cert stored with received from server  
   969         TInt result = fingerPrintSilent.Compare(fingerPrint); 
   965         TInt result = fingerPrintSilent.Compare(fingerPrint); 
   970         RDEBUG_2("CorporateUserAcceptFunction FP Match ( %d )", result ); 
   966         RDEBUG_2("CorporateUserAcceptFunction FP Match ( %d )", result ); 
   971         
   967         
   972         if(result==KErrNone)
   968         if(result==KErrNone)
   973             {
   969             {
   974             UpdateSilentTrustServerId();
   970             UpdateSilentTrustServerIdL();
   975             response = EUserAccept;
   971             response = EUserAccept;
   976             showUserScreen = EFalse;
   972             showUserScreen = EFalse;
   977             
   973             
   978             // call device dialog to show notification                
   974             // call device dialog to show notification                
   979             _LIT(KDialogText, "Silent Trust Done!");
   975             _LIT(KDialogText, "Silent Trust Done!");
   991         }
   987         }
   992 
   988 
   993     if(showUserScreen)
   989     if(showUserScreen)
   994         {       
   990         {       
   995         CProcessorClient *client = new CProcessorClient();
   991         CProcessorClient *client = new CProcessorClient();
       
   992         CleanupStack::PushL(client);
   996         TInt res = client->LaunchDialog(ptr, name);
   993         TInt res = client->LaunchDialog(ptr, name);
   997         
   994         
   998         if(res == 0)
   995         if(res == 0)
   999             response = EUserAccept;
   996             response = EUserAccept;
  1000         else
   997         else
  1001             response = EUserDeny; 
   998             response = EUserDeny; 
  1002         }
   999         }
  1003 
  1000 
  1004 
  1001 
  1005 	MakeBooleanResponseL( response == EUserAccept, aResponseElement);
  1002 	MakeBooleanResponseL( response == EUserAccept, aResponseElement);
       
  1003 	if(showUserScreen)
       
  1004         {
       
  1005 			CleanupStack::Pop(); // client    
       
  1006         }
  1006 }
  1007 }
  1007 
  1008 
  1008 // -----------------------------------------------------------------------------
  1009 // -----------------------------------------------------------------------------
  1009 // CPolicyProcessor::OrFunctionL()
  1010 // CPolicyProcessor::OrFunctionL()
  1010 // -----------------------------------------------------------------------------
  1011 // -----------------------------------------------------------------------------
  1292     RDEBUG_2("CPolicyProcessor::16 fingerPrint: %S", &fingerBuf);
  1293     RDEBUG_2("CPolicyProcessor::16 fingerPrint: %S", &fingerBuf);
  1293     RDEBUG_2("CPolicyProcessor::16 serverName : %S", &serverName);
  1294     RDEBUG_2("CPolicyProcessor::16 serverName : %S", &serverName);
  1294 
  1295 
  1295     CHbSymbianVariant* fingerprintid = CHbSymbianVariant::NewL(&fingerBuf,
  1296     CHbSymbianVariant* fingerprintid = CHbSymbianVariant::NewL(&fingerBuf,
  1296             CHbSymbianVariant::EDes);
  1297             CHbSymbianVariant::EDes);
  1297 
  1298 		CleanupStack::PushL(fingerprintid);
       
  1299 			
  1298     CHbSymbianVariant* serverdisplayname = CHbSymbianVariant::NewL(
  1300     CHbSymbianVariant* serverdisplayname = CHbSymbianVariant::NewL(
  1299             &serverName, CHbSymbianVariant::EDes);
  1301             &serverName, CHbSymbianVariant::EDes);
  1300 
  1302 		CleanupStack::PushL(serverdisplayname);
       
  1303 			
  1301     RDEBUG_2("CPolicyProcessor::fingerPrint: %S", &fingerprintid);
  1304     RDEBUG_2("CPolicyProcessor::fingerPrint: %S", &fingerprintid);
  1302     RDEBUG_2("CPolicyProcessor::fingerPrint: %S", &serverdisplayname);
  1305     RDEBUG_2("CPolicyProcessor::fingerPrint: %S", &serverdisplayname);
  1303 
  1306 
  1304     varMap->Add(KFingerPrint, fingerprintid);
  1307     varMap->Add(KFingerPrint, fingerprintid);
  1305     varMap->Add(KServerdisplayname, serverdisplayname);
  1308     varMap->Add(KServerdisplayname, serverdisplayname);
  1306 
  1309 
  1307     iDevDialog = CHbDeviceDialogSymbian::NewL();
  1310     iDevDialog = CHbDeviceDialogSymbian::NewL();
  1308     TInt err1 = iDevDialog->Show(KHbNotifier, *varMap, this);
  1311     TInt err1 = iDevDialog->Show(KHbNotifier, *varMap, this);
  1309     TInt err = WaitUntilDeviceDialogClosed();
  1312     TInt err = WaitUntilDeviceDialogClosed();
  1310 
  1313 
       
  1314 		CleanupStack::Pop(serverdisplayname);
       
  1315 		CleanupStack::Pop(fingerprintid);
  1311     CleanupStack::PopAndDestroy();
  1316     CleanupStack::PopAndDestroy();
  1312 
  1317 
  1313     if (iDevDialog)
  1318     if (iDevDialog)
  1314         {
  1319         {
  1315         iDevDialog->Cancel();
  1320         iDevDialog->Cancel();
  1641     iCertLabel = NULL;    
  1646     iCertLabel = NULL;    
  1642     delete iCertBuffer;
  1647     delete iCertBuffer;
  1643     iCertBuffer = NULL;    
  1648     iCertBuffer = NULL;    
  1644     delete iCertStore;
  1649     delete iCertStore;
  1645     iCertStore = NULL;
  1650     iCertStore = NULL;
       
  1651     
       
  1652     
       
  1653     if (iFs.Handle())
       
  1654     	iFs.Close();
  1646   
  1655   
  1647     }
  1656     }
  1648 
  1657 
  1649 CCertStore* CCertStore::NewL()
  1658 CCertStore* CCertStore::NewL()
  1650     { 
  1659     { 
  1656     CleanupStack::Pop();
  1665     CleanupStack::Pop();
  1657     return self;    
  1666     return self;    
  1658     }
  1667     }
  1659 
  1668 
  1660 
  1669 
  1661 void CCertStore::InitializeCertStore()
  1670 void CCertStore::InitializeCertStoreL()
  1662     {
  1671     {
  1663     RDEBUG("CCertStore::InitializeCertStore");
  1672     RDEBUG("CCertStore::InitializeCertStoreL");
  1664     if(iCertStore == NULL)
  1673     if(iCertStore == NULL)
  1665         {
  1674         {
  1666         RFs* fs = new RFs();
  1675         User::LeaveIfError(iFs.Connect());
  1667         fs->Connect();
  1676         iCertStore = CUnifiedCertStore::NewL(iFs, ETrue);         
  1668         iCertStore = CUnifiedCertStore::NewL(*fs, ETrue);         
       
  1669          
  1677          
  1670         iCertStore->Initialize(iStatus);
  1678         iCertStore->Initialize(iStatus);
  1671         iCertState = EInitializeStore;    
  1679         iCertState = EInitializeStore;    
  1672        
  1680        
  1673         SetActive();   
  1681         SetActive();