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