|
1 /* |
|
2 * Copyright (c) 2000 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 "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: Implementation of policymanagement components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef _POLICY_PROCESSOR_HEADER__ |
|
22 #define _POLICY_PROCESSOR_HEADER__ |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include "PolicyEngineServer.h" |
|
27 #include "ElementBase.h" |
|
28 #include "RequestContext.h" |
|
29 #include "PolicyStorage.h" |
|
30 #include <e32base.h> |
|
31 |
|
32 // CONSTANTS |
|
33 // MACROS |
|
34 // DATA TYPES |
|
35 // FUNCTION PROTOTYPES |
|
36 // FORWARD DECLARATIONS |
|
37 |
|
38 class CDataType; |
|
39 class CAttribute; |
|
40 class CAttributeValue; |
|
41 class CTrustedSession; |
|
42 |
|
43 typedef RArray<CAttributeValue*> RParameterList; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 |
|
47 namespace AttributeContainerHelper |
|
48 { |
|
49 enum TAttributeTypes |
|
50 { |
|
51 ESubjectAttributes = 0, |
|
52 EActionAttributes, |
|
53 EResourceAttributes, |
|
54 EEnvironmentAttributes |
|
55 }; |
|
56 |
|
57 class TContainer |
|
58 { |
|
59 public: |
|
60 CAttribute * iAttribute; |
|
61 TAttributeTypes iAttributeType; |
|
62 private: |
|
63 }; |
|
64 } |
|
65 |
|
66 class RAttributeContainer : public RArray<AttributeContainerHelper::TContainer*> |
|
67 { |
|
68 public: |
|
69 void AppendL( AttributeContainerHelper::TAttributeTypes aAttributeTypes, CAttribute* aAttribute); |
|
70 void Close(); |
|
71 private: |
|
72 }; |
|
73 |
|
74 class CPolicyProcessor : public CActive |
|
75 { |
|
76 public: |
|
77 typedef RArray<CAttribute*> RAttributeList; |
|
78 |
|
79 static CPolicyProcessor * NewL(); |
|
80 CPolicyProcessor(); |
|
81 ~CPolicyProcessor(); |
|
82 void ConstructL(); |
|
83 |
|
84 void ResetRequestContext(); |
|
85 |
|
86 void ExecuteRequestL( RAttributeContainer& aAttributes, TMatchResponse &aResponse); |
|
87 void ExecuteRequestL( const RMessage2& aMessage); |
|
88 |
|
89 |
|
90 //Request context |
|
91 TRequestContext * RequestContext(); |
|
92 |
|
93 RAttributeList * Subjects(); |
|
94 RAttributeList * Actions(); |
|
95 RAttributeList * Resources(); |
|
96 RAttributeList * Environments(); |
|
97 |
|
98 //Execution functions |
|
99 static void HandleErrorL( const TDesC8 &aText); |
|
100 |
|
101 TBool MatchFunctionL( const TDesC8 &aFunctionId, CDataType * aData1, CDataType * aData2); |
|
102 void FunctionL( const TDesC8 &aFunctionId, RParameterList& aParams, CAttributeValue* aResponseElement); |
|
103 |
|
104 //For management functions |
|
105 void SetTargetElement( CElementBase * aElement); |
|
106 void SetSessionTrust( CTrustedSession * aTrustedSession); |
|
107 protected: |
|
108 //From CActive |
|
109 void RunL(); |
|
110 void DoCancel(); |
|
111 TInt RunError( TInt aError); |
|
112 private: |
|
113 void DoRequestExecutionL(TMatchResponse &aResponse, TBool iUseEditableElements); |
|
114 TPtrC8 NextToken( TPtrC8& aText); |
|
115 |
|
116 void OrFunctionL( const RParameterList& aParams, CAttributeValue* aResponseElement ); |
|
117 void AndFunctionL( const RParameterList& aParams, CAttributeValue* aResponseElement ); |
|
118 void NotFunctionL( const RParameterList& aParams, CAttributeValue* aResponseElement ); |
|
119 |
|
120 void CertificateForSessionL( CAttributeValue* aResponseElement ); |
|
121 void CorporateUserAcceptFunctionL( const RParameterList& aParams, CAttributeValue* aResponseElement ); |
|
122 void RuleTargetStructureFunctionL( const RParameterList& aParams, CAttributeValue* aResponseElement ); |
|
123 void EqualFunctionsL( const RParameterList& aParams, CAttributeValue* aResponseElement ); |
|
124 |
|
125 void MakeBooleanResponseL( const TBool aValue, CAttributeValue* aResponseElement ); |
|
126 |
|
127 void CompleteMessage( TInt aError, TResponse aResponse); |
|
128 private: |
|
129 CElementBase * iManagementTargetPolicy; |
|
130 CTrustedSession * iTrustedSession; |
|
131 |
|
132 RAttributeList iSubjects; |
|
133 RAttributeList iActions; |
|
134 RAttributeList iResources; |
|
135 RAttributeList iEnvironments; |
|
136 TBool iDeleteAttributes; |
|
137 TBool iUseEditedElements; |
|
138 |
|
139 //RunL handling |
|
140 const RMessage2 * iMessage; |
|
141 HBufC8 * iRequestBuffer; |
|
142 TInt iProcessorState; |
|
143 }; |
|
144 |
|
145 class TCombiningAlgorith |
|
146 { |
|
147 public: |
|
148 TCombiningAlgorith( const TDesC8 &aAlgorithId); |
|
149 |
|
150 TBool AddInput( const TMatchResponse& aInput, const TMatchResponse& aEffect); |
|
151 TBool AddInput( const TMatchResponse& aInput); |
|
152 TBool ResultReady(); |
|
153 TMatchResponse Result(); |
|
154 private: |
|
155 enum TCombingAlgorithm |
|
156 { |
|
157 ERuleDenyOverrides = 0, |
|
158 EPolicyDenyOverrides, |
|
159 ERulePermitOverrides, |
|
160 EPolicyPermitOverrides, |
|
161 }; |
|
162 private: |
|
163 TCombingAlgorithm iAlgorithm; |
|
164 TMatchResponse iCurrentResponse; |
|
165 TBool iResultReady; |
|
166 TBool iAtLeastOneError; |
|
167 TBool iPotentialDeny; |
|
168 TBool iPotentialPermit; |
|
169 TBool iAtLeastOneDeny; |
|
170 TBool iAtLeastOnePermit; |
|
171 }; |
|
172 |
|
173 |
|
174 #endif |