rtsecuritymanager/rtsecuritymanagerserver/inc/rtsecmgrpolicymanager.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 policy manager class
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef C_RTSECMGRPOLICYMANAGER_H
       
    24 #define C_RTSECMGRPOLICYMANAGER_H
       
    25 
       
    26 #include <e32capability.h>
       
    27 #include <rtsecmgrutility.h>
       
    28 #include <rtsecmgrscript.h>
       
    29 #include "rtsecmgrdef.h"
       
    30 #include "rtsecmgrpolicy.h"
       
    31 #include "rtsecmgrdata.h"
       
    32 #include "rtsecmgrstore.h"
       
    33 
       
    34 /*
       
    35  * Manages set of security and trust policies. 
       
    36  * 
       
    37  * CPolicyManager provides management functionalities to
       
    38  *  - register a policy
       
    39  *  - un-register a policy
       
    40  *  - restore policies from the persistent storage
       
    41  *
       
    42  * CPolicyManager interacts with CSecMgrStore which abstracts the
       
    43  * underlying persistent storage from policy users
       
    44  * 
       
    45  * @see CSecMgrStore
       
    46  * @see CPolicy
       
    47  * 
       
    48  * @exe rtsecmgrserver.exe
       
    49  */
       
    50 NONSHARABLE_CLASS(CPolicyManager) : public CBase
       
    51 	{
       
    52 public:
       
    53 
       
    54 	/**
       
    55 	 * Two-phased constructor
       
    56 	 * 
       
    57 	 * Constructs a CPolicyManager instance
       
    58 	 * 
       
    59 	 * @param aSecMgrDB CSecMgrStore* pointer to security manager storage type
       
    60 	 * 
       
    61 	 * @return CPolicyManager* pointer to an instance of CPolicyManager
       
    62 	 */
       
    63 	static CPolicyManager* NewL(CSecMgrStore* aSecMgrDB);
       
    64 
       
    65 	/**
       
    66 	 * Two-phased constructor
       
    67 	 * 
       
    68 	 * Constructs a CPolicyManager instance and leaves the created
       
    69 	 * instance on the cleanupstack
       
    70 	 * 
       
    71 	 * @param aSecMgrDB CSecMgrStore* pointer to security manager storage type
       
    72 	 * 
       
    73 	 * @return CPolicyManager* pointer to an instance of CPolicyManager
       
    74 	 */
       
    75 	static CPolicyManager* NewLC(CSecMgrStore* aSecMgrDB);
       
    76 
       
    77 	/**
       
    78 	 * Destructor
       
    79 	 * 
       
    80 	 * Cleanups the internal cache for policy data
       
    81 	 */
       
    82 	inline ~CPolicyManager();
       
    83 
       
    84 	/**
       
    85 	 * Registers a new policy data. 
       
    86 	 * 
       
    87 	 * This method in turn updates the security manager
       
    88 	 * persistent store with new policy data
       
    89 	 * 
       
    90 	 * @param aPolicy const CPolicy& Reference to policy data
       
    91 	 * 
       
    92 	 */
       
    93 	void RegisterPolicyL(const CPolicy& aPolicy);
       
    94 
       
    95 	/**
       
    96 	 * Un-registers an existing policy data 
       
    97 	 * 
       
    98 	 * This method in turn removes the policy data from the 
       
    99 	 * security manager persistent store
       
   100 	 * 
       
   101 	 * @param aPolicyID TPolicyID Policy identifier
       
   102 	 * 
       
   103 	 * @return KErrNone if unregistration is successful; Otherwise one of
       
   104 	 * system wide error codes
       
   105 	 */
       
   106 	TInt UnRegisterPolicy(TPolicyID aPolicyID);
       
   107 
       
   108 	/**
       
   109 	 * Restores policy data from security manager persistent store.
       
   110 	 * 
       
   111 	 * The internal cache of policy data maintained by this class
       
   112 	 * gets updated
       
   113 	 * 
       
   114 	 */
       
   115 	inline void RestorePoliciesL();
       
   116 
       
   117 	/**
       
   118 	 * Gets the policy data associated with the policy
       
   119 	 * identifier
       
   120 	 * 
       
   121 	 * @param aPolicyID TPolicyID policy identifier
       
   122 	 * 
       
   123 	 * @return CPolicy * pointer to an instance of CPolicy associated
       
   124 	 * with policy identifier; Returns NULL if policy identifier is not valid
       
   125 	 */
       
   126 	CPolicy* Policy(TPolicyID aPolicyID) const;
       
   127 
       
   128 	/**
       
   129 	 * Checks if a policy data is stored with a policy identifier
       
   130 	 * 
       
   131 	 * @param aPolicyID TPolicyID policy identifier
       
   132 	 * 
       
   133 	 * @return TBool ETrue if policy associated with policy identifier
       
   134 	 * exists; Otherwise EFalse
       
   135 	 * 
       
   136 	 */
       
   137 	TBool HasPolicy(TPolicyID aPolicyID) const;
       
   138 
       
   139 	/**
       
   140 	 * Gets the number of registered policy data
       
   141 	 * 
       
   142 	 * @return TInt number of registered policy data
       
   143 	 */
       
   144 	inline TInt Count() const;
       
   145 private:
       
   146 
       
   147 	/**
       
   148 	 * Overloaded constructor
       
   149 	 * 
       
   150 	 */
       
   151 	inline CPolicyManager(CSecMgrStore* aSecMgrDB);
       
   152 private:
       
   153 
       
   154 	//Array of policy data
       
   155 	RPolicies iPolicies;
       
   156 
       
   157 	//Reference to security manager persistent storage
       
   158 	CSecMgrStore* iSecMgrDB;
       
   159 	};
       
   160 
       
   161 #include "rtsecmgrpolicymanager.inl"
       
   162 
       
   163 #endif //C_RTSECMGRPOLICYMANAGER_H
       
   164