contentpublishingsrv/contentpublishingutils/contentpublishingmap/inc/cpsecuritypolicy.h
changeset 93 82b66994846c
parent 92 782e3408c2ab
child 94 dbb8300717f7
equal deleted inserted replaced
92:782e3408c2ab 93:82b66994846c
     1 /*
       
     2 * Copyright (c) 2008 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:  Class used by session to handle access control list
       
    15  *  Version     : %version: ou1s60ui#4.1.1 % << Don't touch! Updated by Synergy at check-out.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_CPSECURITYPOLICY_H
       
    21 #define C_CPSECURITYPOLICY_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class CLiwDefaultMap;
       
    26 
       
    27 /**
       
    28  *  Internal class for Security related activities
       
    29  *
       
    30  *  @since S60 v5.0
       
    31  */
       
    32 NONSHARABLE_CLASS( CCPSecurityPolicy ): public CBase
       
    33     {
       
    34 public:
       
    35     
       
    36     enum TACLPolicy 
       
    37         {
       
    38         ERead,
       
    39         EWrite,
       
    40         EDelete    
       
    41         };
       
    42     
       
    43    /**
       
    44      * Two-phased constructor.
       
    45      */
       
    46     static CCPSecurityPolicy* NewL( const RMessage2& aMessage );
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      */
       
    51     static CCPSecurityPolicy* NewLC( const RMessage2& aMessage );
       
    52 
       
    53     /**
       
    54      * Destructor.
       
    55      */
       
    56     virtual ~CCPSecurityPolicy();
       
    57 
       
    58     /**
       
    59      * Sets default ACL map and serializes it
       
    60      *
       
    61      * @param aPolicy target for ACL binary
       
    62      */
       
    63     void GetDefaultSecurityL( RBuf8& aResult ) const ;
       
    64     
       
    65     /**
       
    66      * Checks if access for client (iMessage) 
       
    67      * should be granted or not
       
    68      *
       
    69      * @param aBinary serialized ACL map
       
    70      * @param aPolicy secururity policy to check
       
    71      * @return ETrue if security check is ok, 
       
    72      * 	EFalse if not 
       
    73      */
       
    74     TBool CheckSecurityL( TPtrC8& aBinary , TACLPolicy aPolicy ) const;
       
    75     
       
    76     /**
       
    77      * Performs actuall security check
       
    78      * should be granted or not
       
    79      *
       
    80      * @param aMap ACL map
       
    81      * @return ETrue if security check is ok, 
       
    82      * 	EFalse if not 
       
    83      */
       
    84     TInt DoCheckSecurityL( const CLiwMap* aMap ) const;
       
    85 
       
    86     /**
       
    87      * Performs security check based on client UIDs
       
    88      *
       
    89      * @param aList list of uids which have access
       
    90      *
       
    91      * @return access granted or not
       
    92      */
       
    93     TBool CheckUids( const TDesC& aList ) const ;
       
    94      
       
    95     /**
       
    96      * Performs security check based on client Capabilities
       
    97      *
       
    98      * @param aList list of capabilities which client must have
       
    99      *
       
   100      * @return access granted or not
       
   101      */
       
   102     TBool CheckCapabilities( const TDesC& aList ) const;
       
   103         
       
   104     /**
       
   105      * Exctracts from list next token( UID or Capability )
       
   106      *
       
   107      * @param aList list as desciptor
       
   108      * @param aResult single token extracted from list
       
   109      * @param aPos position of the reuired token
       
   110      */
       
   111     void ExctractNextToken( const TDesC& aList, 
       
   112                             TPtrC& aResult , TInt& aPos ) const;
       
   113     /**
       
   114      * Converts capability given as descriptor to enum
       
   115      *
       
   116      * @param aCapability descriptor to convert
       
   117      *
       
   118      * @return Capablity as enum
       
   119      */
       
   120     TCapability GetCapability( const TDesC& aCapability ) const; 
       
   121     
       
   122 private:
       
   123     
       
   124     /**
       
   125      * C++ default constructor.
       
   126      */
       
   127     CCPSecurityPolicy( const RMessage2& aMessage );
       
   128 
       
   129     /**
       
   130      * By default Symbian 2nd phase constructor is private.
       
   131      */
       
   132     void ConstructL();
       
   133 
       
   134 private:
       
   135     // data
       
   136 
       
   137     /*
       
   138      * Not own.
       
   139      * Message from client
       
   140      */
       
   141     const RMessage2& iMessage;
       
   142 
       
   143     };
       
   144 
       
   145 #endif // C_CPSECURITYPOLICY_H