rtsecuritymanager/rtsecuritymanagerserver/inc/rtsecmgrscriptmanager.h
changeset 57 61b27eec6533
parent 45 7aa6007702af
equal deleted inserted replaced
45:7aa6007702af 57:61b27eec6533
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:       Definition of script manager class
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef C_RTSECMGRSCRIPTMANAGER_H
       
    24 #define C_RTSECMGRSCRIPTMANAGER_H
       
    25 
       
    26 #include <e32capability.h>
       
    27 #include <rtsecmgrutility.h>
       
    28 #include <rtsecmgrscript.h>
       
    29 #include "rtsecmgrdef.h"
       
    30 #include "rtsecmgrstore.h"
       
    31 
       
    32 //Forward declarations
       
    33 class CSecMgrStore;
       
    34 class CPolicyManager;
       
    35 
       
    36 typedef RPointerArray<CScript> RScripts;
       
    37 
       
    38 /*
       
    39  * Models the cache to maintain the list of registered script
       
    40  * data. Provides operations to register script, de-register 
       
    41  * script, query script related information.
       
    42  *
       
    43  * This class abstracts the underlying persistent storage to
       
    44  * store script related data.
       
    45  *
       
    46  * @see CSecMgrStore
       
    47  * @see CPolicyManager
       
    48  * @see CScript
       
    49  * 
       
    50  * @exe rtsecmgrserver.exe
       
    51  */
       
    52 class CScriptManager : public CBase
       
    53 	{
       
    54 public:
       
    55 	/**
       
    56 	 * Two-phased constructor
       
    57 	 * 
       
    58 	 * Constructs a CScriptManager instance
       
    59 	 * 
       
    60 	 * @param aSecMgrDB CSecMgrStore* reference to security manager store
       
    61 	 * @param aPolicyMgr CPolicyManager* reference to policymanager instance
       
    62 	 * 
       
    63 	 * @return CScriptManager* pointer to an instance of CScriptManager
       
    64 	 */
       
    65 	static CScriptManager* NewL(CSecMgrStore* aSecMgrDB,
       
    66 			CPolicyManager* aPolicyMgr);
       
    67 
       
    68 	/**
       
    69 	 * Two-phased constructor
       
    70 	 * 
       
    71 	 * Constructs a CScriptManager instance and leaves the created instance
       
    72 	 * on the cleanupstack
       
    73 	 * 
       
    74 	 * @param aSecMgrDB CSecMgrStore* reference to security manager store
       
    75 	 * @param aPolicyMgr CPolicyManager* reference to policymanager instance
       
    76 	 * 
       
    77 	 * @return CScriptManager* pointer to an instance of CScriptManager
       
    78 	 */
       
    79 	static CScriptManager* NewLC(CSecMgrStore* aSecMgrDB,
       
    80 			CPolicyManager* aPolicyMgr);
       
    81 
       
    82 	/**
       
    83 	 * Destructor
       
    84 	 * 
       
    85 	 * Performs clean-up of transient script store cache
       
    86 	 * 
       
    87 	 */
       
    88 	virtual ~CScriptManager();
       
    89 
       
    90 	/**
       
    91 	 * Registers a script based on a policy identified by
       
    92 	 * input policy identifier with security manager
       
    93 	 * 
       
    94 	 * @param aPolicyID TPolicyID input policy identifier of the script
       
    95 	 * 
       
    96 	 * @return TExecutableID script identifier of the registered script
       
    97 	 */
       
    98 	TExecutableID
       
    99 			RegisterScript(TPolicyID aPolicyID);
       
   100 
       
   101 	/**
       
   102 	 * Registers a script with hashvalue based on a policy identified by
       
   103 	 * input policy identifier with security manager. 
       
   104 	 * 
       
   105 	 * @param aPolicyID TPolicyID input policy identifier of the script
       
   106 	 * @param aHashValue const TDesC& hashValue of the script
       
   107 	 * 
       
   108 	 * @return TExecutableID script identifier of the registered script
       
   109 	 */
       
   110 	TExecutableID
       
   111 			RegisterScript(TPolicyID aPolicyID, const TDesC& aHashValue);
       
   112 
       
   113 	/**
       
   114 	 * Un-Registers a script
       
   115 	 * 
       
   116 	 * @param aExecID script identifier of the registered script
       
   117 	 * @param aPolicyID policy identifier passed while registering script
       
   118 	 * 
       
   119 	 */
       
   120 	void UnRegisterScriptL(TExecutableID aExecID, TPolicyID aPolicyID);
       
   121 
       
   122 	/**
       
   123 	 * Gets underlying script data
       
   124 	 * 
       
   125 	 * @param aScriptInfo CScript& output script data
       
   126 	 * 
       
   127 	 * @return KErrNone if script data could be returned; Otherwise one of
       
   128 	 * system error codes
       
   129 	 * 
       
   130 	 */
       
   131 	TInt ScriptInfo(CScript& aScriptInfo);
       
   132 
       
   133 	/**
       
   134 	 * Updates permanently granted or denied permission data
       
   135 	 * of the script
       
   136 	 * 
       
   137 	 * @param aExecID 	 TExecutableID script identifier
       
   138 	 * @param aPermGrant TPermGrant permanently allowed permission
       
   139 	 * @param aPermDenied TPermGrant permanently denied permission
       
   140 	 * 
       
   141 	 */
       
   142 	void UpdatePermGrantL(TExecutableID aExecID, TPermGrant aPermGrant,
       
   143 			TPermGrant aPermDenied);
       
   144 	
       
   145 	/**
       
   146      * Updates permanently granted or denied permission data
       
   147      * of the script
       
   148      * 
       
   149      * @param aExecID    TExecutableID script identifier
       
   150      * @param aPermGrant TPermGrant permanently allowed permission
       
   151      * @param aPermDenied TPermGrant permanently denied permission
       
   152      * 
       
   153      */
       
   154     void UpdatePermGrantL(TExecutableID aExecID, RProviderArray aAllowedProviders,
       
   155             RProviderArray aDeniedProviders);
       
   156 
       
   157 	/**
       
   158 	 * Gets the script file name
       
   159 	 * 
       
   160 	 * @param aExecID 	 TExecutableID script identifier
       
   161 	 * @param TDes& Output file name
       
   162 	 * 
       
   163 	 * @return KErrNone if operation is successful; Otherwise one of
       
   164 	 * system wide error codes
       
   165 	 * 
       
   166 	 */
       
   167 	TInt GetScriptFile(TExecutableID aExecID, TDes& aScriptFile);
       
   168 
       
   169 private:
       
   170 
       
   171 	/**
       
   172 	 * Overloaded constructor to initialise internal
       
   173 	 * state of CScriptManager
       
   174 	 * 
       
   175 	 */
       
   176 	inline CScriptManager(CSecMgrStore* aSecMgrDB, CPolicyManager* aPolicyMgr) :
       
   177 		iSecMgrDB(aSecMgrDB), iPolicyMgr(aPolicyMgr)
       
   178 		{
       
   179 		}
       
   180 
       
   181 	/**
       
   182 	 * Two-phased constructor
       
   183 	 * 
       
   184 	 */
       
   185 	void ConstructL();
       
   186 
       
   187 	/**
       
   188 	 * Generates a new script identifier
       
   189 	 * 
       
   190 	 */
       
   191 	inline TExecutableID GetID()
       
   192 		{
       
   193 		if ( --iID > 0)
       
   194 			return iID;
       
   195 
       
   196 		return (TExecutableID)KSecurityServerUid2Int;
       
   197 		}
       
   198 
       
   199 private:
       
   200 	
       
   201 	//list of script data structure
       
   202 	RScripts iScripts;
       
   203 	
       
   204 	//reference to security manager store
       
   205 	CSecMgrStore* iSecMgrDB;
       
   206 	
       
   207 	//reference to policymanager instance	
       
   208 	CPolicyManager* iPolicyMgr;
       
   209 	
       
   210 	//Last generated script identifier
       
   211 	TExecutableID iID;
       
   212 	};
       
   213 
       
   214 #endif  //C_RTSECMGRSCRIPTMANAGER_H
       
   215