policymanagement/policyengine/policyengineserver/inc/elements.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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 #ifndef ELEMENTS_HEADER_
       
    20 #define ELEMENTS_HEADER_
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include "ElementBase.h"
       
    25 #include "XACMLconstants.h"
       
    26 #include "RequestContext.h"
       
    27 #include "PolicyStorage.h"
       
    28 
       
    29 #include <e32base.h>
       
    30 
       
    31 // CONSTANTS
       
    32 // MACROS
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 class CAttributeDesignator;
       
    36 class CAttributeValue;
       
    37 class CPolicyProcessor;
       
    38 class CMatchObject;
       
    39 class CItemContainer;
       
    40 class CTarget;
       
    41 
       
    42 // DATA TYPES
       
    43 
       
    44 typedef RArray<HBufC*> RAttributeValuesList;
       
    45 
       
    46 // FUNCTION PROTOTYPES
       
    47 // CLASS DECLARATION
       
    48 
       
    49 /*
       
    50 class TUnionTarget
       
    51 {
       
    52 	public:
       
    53 		TUnionTarget( CPolicyStorage * aPolicyStorage);
       
    54 		~TUnionTarget();
       
    55 		void AddTargetElementsL( CElementBase * aElement);
       
    56 		
       
    57 		RMatchObjectArray * GetSubjectAttributes();
       
    58 		RMatchObjectArray * GetResourceAttributes();
       
    59 		RMatchObjectArray * GetActionAttributes();
       
    60 		RMatchObjectArray * GetEnviromentAttributes();
       
    61 		
       
    62 		CMatchObject * FindSubjectAttribute( const TDesC8 &aAttributeId);
       
    63 		CMatchObject * FindActionAttribute( const TDesC8 &aAttributeId);
       
    64 		CMatchObject * FindResourceAttribute( const TDesC8 &aAttributeId);
       
    65 		CMatchObject * FindEnvironmentAttribute( const TDesC8 &aAttributeId);
       
    66 	
       
    67 	private:
       
    68 		CMatchObject * FindAttribute( const TDesC8 &aAttributeId, RMatchObjectArray *aMatchObjectArray);
       
    69 		
       
    70 	private:		
       
    71 		CPolicyStorage * iPolicyStorage;
       
    72 		TElementReserver iReserver;
       
    73 		
       
    74 		RMatchObjectArray iSubjectAttributes;
       
    75 		RMatchObjectArray iResourceAttributes;
       
    76 		RMatchObjectArray iActionAttributes;
       
    77 		RMatchObjectArray iEnvironmentAttributes;
       
    78 };*/
       
    79 
       
    80 class RContentBuilder : public RPointerArray<HBufC8>
       
    81 {
       
    82 	public:
       
    83 		RContentBuilder();
       
    84 	
       
    85 		void AddContentL( HBufC8 * aBuffer);
       
    86 		HBufC8 * ContentL();
       
    87 		HBufC8 * ContentLC();
       
    88 		
       
    89 		void Close();		
       
    90 	private:
       
    91 		TInt iSize;
       
    92 };
       
    93 
       
    94 class CApply : public CElementBase
       
    95 {
       
    96 	public:
       
    97 			CApply();
       
    98 			~CApply();
       
    99 		
       
   100 			static CApply * NewL();
       
   101 			static TBool IdentificateType( const TDesC8& aElementName);
       
   102 
       
   103 			HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode);
       
   104 
       
   105 			void AddAttributeL( CPolicyParser *aParser, const TDesC8& aName, const TDesC8& aValue);
       
   106 			void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   107 	
       
   108 			void AddIdElementL( CElementBase * aElement);	
       
   109 			virtual TBool ValidElement();
       
   110 		
       
   111 			CAttributeValue * ApplyValueL( CPolicyProcessor* aPolicyProcessor);
       
   112 			
       
   113 			const TPtrC8 ReturnDataType();
       
   114 		
       
   115 		private:
       
   116 			void ConstructL();
       
   117 			HBufC8 * iFunctionId;
       
   118 			CAttributeValue * iResponseValue;			
       
   119 };
       
   120 
       
   121 class CCondition : public CElementBase
       
   122 {
       
   123 	public:
       
   124 		CCondition();
       
   125 		~CCondition();
       
   126 		
       
   127 		static CCondition * NewL();
       
   128 		static TBool IdentificateType( const TDesC8& aElementName);
       
   129 
       
   130 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode);
       
   131 
       
   132 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   133 	
       
   134 		void AddIdElementL( CElementBase * aElement);	
       
   135 		virtual TBool ValidElement();
       
   136 		
       
   137 		TMatchResponse ConditionValueL( CPolicyProcessor* aPolicyProcessor);
       
   138 	private:
       
   139 		CElementBase * iExpression;
       
   140 };
       
   141 
       
   142 
       
   143 class CPolicySet : public CElementBase
       
   144 {
       
   145 	public:
       
   146 		CPolicySet();
       
   147 		virtual ~CPolicySet();
       
   148 
       
   149 		static CPolicySet * NewL();
       
   150 		static TBool IdentificateType( const TDesC8& aElementName);
       
   151 
       
   152 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode);
       
   153 
       
   154 		void AddAttributeL( CPolicyParser *aParser, const TDesC8& aName, const TDesC8& aValue);
       
   155 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   156 	
       
   157 		TMatchResponse MatchL( CPolicyProcessor* aPolicyProcessor);
       
   158 		void AddIdElementL( CElementBase * aElement);	
       
   159 		
       
   160 		virtual TBool ValidElement();
       
   161 	private:
       
   162 		HBufC8 * iPolicySetId;
       
   163 		HBufC8 * iPolicyCompiningAlg;
       
   164 		CElementBase * iTarget;
       
   165 		CElementBase * iDescription;
       
   166 };
       
   167 
       
   168 class CPolicy : public CElementBase
       
   169 {
       
   170 	public:
       
   171 		CPolicy();
       
   172 		virtual ~CPolicy();
       
   173 
       
   174 		static CPolicy * NewL();
       
   175 		static TBool IdentificateType( const TDesC8& aElementName);
       
   176 
       
   177 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode);
       
   178 
       
   179 		void AddAttributeL( CPolicyParser *aParser, const TDesC8& aName, const TDesC8& aValue);
       
   180 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   181 	
       
   182 		TMatchResponse MatchL( CPolicyProcessor* aPolicyProcessor);
       
   183 		void AddIdElementL( CElementBase * aElement);	
       
   184 
       
   185 		virtual TBool ValidElement();
       
   186 		
       
   187 	private:
       
   188 		HBufC8 * iPolicyId;
       
   189 		HBufC8 * iRuleCompiningAlg;
       
   190 		CElementBase * iDescription;
       
   191 		CElementBase * iTarget;
       
   192 };
       
   193 
       
   194 class CRule : public CElementBase
       
   195 {
       
   196 	public:
       
   197 		CRule();
       
   198 		virtual ~CRule();
       
   199 		
       
   200 		static CRule * NewL();
       
   201 		static TBool IdentificateType( const TDesC8& aElementName);
       
   202 			
       
   203 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode);
       
   204 
       
   205 		TMatchResponse MatchL( CPolicyProcessor* aPolicyProcessor);
       
   206 		TMatchResponse Effect();
       
   207 		
       
   208 		const TDesC8& EffectValue();
       
   209 		CTarget* GetTarget();
       
   210 
       
   211 		void AddIdElementL( CElementBase * aElement);
       
   212 		void SetRuleIdL( const TDesC8& aName);
       
   213 		void SetEffectL( const TDesC8& aEffect);
       
   214 
       
   215 		virtual TBool ValidElement();
       
   216 		void AddAttributeL( CPolicyParser *aParser, const TDesC8& aName, const TDesC8& aValue);
       
   217 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   218 	private: 
       
   219 		
       
   220 	private:
       
   221 		CElementBase * iDescription;
       
   222 		HBufC8 * iEffect;
       
   223 		HBufC8 * iRuleId;
       
   224 		
       
   225 		CElementBase * iTarget;
       
   226 		CElementBase * iCondition;
       
   227 };
       
   228 
       
   229 class CTarget : public CElementBase
       
   230 {
       
   231 	public:
       
   232 		CTarget();
       
   233 		virtual ~CTarget();
       
   234 
       
   235 		static CTarget * NewL();
       
   236 		static TBool IdentificateType( const TDesC8& aElementName);
       
   237 			
       
   238 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode);
       
   239 		TMatchResponse MatchL( CPolicyProcessor* aPolicyProcessor);
       
   240 		void AddIdElementL( CElementBase * aElement);
       
   241 
       
   242 		virtual TBool ValidElement();
       
   243 		
       
   244 		void GetMatchContainersL( RMatchObjectArray& aMatchContainer );
       
   245 		
       
   246 		//Parsing functions
       
   247 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   248 	private:	
       
   249 		
       
   250 	private:
       
   251 		CElementBase * iSubjects;
       
   252 		CElementBase * iActions;
       
   253 		CElementBase * iResources;
       
   254 		CElementBase * iEnvironments;			
       
   255 };
       
   256 
       
   257 class CItemContainer : public CElementBase
       
   258 {
       
   259 	public:
       
   260 		virtual ~CItemContainer();
       
   261 		
       
   262 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode  );
       
   263 		TMatchResponse MatchL( CPolicyProcessor* aPolicyProcessor);
       
   264 		void AddIdElementL( CElementBase * aElement);
       
   265 		
       
   266 		virtual TBool ValidElement();
       
   267 		
       
   268 		void GetMatchContainersL( RMatchObjectArray& aMatchContainer );
       
   269 	protected:
       
   270 		CItemContainer();
       
   271 
       
   272 	private:
       
   273 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   274 
       
   275 	protected:
       
   276 		enum TBooleanType
       
   277 		{
       
   278 			EOrBoolean,
       
   279 			EAndBoolean
       
   280 		};
       
   281 	
       
   282 		TNativeElementTypes iAllowedType;
       
   283 		TBooleanType iBooleanType;
       
   284 };
       
   285 
       
   286 class CSubjects : public CItemContainer
       
   287 {
       
   288 	public:
       
   289 		CSubjects();
       
   290 		virtual ~CSubjects();
       
   291 		
       
   292 		static CSubjects * NewL();
       
   293 		static TBool IdentificateType( const TDesC8& aElementName);
       
   294 	private:
       
   295 };
       
   296 
       
   297 
       
   298 class CSubject : public CItemContainer
       
   299 {
       
   300 	public:
       
   301 		CSubject();
       
   302 		virtual ~CSubject();
       
   303 		
       
   304 		static CSubject * NewL();
       
   305 		static TBool IdentificateType( const TDesC8& aElementName);
       
   306 	private:
       
   307 };
       
   308 
       
   309 class CActions : public CItemContainer
       
   310 {
       
   311 	public:
       
   312 		CActions();
       
   313 		virtual ~CActions();
       
   314 		
       
   315 		static CElementBase * NewL();
       
   316 		static TBool IdentificateType( const TDesC8& aElementName);
       
   317 	private:
       
   318 };
       
   319 
       
   320 
       
   321 class CAction : public CItemContainer
       
   322 {
       
   323 	public:
       
   324 		CAction();
       
   325 		virtual ~CAction();
       
   326 		
       
   327 		static CElementBase * NewL();
       
   328 		static TBool IdentificateType( const TDesC8& aElementName);
       
   329 	private:
       
   330 };
       
   331 
       
   332 class CResources : public CItemContainer
       
   333 {
       
   334 	public:
       
   335 		CResources();
       
   336 		virtual ~CResources();
       
   337 		
       
   338 		static CElementBase * NewL();
       
   339 		static TBool IdentificateType( const TDesC8& aElementName);
       
   340 	private:
       
   341 };
       
   342 
       
   343 
       
   344 class CResource : public CItemContainer
       
   345 {
       
   346 	public:
       
   347 		CResource();
       
   348 		virtual ~CResource();
       
   349 		
       
   350 		static CElementBase * NewL();
       
   351 		static TBool IdentificateType( const TDesC8& aElementName);
       
   352 	private:
       
   353 };
       
   354 
       
   355 class CEnvironments : public CItemContainer
       
   356 {
       
   357 	public:
       
   358 		CEnvironments();
       
   359 		virtual ~CEnvironments();
       
   360 		
       
   361 		static CElementBase * NewL();
       
   362 		static TBool IdentificateType( const TDesC8& aElementName);
       
   363 	private:
       
   364 };
       
   365 
       
   366 
       
   367 class CEnvironment : public CItemContainer
       
   368 {
       
   369 	public:
       
   370 		CEnvironment();
       
   371 		virtual ~CEnvironment();
       
   372 		
       
   373 		static CElementBase * NewL();
       
   374 		static TBool IdentificateType( const TDesC8& aElementName);
       
   375 	private:
       
   376 };
       
   377 
       
   378 
       
   379 
       
   380 
       
   381 class CAttribute : public CElementBase
       
   382 {
       
   383 	public:
       
   384 		CAttribute();
       
   385 		virtual ~CAttribute();
       
   386 		
       
   387 		static CAttribute * NewL( const TDesC8& aAttributeId, const TDesC8& aAttributeValue, const TDesC8& aDataType);
       
   388 		static CAttribute * NewL( const TDesC8& aAttributeId, const TBool& aAttributeValue);
       
   389 		void ConstructL( const TDesC8& aAttributeId, const TDesC8& aAttributeValue, const TDesC8& aDataType);
       
   390 	
       
   391 	
       
   392 		CAttributeValue * AttributeValue();
       
   393 		TDesC8& AttributeId();
       
   394 		TDesC8& AttributeType();	
       
   395 	
       
   396 	private:
       
   397 		CAttributeValue * iAttributeValue;
       
   398 		HBufC8 * iAttributeId;
       
   399 		HBufC8 * iDataType;
       
   400 };
       
   401 
       
   402 class CAttributeDesignator : public CElementBase
       
   403 {
       
   404 	public:
       
   405 		CAttributeDesignator();
       
   406 		virtual ~CAttributeDesignator();
       
   407 		static CElementBase * NewL( TNativeElementTypes aType);
       
   408 		
       
   409 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode  );
       
   410 		
       
   411 		TDesC8& GetAttributeid();
       
   412 		TDesC8& GetDataType();
       
   413 		
       
   414 		CAttribute * GetAttributeFromRequestContext( CPolicyProcessor * iRequestContext);
       
   415 		
       
   416 		virtual TBool ValidElement();
       
   417 		void AddAttributeL( CPolicyParser *aParser, const TDesC8& aName, const TDesC8& aValue);
       
   418 	private:	
       
   419 	protected:		
       
   420 		HBufC8 * iAttributeId;
       
   421 		HBufC8 * iDataType;
       
   422 };
       
   423 
       
   424 class CSubjectAttributeDesignator : public CAttributeDesignator
       
   425 {
       
   426 	public:
       
   427 		CSubjectAttributeDesignator();
       
   428 		virtual ~CSubjectAttributeDesignator();
       
   429 
       
   430 		static CSubjectAttributeDesignator * NewL();
       
   431 		static TBool IdentificateType( const TDesC8& aElementName);
       
   432 		
       
   433 	private:
       
   434 };
       
   435 
       
   436 class CActionAttributeDesignator : public CAttributeDesignator
       
   437 {
       
   438 	public:
       
   439 		CActionAttributeDesignator();
       
   440 		virtual ~CActionAttributeDesignator();
       
   441 
       
   442 		static CElementBase * NewL();
       
   443 		static TBool IdentificateType( const TDesC8& aElementName);
       
   444 		
       
   445 	private:
       
   446 };
       
   447 
       
   448 class CResourceAttributeDesignator : public CAttributeDesignator
       
   449 {
       
   450 	public:
       
   451 		CResourceAttributeDesignator();
       
   452 		virtual ~CResourceAttributeDesignator();
       
   453 
       
   454 		static CElementBase * NewL();
       
   455 		static TBool IdentificateType( const TDesC8& aElementName);
       
   456 		
       
   457 	private:
       
   458 };
       
   459 
       
   460 class CEnvironmentAttributeDesignator : public CAttributeDesignator
       
   461 {
       
   462 	public:
       
   463 		CEnvironmentAttributeDesignator();
       
   464 		virtual ~CEnvironmentAttributeDesignator();
       
   465 
       
   466 		static CElementBase * NewL();
       
   467 		static TBool IdentificateType( const TDesC8& aElementName);
       
   468 		
       
   469 	private:
       
   470 };
       
   471 
       
   472 
       
   473 class CMatchObject : public CElementBase
       
   474 {
       
   475 	public:
       
   476 		CMatchObject( TNativeElementTypes aElementType);
       
   477 		CMatchObject( const TDesC8& aElementName);
       
   478 		virtual ~CMatchObject();
       
   479 	
       
   480 		void AddAttributeL( CPolicyParser *aParser, const TDesC8& aName, const TDesC8& aValue);
       
   481 		void AddElementL( CPolicyParser *aParser, CElementBase * aElement);
       
   482 	
       
   483 		static CElementBase * NewL( const TDesC8& aElementName);
       
   484 		static CElementBase * NewL( TNativeElementTypes aElementType);
       
   485 		
       
   486 		
       
   487 		static TBool IdentificateType( const TDesC8& aElementName);
       
   488 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode  );
       
   489 		
       
   490 		CAttributeDesignator* AttributeDesignator();
       
   491 		CAttributeValue* AttributeValue();
       
   492 		HBufC8* MatchId();
       
   493 		
       
   494 		TMatchResponse MatchL( CPolicyProcessor* aPolicyProcessor);
       
   495 
       
   496 		TBool CheckMatchObject( const TDesC8& aType, const TDesC8& aAttribute, const TDesC8& aValue);
       
   497 		
       
   498 
       
   499 		void AddIdElementL( CElementBase * aElement);		
       
   500 		virtual TBool ValidElement();
       
   501 	private: 
       
   502 		HBufC8 * iMatchId;
       
   503 		
       
   504 		CAttributeDesignator* iDesignator;
       
   505 		CAttributeValue* iMatchValue;
       
   506 };
       
   507 
       
   508 
       
   509 class CDescription : public CElementBase
       
   510 {
       
   511 	public:
       
   512 		CDescription();
       
   513 		virtual ~CDescription();
       
   514 	
       
   515 		static CElementBase * NewL();
       
   516 		
       
   517 		static TBool IdentificateType( const TDesC8& aElementName);
       
   518 		HBufC8 * DecodeElementL( const  TLanguageSelector &aLanguage, const TDecodeMode &aMode  );
       
   519 		HBufC8 * DescriptionText();
       
   520 		
       
   521 		void AddContentL( CPolicyParser *aParser, const TDesC8& aName);
       
   522 
       
   523 		virtual TBool ValidElement();
       
   524 	private: 
       
   525 		HBufC8 * iDescription;
       
   526 		
       
   527 };
       
   528 
       
   529 
       
   530 #endif
       
   531 
       
   532