webservices/wsstar/wsstarpolicy/inc/wspolicy.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23  
       
    24 
       
    25 #ifndef WS_POLICY_H
       
    26 #define WS_POLICY_H
       
    27 
       
    28 // INCLUDES
       
    29 #include <e32std.h>
       
    30 
       
    31 #include "SenDomFragment.h"
       
    32 #include <SenDomFragmentBase.h>
       
    33 #include "policyassertion.h"
       
    34 #include "xorcompositeassertion.h"
       
    35 #include "andcompositeassertion.h"
       
    36 #include "wspolicyreader.h"
       
    37 #include "wspolicyutils.h"
       
    38 // FORWARD DECLARATIONS
       
    39 class CWSPolicyReader;
       
    40 class CWSPolicyWriter;
       
    41 class CMyXml;
       
    42 /**
       
    43  * Class: CWSPolicy
       
    44  * Description: Public interface to a policy. A policy should be created by this class. 
       
    45  * The policy will be stored as XML-DOM tree in memory and can be used to do different 
       
    46  * kind of processings on the policy. i.e. Normalizing, intersecting and merging
       
    47  */
       
    48 class CWSPolicy : public CBase
       
    49     {
       
    50 
       
    51     public:
       
    52         //public two phase constructors
       
    53         //still there is no purpose to create a policy with empty arguments ??
       
    54         IMPORT_C    static CWSPolicy* NewL();
       
    55         IMPORT_C    static CWSPolicy* NewLC();
       
    56         //creates a policy from a descriptor
       
    57         IMPORT_C    static CWSPolicy* NewL(TDesC8& aPolicyUri, TDesC8& aPolicy);
       
    58         IMPORT_C    static CWSPolicy* NewLC(TDesC8& aPolicyUri, TDesC8& aPolicy);
       
    59         //creates a policy from CSenElement    
       
    60         IMPORT_C    static CWSPolicy* NewL(CSenElement* aPolicy);
       
    61         IMPORT_C    static CWSPolicy* NewLC(CSenElement* aPolicy);
       
    62         //creates a policy from TElement//libxml2
       
    63         //IMPORT_C    static CWSPolicy* NewL(TElement aPolicy);
       
    64         //IMPORT_C    static CWSPolicy* NewLC(TElement aPolicy);
       
    65 
       
    66         IMPORT_C    TInt SetPolicyL(TDesC8& aPolicyUri, TDesC8& aPolicy);
       
    67         //Normalize a policy using a registry to solve references
       
    68         //returns ETrue if normalization is successfult else EFalse
       
    69         IMPORT_C    TBool NormalizePolicyL(CPolicyRegistry* aRegistry);
       
    70         CSenElement*  NormalizePolicy2L(CSenElement& aPolicy, CPolicyRegistry* aRegistry);
       
    71         //Intersect a policy with second policy provided as a parameter
       
    72         //return intersected policy
       
    73         IMPORT_C    CWSPolicy* IntersectPolicyL(CWSPolicy* aPolicy);
       
    74         //Merge a policy with second policy provided as a parameter
       
    75         //return merged policy
       
    76         IMPORT_C    CWSPolicy* MergePolicyL(CWSPolicy* aPolicy);
       
    77             
       
    78         //returns ETrue if the policy is normalized else EFalse
       
    79         IMPORT_C    TBool Normalized();
       
    80 
       
    81         IMPORT_C    HBufC8* PolicyAsXmlL();
       
    82         IMPORT_C    CSenElement* PolicyL();	//codescannerwarnings
       
    83         IMPORT_C    HBufC8* NormalizedAsXmlL();
       
    84         IMPORT_C    CSenElement* NormalizedPolicy();
       
    85         IMPORT_C    TBool IsExpiredPolicyL();	//codescannerwarnings
       
    86         IMPORT_C    CSenElement* NonNormalizedPolicyL();	//codescannerwarnings
       
    87         ~CWSPolicy();   
       
    88         
       
    89     private:
       
    90         CWSPolicy();
       
    91         void ConstructL();
       
    92         TInt NormalizePL(CPolicyRegistry* aRegistry);
       
    93         CWSPolicy* MergePL(CWSPolicy* aPolicy);
       
    94         CWSPolicy* IntersectPL(CWSPolicy* aPolicy);	//codescannerwarnings  
       
    95 
       
    96         void GeneratePolicyIdL(CSenElement* aPolicy);	//codescannerwarnings 
       
    97         TPtrC8 PolicyIdL(CSenElement* aPolicy);
       
    98         TPtrC8 PolicyNameL(CSenElement* aPolicy);
       
    99         TInt AddPolicyNameL(CSenElement* aPolicy);
       
   100         TInt AddPolicyMetadatEndpointL(CSenElement* aPolicy);
       
   101         TInt AddPolicyIdL(CSenElement* aPolicy);
       
   102         TInt AddPolicyValidityL(CSenElement* aPolicy);
       
   103         TInt EvaluateExpiryL(CSenElement* aPolicy);	//codescannerwarnings 
       
   104         CSenElement* GetExpiryTagL();	//codescannerwarnings 
       
   105         void BaseConstructL(TDesC8& aPolicyUri, TDesC8& aPolicy);
       
   106         void BaseConstructL(CSenElement* aPolicy);
       
   107 
       
   108         MAssertion* NormaAssertion();
       
   109 
       
   110     private: // Data
       
   111 
       
   112         CWSPolicyReader* iReader;
       
   113         CWSPolicyWriter* iWriter;
       
   114         CMyXml* iInDoc;
       
   115         CMyXml* iOutDoc;
       
   116 
       
   117         CSenElement* iNormPolicy; //owned           
       
   118         CPolicyAssertion* iNormaPolicyAssert; //owned
       
   119         TBool iNormalized;
       
   120         TBool iExpired;
       
   121         HBufC8* iPolicyId;
       
   122         HBufC8* iPolicyName;
       
   123         HBufC8* iPolicyUri;
       
   124         TInt count;
       
   125         TTime iExpiry;
       
   126     };
       
   127 
       
   128 class CMyXml :public CSenDomFragment
       
   129 {
       
   130 public:    
       
   131     static CMyXml* NewL();
       
   132     static CMyXml* NewLC();
       
   133     ~CMyXml();
       
   134     
       
   135     TInt ReadFromDescL(const TDesC8& aData);
       
   136     CSenElement* XMLDocL();
       
   137 private:
       
   138 
       
   139     CMyXml();
       
   140     void ConstructL();
       
   141     TBool iParsed;
       
   142 
       
   143 };   
       
   144 #endif // WS_POLICY_H
       
   145 // END OF FILE