os/security/authorisation/userpromptservice/policies/inc/policy.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @publishedPartner
sl@0
    22
 @released 
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef POLICY_H
sl@0
    26
#define POLICY_H
sl@0
    27
sl@0
    28
#include <e32base.h>
sl@0
    29
#include <e32cmn.h>
sl@0
    30
sl@0
    31
namespace UserPromptService 
sl@0
    32
	{
sl@0
    33
	/**
sl@0
    34
	 Defines a set of SID classes.
sl@0
    35
	 See Symbian Signed UID FAQ for the definition of SID classes.
sl@0
    36
	 */
sl@0
    37
	NONSHARABLE_CLASS(TSidClasses)
sl@0
    38
		{
sl@0
    39
	public:
sl@0
    40
		IMPORT_C TSidClasses(TUint16 aSidClasses);
sl@0
    41
		IMPORT_C TBool Contains(const TSecureId& aSid) const;
sl@0
    42
						
sl@0
    43
		const TUint16 iSidClasses; ///< A bitmask that defines the set SID classes.
sl@0
    44
		};
sl@0
    45
sl@0
    46
	/**
sl@0
    47
	 Class for a single policy record.
sl@0
    48
	 */
sl@0
    49
	NONSHARABLE_CLASS(CPolicy) : public CBase
sl@0
    50
		{
sl@0
    51
	public:
sl@0
    52
		/**
sl@0
    53
		   Defines the elements in the options field that determines 
sl@0
    54
		   whether a prompt should be displayed and if so what buttons are
sl@0
    55
		   available.
sl@0
    56
sl@0
    57
		   All other bits are reserved for future use and should be ignored
sl@0
    58
		   by the custom Policy Evaluators and Dialog Creators.
sl@0
    59
		 */
sl@0
    60
		typedef enum 
sl@0
    61
			{			
sl@0
    62
			EYes = 0x01,		///< The 'Yes' button should be displayed in the prompt.			
sl@0
    63
			ENo =  0x02,		///< The 'No' button should be displayed in the prompt.	
sl@0
    64
			ESession = 0x04,	///< The 'SessionYes' button should be displayed in the prompt.
sl@0
    65
			ESessionYes = 0x04,	///< The 'SessionYes' button should be displayed in the prompt.
sl@0
    66
			EAlways = 0x08,		///< The 'Always' button should be displayed in the prompt.			
sl@0
    67
			ENever = 0x10,		///< The 'Never' button should be displayed in the prompt.
sl@0
    68
			ESessionNo = 0x20   ///< The 'SessionNo' button should be displayed in the prompt.
sl@0
    69
			} TOptions;
sl@0
    70
			
sl@0
    71
		/**
sl@0
    72
		Allows policies to be matched according to whether the client process
sl@0
    73
		passed security check defined by the system server.
sl@0
    74
		Typically, this corresponds to whether the client has the correct capabilities
sl@0
    75
		for the requested service. However, system servers are free to use features
sl@0
    76
		other than capabilities in their security check.
sl@0
    77
sl@0
    78
		E.g. If the client has the correct capabilities for the requested service then
sl@0
    79
		the "Always" and "Never" options will be enabled in the policy; otherwise, a
sl@0
    80
		different policy will be matched where the prompt is limited to one-shot
sl@0
    81
		permissions ("Yes" and "No").
sl@0
    82
		*/
sl@0
    83
		typedef enum 
sl@0
    84
			{ 
sl@0
    85
			/**
sl@0
    86
			The policy applies regardless of whether the client process passed the
sl@0
    87
			system server's security check.
sl@0
    88
			*/
sl@0
    89
			ESystemServerSecurityPassedOrFailed = 0,
sl@0
    90
			/**
sl@0
    91
			The policy only applies if the client process failed the system server's
sl@0
    92
			security check.
sl@0
    93
			*/
sl@0
    94
			ESystemServerSecurityFailed = 1,
sl@0
    95
			/**
sl@0
    96
			The policy only applies if the client process passed the system server's
sl@0
    97
			security check.
sl@0
    98
			*/
sl@0
    99
			ESystemServerSecurityPassed = 2
sl@0
   100
			} TSystemServerSecurity;			
sl@0
   101
	
sl@0
   102
		IMPORT_C static CPolicy* NewL(const TSidClasses& aSidClasses, const RArray<TSecureId>& aSidList, 
sl@0
   103
				const TDesC& aDestination, TUint aOptions, const TUid& aPolicyEvaluator, 
sl@0
   104
				const TUid& aDialogCreator, TUint16 aFlags, 
sl@0
   105
				TSystemServerSecurity aSystemServerSecurity, 
sl@0
   106
				TUint16 aMajorVersion, TUint16 aMinorVersion, TBool aDefault = EFalse);
sl@0
   107
		
sl@0
   108
		IMPORT_C static CPolicy* NewLC(const TSidClasses& aSidClasses, const RArray<TSecureId>& aSidList, 
sl@0
   109
				const TDesC& aDestination, TUint aOptions, const TUid& aPolicyEvaluator, 
sl@0
   110
				const TUid& aDialogCreator, TUint16 aFlags,
sl@0
   111
				TSystemServerSecurity aSystemServerSecurity, 
sl@0
   112
				TUint16 aMajorVersion, TUint16 aMinorVersion, TBool aDefault = EFalse);
sl@0
   113
sl@0
   114
		IMPORT_C TBool Matches(const TSecureId& aClientSid, const TDesC& aDestination, TBool aSecurityResult) const;		
sl@0
   115
		IMPORT_C TBool PromptRequired() const;
sl@0
   116
	
sl@0
   117
		IMPORT_C TOptions Options() const;
sl@0
   118
		IMPORT_C const TUid& PolicyEvaluator() const;
sl@0
   119
		IMPORT_C const TUid& DialogCreator() const;
sl@0
   120
		IMPORT_C const TDesC& Destination() const;
sl@0
   121
		IMPORT_C const TSidClasses& SidClasses() const;
sl@0
   122
		IMPORT_C const RArray<TSecureId>& SidList() const;
sl@0
   123
		IMPORT_C TUint16 Flags() const;
sl@0
   124
		IMPORT_C TBool Default() const;
sl@0
   125
		IMPORT_C TSystemServerSecurity SystemServerSecurity() const;
sl@0
   126
		IMPORT_C TUint16 MajorVersion() const;
sl@0
   127
		IMPORT_C TUint16 MinorVersion() const;
sl@0
   128
sl@0
   129
		~CPolicy();
sl@0
   130
	private:
sl@0
   131
		CPolicy(const TSidClasses& aSidClasses, TUint aOptions, 
sl@0
   132
				const TUid& aPolicyEvaluator, const TUid& aDialogCreator,	
sl@0
   133
				TUint16 aFlags, TSystemServerSecurity aSystemServerSecurity, 
sl@0
   134
				TUint16 aMajorVersion, TUint16 aMinorVersion, TBool aDefault);
sl@0
   135
sl@0
   136
		void ConstructL(const RArray<TSecureId>& aSidList, const TDesC& aDescription);
sl@0
   137
		
sl@0
   138
		TSidClasses iSidClasses;	///< The clases of SIDs that this policy applies to.		
sl@0
   139
		RArray<TSecureId> iSidList;	///< The set of individual SIDs that this policy applies to.
sl@0
   140
		HBufC* iDestination;		///< Wildcard string to match against the request's destination.
sl@0
   141
		TUint iOptions;				///< Options for evaluator EYes|ENo|ESessionYes|EAlways|ENever.
sl@0
   142
		TUid iPolicyEvaluator;		///< Implementation UID of the associated policy evaluator.
sl@0
   143
		TUid iDialogCreator;		///< Implementation UID of the associated dialog creator.
sl@0
   144
		TUint16 iFlags;				///< Policy Evaluator specific flags
sl@0
   145
		/**	Whether this policy is specific to clients that passed/failed the system server's
sl@0
   146
		security check.	*/
sl@0
   147
		TSystemServerSecurity iSystemServerSecurity;
sl@0
   148
		TUint16 iMajorVersion;		///< Major version of the UPS policy file.
sl@0
   149
		TUint16 iMinorVersion;		///< Minor version of the UPS policy file.		
sl@0
   150
		TBool iDefault;				///< ETrue if no match was found in the policy file.
sl@0
   151
		};
sl@0
   152
	}
sl@0
   153
sl@0
   154
#endif // POLICY_H