os/security/authorisation/userpromptservice/policies/inc/policy.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptservice/policies/inc/policy.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,154 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @publishedPartner
    1.25 + @released 
    1.26 +*/
    1.27 +
    1.28 +#ifndef POLICY_H
    1.29 +#define POLICY_H
    1.30 +
    1.31 +#include <e32base.h>
    1.32 +#include <e32cmn.h>
    1.33 +
    1.34 +namespace UserPromptService 
    1.35 +	{
    1.36 +	/**
    1.37 +	 Defines a set of SID classes.
    1.38 +	 See Symbian Signed UID FAQ for the definition of SID classes.
    1.39 +	 */
    1.40 +	NONSHARABLE_CLASS(TSidClasses)
    1.41 +		{
    1.42 +	public:
    1.43 +		IMPORT_C TSidClasses(TUint16 aSidClasses);
    1.44 +		IMPORT_C TBool Contains(const TSecureId& aSid) const;
    1.45 +						
    1.46 +		const TUint16 iSidClasses; ///< A bitmask that defines the set SID classes.
    1.47 +		};
    1.48 +
    1.49 +	/**
    1.50 +	 Class for a single policy record.
    1.51 +	 */
    1.52 +	NONSHARABLE_CLASS(CPolicy) : public CBase
    1.53 +		{
    1.54 +	public:
    1.55 +		/**
    1.56 +		   Defines the elements in the options field that determines 
    1.57 +		   whether a prompt should be displayed and if so what buttons are
    1.58 +		   available.
    1.59 +
    1.60 +		   All other bits are reserved for future use and should be ignored
    1.61 +		   by the custom Policy Evaluators and Dialog Creators.
    1.62 +		 */
    1.63 +		typedef enum 
    1.64 +			{			
    1.65 +			EYes = 0x01,		///< The 'Yes' button should be displayed in the prompt.			
    1.66 +			ENo =  0x02,		///< The 'No' button should be displayed in the prompt.	
    1.67 +			ESession = 0x04,	///< The 'SessionYes' button should be displayed in the prompt.
    1.68 +			ESessionYes = 0x04,	///< The 'SessionYes' button should be displayed in the prompt.
    1.69 +			EAlways = 0x08,		///< The 'Always' button should be displayed in the prompt.			
    1.70 +			ENever = 0x10,		///< The 'Never' button should be displayed in the prompt.
    1.71 +			ESessionNo = 0x20   ///< The 'SessionNo' button should be displayed in the prompt.
    1.72 +			} TOptions;
    1.73 +			
    1.74 +		/**
    1.75 +		Allows policies to be matched according to whether the client process
    1.76 +		passed security check defined by the system server.
    1.77 +		Typically, this corresponds to whether the client has the correct capabilities
    1.78 +		for the requested service. However, system servers are free to use features
    1.79 +		other than capabilities in their security check.
    1.80 +
    1.81 +		E.g. If the client has the correct capabilities for the requested service then
    1.82 +		the "Always" and "Never" options will be enabled in the policy; otherwise, a
    1.83 +		different policy will be matched where the prompt is limited to one-shot
    1.84 +		permissions ("Yes" and "No").
    1.85 +		*/
    1.86 +		typedef enum 
    1.87 +			{ 
    1.88 +			/**
    1.89 +			The policy applies regardless of whether the client process passed the
    1.90 +			system server's security check.
    1.91 +			*/
    1.92 +			ESystemServerSecurityPassedOrFailed = 0,
    1.93 +			/**
    1.94 +			The policy only applies if the client process failed the system server's
    1.95 +			security check.
    1.96 +			*/
    1.97 +			ESystemServerSecurityFailed = 1,
    1.98 +			/**
    1.99 +			The policy only applies if the client process passed the system server's
   1.100 +			security check.
   1.101 +			*/
   1.102 +			ESystemServerSecurityPassed = 2
   1.103 +			} TSystemServerSecurity;			
   1.104 +	
   1.105 +		IMPORT_C static CPolicy* NewL(const TSidClasses& aSidClasses, const RArray<TSecureId>& aSidList, 
   1.106 +				const TDesC& aDestination, TUint aOptions, const TUid& aPolicyEvaluator, 
   1.107 +				const TUid& aDialogCreator, TUint16 aFlags, 
   1.108 +				TSystemServerSecurity aSystemServerSecurity, 
   1.109 +				TUint16 aMajorVersion, TUint16 aMinorVersion, TBool aDefault = EFalse);
   1.110 +		
   1.111 +		IMPORT_C static CPolicy* NewLC(const TSidClasses& aSidClasses, const RArray<TSecureId>& aSidList, 
   1.112 +				const TDesC& aDestination, TUint aOptions, const TUid& aPolicyEvaluator, 
   1.113 +				const TUid& aDialogCreator, TUint16 aFlags,
   1.114 +				TSystemServerSecurity aSystemServerSecurity, 
   1.115 +				TUint16 aMajorVersion, TUint16 aMinorVersion, TBool aDefault = EFalse);
   1.116 +
   1.117 +		IMPORT_C TBool Matches(const TSecureId& aClientSid, const TDesC& aDestination, TBool aSecurityResult) const;		
   1.118 +		IMPORT_C TBool PromptRequired() const;
   1.119 +	
   1.120 +		IMPORT_C TOptions Options() const;
   1.121 +		IMPORT_C const TUid& PolicyEvaluator() const;
   1.122 +		IMPORT_C const TUid& DialogCreator() const;
   1.123 +		IMPORT_C const TDesC& Destination() const;
   1.124 +		IMPORT_C const TSidClasses& SidClasses() const;
   1.125 +		IMPORT_C const RArray<TSecureId>& SidList() const;
   1.126 +		IMPORT_C TUint16 Flags() const;
   1.127 +		IMPORT_C TBool Default() const;
   1.128 +		IMPORT_C TSystemServerSecurity SystemServerSecurity() const;
   1.129 +		IMPORT_C TUint16 MajorVersion() const;
   1.130 +		IMPORT_C TUint16 MinorVersion() const;
   1.131 +
   1.132 +		~CPolicy();
   1.133 +	private:
   1.134 +		CPolicy(const TSidClasses& aSidClasses, TUint aOptions, 
   1.135 +				const TUid& aPolicyEvaluator, const TUid& aDialogCreator,	
   1.136 +				TUint16 aFlags, TSystemServerSecurity aSystemServerSecurity, 
   1.137 +				TUint16 aMajorVersion, TUint16 aMinorVersion, TBool aDefault);
   1.138 +
   1.139 +		void ConstructL(const RArray<TSecureId>& aSidList, const TDesC& aDescription);
   1.140 +		
   1.141 +		TSidClasses iSidClasses;	///< The clases of SIDs that this policy applies to.		
   1.142 +		RArray<TSecureId> iSidList;	///< The set of individual SIDs that this policy applies to.
   1.143 +		HBufC* iDestination;		///< Wildcard string to match against the request's destination.
   1.144 +		TUint iOptions;				///< Options for evaluator EYes|ENo|ESessionYes|EAlways|ENever.
   1.145 +		TUid iPolicyEvaluator;		///< Implementation UID of the associated policy evaluator.
   1.146 +		TUid iDialogCreator;		///< Implementation UID of the associated dialog creator.
   1.147 +		TUint16 iFlags;				///< Policy Evaluator specific flags
   1.148 +		/**	Whether this policy is specific to clients that passed/failed the system server's
   1.149 +		security check.	*/
   1.150 +		TSystemServerSecurity iSystemServerSecurity;
   1.151 +		TUint16 iMajorVersion;		///< Major version of the UPS policy file.
   1.152 +		TUint16 iMinorVersion;		///< Minor version of the UPS policy file.		
   1.153 +		TBool iDefault;				///< ETrue if no match was found in the policy file.
   1.154 +		};
   1.155 +	}
   1.156 +
   1.157 +#endif // POLICY_H