terminalsecurity/SCP/SCPServer/src/SCPSession.cpp
branchRCL_3
changeset 27 5cc2995847ea
parent 26 19bba8228ff0
equal deleted inserted replaced
26:19bba8228ff0 27:5cc2995847ea
    48 #include <featmgr.h>
    48 #include <featmgr.h>
    49 #include "SCPDebug.h"
    49 #include "SCPDebug.h"
    50 #include <TerminalControl3rdPartyAPI.h>
    50 #include <TerminalControl3rdPartyAPI.h>
    51 #include <TerminalControl3rdPartyParamsPlugin.h>
    51 #include <TerminalControl3rdPartyParamsPlugin.h>
    52 #include <utf.h>
    52 #include <utf.h>
       
    53 
       
    54 #include <PolicyEngineXACML.h>
    53 // ================= MEMBER FUNCTIONS =======================
    55 // ================= MEMBER FUNCTIONS =======================
    54 
    56 
    55 // C++ default constructor can NOT contain any code, that
    57 // C++ default constructor can NOT contain any code, that
    56 // might leave.
    58 // might leave.
    57 //
    59 //
    67 	}
    69 	}
    68 
    70 
    69 // Symbian 2nd phase constructor can leave.
    71 // Symbian 2nd phase constructor can leave.
    70 void CSCPSession::ConstructL()
    72 void CSCPSession::ConstructL()
    71     {
    73     {
       
    74     User::LeaveIfError( iPE.Connect() );
       
    75     User::LeaveIfError( iPR.Open( iPE ) );
    72     iServer.SessionOpened();
    76     iServer.SessionOpened();
    73     }
    77     }
    74 
    78 
    75 // Static constructor.
    79 // Static constructor.
    76 CSCPSession* CSCPSession::NewL( CSCPServer& aServer )
    80 CSCPSession* CSCPSession::NewL( CSCPServer& aServer )
   111     
   115     
   112     iServer.SessionClosed();
   116     iServer.SessionClosed();
   113     if(iALParamValue) {
   117     if(iALParamValue) {
   114 		delete iALParamValue;		
   118 		delete iALParamValue;		
   115     }
   119     }
   116         
   120     iPR.Close();
       
   121 	iPE.Close();    
   117     Dprint( (_L("<-- CSCPSession::~CSCPSession()")) );   
   122     Dprint( (_L("<-- CSCPSession::~CSCPSession()")) );   
   118     }
   123     }
   119 
   124 
   120 
   125 
   121 
   126 
   849 		FeatureManager::UnInitializeLib();
   854 		FeatureManager::UnInitializeLib();
   850 		User::Leave(KErrNotSupported);
   855 		User::Leave(KErrNotSupported);
   851 	}
   856 	}
   852     
   857     
   853     TSecureId id = aMessage.SecureId();
   858     TSecureId id = aMessage.SecureId();
   854 	
   859     TBool hasAllFilesCap = aMessage.HasCapability(ECapabilityAllFiles);
       
   860     TBool hasDiskAdminCap = aMessage.HasCapability(ECapabilityDiskAdmin);
       
   861     
   855     switch(id.iId) {
   862     switch(id.iId) {
   856         case KSCPServerSIDAutolock:
   863         case KSCPServerSIDAutolock:
   857         case KAknNfySrvUid:
   864         case KAknNfySrvUid:
   858         case KSCPServerSIDGeneralSettings:
   865         case KSCPServerSIDGeneralSettings:
   859         case KSCPServerSIDSysAp:
   866         case KSCPServerSIDSysAp:
   860         case KSCPServerSIDTerminalControl:
   867         case KSCPServerSIDTerminalControl:
   861         case KSCPServerSIDTelephone:
   868         case KSCPServerSIDTelephone:
   862         case KSCPServerSIDLog:
   869         case KSCPServerSIDLog:
       
   870             {
       
   871             Dprint( (_L("[CSCPSession]-> fixed sid's") ));
   863             break;
   872             break;
       
   873             }
   864         default: {
   874         default: {
       
   875         TInt retVal = CheckTerminalControl3rdPartySecureIDL(id);
       
   876         Dprint(_L("[CSCPSession]->CheckTerminalControl3rdPartySecureIDL retval %d"), retVal);
       
   877         if(((retVal==KErrNone)&&(hasDiskAdminCap))||(hasAllFilesCap))
       
   878             {
       
   879             Dprint( (_L("[CSCPSession]-> sid is 3rd party or has AllFiles") ));
       
   880             break;
       
   881             }
       
   882         else
       
   883             {
   865             Dprint( (_L("[CSCPSession]-> ERROR: Permission denied") ));
   884             Dprint( (_L("[CSCPSession]-> ERROR: Permission denied") ));
   866         User::Leave( KErrPermissionDenied );
   885             User::Leave( KErrPermissionDenied );
       
   886             }
   867         }
   887         }
   868     };
   888     };
   869 	
   889 	
   870     Dprint( (_L("--> CSCPSession::HandleAuthenticationMessage()") ));
   890     Dprint( (_L("--> CSCPSession::HandleAuthenticationMessage()") ));
   871     
   891     
  1678 	Dprint(_L("[CSCPSession]->INFO: Initiating notification to all the StakeHolders..."));
  1698 	Dprint(_L("[CSCPSession]->INFO: Initiating notification to all the StakeHolders..."));
  1679 	TRAPD(lErr, NotifyAllStakeHoldersL(lChangeArray, aCallerID));
  1699 	TRAPD(lErr, NotifyAllStakeHoldersL(lChangeArray, aCallerID));
  1680 	Dprint(_L("[CSCPSession]->INFO: Notification to all the StakeHolders complete..."));
  1700 	Dprint(_L("[CSCPSession]->INFO: Notification to all the StakeHolders complete..."));
  1681 	CleanupStack :: PopAndDestroy(); //lChangeArray
  1701 	CleanupStack :: PopAndDestroy(); //lChangeArray
  1682 }
  1702 }
       
  1703 // -------------------------------------------------------------------------------------
       
  1704 // CTcTrustedSession::CheckTerminalControl3rdPartySecureIDL
       
  1705 // -------------------------------------------------------------------------------------   
       
  1706 TInt CSCPSession::CheckTerminalControl3rdPartySecureIDL(TSecureId aId)
       
  1707     {
       
  1708     Dprint(_L("TerminalControl: [CSCPSession]CheckTerminalControl3rdPartySecureIDL"));    
       
  1709     TRequestContext context;
       
  1710     TResponse response;
       
  1711     TUid secureId = TUid::Uid(aId.iId);
       
  1712     context.AddSubjectAttributeL(
       
  1713         PolicyEngineXACML::KSubjectId, secureId
       
  1714         );
       
  1715     context.AddResourceAttributeL(
       
  1716         PolicyEngineXACML::KResourceId,
       
  1717         PolicyEngineXACML::KThirdPartySecureIds,
       
  1718         PolicyEngineXACML::KStringDataType
       
  1719         );
       
  1720     User::LeaveIfError( iPR.MakeRequest( context, response ) );
       
  1721     TResponseValue resp = response.GetResponseValue();
       
  1722     Dprint(_L("[CSCPSession]->CheckTerminalControl3rdPartySecureIDL Policy check returned %d"), (TInt)resp);
       
  1723     switch( resp )
       
  1724         {
       
  1725         case EResponsePermit:
       
  1726             return KErrNone;
       
  1727         case EResponseDeny:
       
  1728             case EResponseIndeterminate:
       
  1729             case EResponseNotApplicable:
       
  1730             default:
       
  1731                 User::Leave( KErrAccessDenied );
       
  1732         }
       
  1733         
       
  1734       return KErrAccessDenied;
       
  1735     }