wlansecuritysettings/wapisecuritysettingsui/inc/wapisecuritysettingsimpl.h
changeset 17 8840d3e38314
equal deleted inserted replaced
2:1c7bc153c08e 17:8840d3e38314
       
     1 /*
       
     2 * ============================================================================
       
     3 *  Name     : wapisecuritysettingsimpl.h 
       
     4 *  Part of  : WAPI Security Settings UI
       
     5 *
       
     6 *  Description:
       
     7 *      Declaration of class CWAPISecuritySettingsImpl.
       
     8 *      
       
     9 *  Version: %version:  11.1.1 %
       
    10 *
       
    11 *  Copyright (C) 2008 Nokia Corporation.
       
    12 *  This material, including documentation and any related 
       
    13 *  computer programs, is protected by copyright controlled by 
       
    14 *  Nokia Corporation. All rights are reserved. Copying, 
       
    15 *  including reproducing, storing,  adapting or translating, any 
       
    16 *  or all of this material requires the prior written consent of 
       
    17 *  Nokia Corporation. This material also contains confidential 
       
    18 *  information which may not be disclosed to others without the 
       
    19 *  prior written consent of Nokia Corporation.
       
    20 *
       
    21 * ============================================================================
       
    22 */
       
    23 
       
    24 #ifndef WAPISECURITYSETTINGSIMPL_H
       
    25 #define WAPISECURITYSETTINGSIMPL_H
       
    26 
       
    27 // INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <cmmanagerext.h>
       
    30 
       
    31 #include <wapisecuritysettingsui.h>
       
    32 #include "wapisecuritysettingsdefs.h"
       
    33 #include <WapiCertificates.h>
       
    34 
       
    35 #include <metadatabase.h>
       
    36 #include <commsdattypesv1_1.h>
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * WAPI Security Settings.
       
    44 * Implementation behind proxy class CWAPISecuritySettings.
       
    45 */
       
    46 NONSHARABLE_CLASS( CWAPISecuritySettingsImpl ) : public CBase
       
    47     {
       
    48 
       
    49     public:     // Constructors and destructor
       
    50 
       
    51         /**
       
    52         * Two-phased constructor. Leaves on failure.
       
    53         * @return The constructed CWAPISecuritySettings object.
       
    54         */
       
    55         static CWAPISecuritySettingsImpl* NewL();
       
    56 
       
    57         
       
    58         /**
       
    59         * Destructor.
       
    60         */
       
    61         virtual ~CWAPISecuritySettingsImpl();
       
    62 
       
    63     protected:  // Constructors
       
    64 
       
    65         /**
       
    66         * Constructor.
       
    67         * @param aEikEnv Eikon environment.
       
    68         */
       
    69         CWAPISecuritySettingsImpl();
       
    70 
       
    71         
       
    72         /**
       
    73         * Second-phase constructor.
       
    74         */
       
    75         void ConstructL();
       
    76 
       
    77     public:     // New methods
       
    78 
       
    79 
       
    80         /**
       
    81         * Load from database.
       
    82         * @param aIapRecordId Iap record
       
    83         * @param aSession Commsdat session
       
    84         */
       
    85         void LoadL( TUint32 aIapRecordId, CommsDat::CMDBSession& aSession );
       
    86         
       
    87         
       
    88         /**
       
    89         * Save to database.
       
    90         * @param aIapRecordId Iap record
       
    91         * @param aSession Commsdat session
       
    92         */
       
    93         void SaveL( TUint32 aIapRecordId, CommsDat::CMDBSession& aSession ) const;
       
    94  
       
    95         
       
    96         /**
       
    97         * Resets certificate store from C drive
       
    98         */
       
    99         void ResetCertificateStoreL();
       
   100  
       
   101         /**
       
   102          * Load certificates. This was implemented for performance issues.
       
   103          */
       
   104         void LoadCertificatesL();
       
   105         
       
   106         
       
   107         /**
       
   108         * Delete AP related data from certificate database tables
       
   109         *
       
   110         * @param aId        Service table id
       
   111         */
       
   112         void DeleteAPSpecificDataL( const TInt aId );
       
   113         
       
   114         
       
   115         /**
       
   116          * Fetches table index by certificate label name
       
   117          * @param aCertificates     Pointer to certificate array
       
   118          * @param aCert             Certificate label
       
   119          * @return  Index to corresponding certificate label
       
   120          */
       
   121          TInt GetIndexByCertLabel( 
       
   122                              RArray<TBuf<KMaxLabelLength> >* aCertificates, 
       
   123                              const TDesC& aCert);
       
   124         
       
   125 
       
   126          /**
       
   127          * Read the value of the current user certificate label
       
   128          * @param aUserCertInUse  Fetched certificate label
       
   129          */
       
   130         inline void GetUserCertInUse( TInt& aUserCertInUse );
       
   131 
       
   132         
       
   133         /**
       
   134          * Read the value of the current CA certificate label
       
   135          * @param aCACertInUse  Fetched certificate label
       
   136          */
       
   137         inline void GetCACertInUse( TInt& aCACertInUse );
       
   138  
       
   139         
       
   140         /**
       
   141          * Sets the value of the current user certificate in use
       
   142          * @param aSelectedCert  The new value for user certificate
       
   143          */
       
   144         inline void SetUserCertInUse( const TInt aSelectedCert );
       
   145 
       
   146         
       
   147         /**
       
   148          * Sets the value of the current CA certificate in use
       
   149          * @param aSelectedCert  The new value for CA certificate
       
   150          */      
       
   151         inline void SetCACertInUse( const TInt aSelectedCert );
       
   152  
       
   153         
       
   154         /**
       
   155          * Fetches pointers to RARRAYS where user and CA certificates are
       
   156          * stored.
       
   157          * @param aUserCertificates Pointer reference to user certificates
       
   158          * @param aCACertificates Pointer reference to CA certificates
       
   159          */   
       
   160         inline void GetCertificateLabels ( 
       
   161                         RArray<TBuf<KMaxLabelLength> >*& aUserCertificates, 
       
   162                         RArray<TBuf<KMaxLabelLength> >*& aCACertificates );
       
   163         /**
       
   164          * Sets preshared key format, key, and wapi to PSK mode.
       
   165          */
       
   166         void SetPreSharedKeyL( const CWAPISecuritySettings::TWapiKeyFormat aKeyFormat, const TDesC& aPreSharedKey );
       
   167 
       
   168         /**
       
   169          * Read the value of the current authentication
       
   170          */
       
   171         TWapiAuth GetAuthentication( );
       
   172         
       
   173         /**
       
   174          * Sets the value of authentication  in use
       
   175          * @param aWapiAuth  Authentication
       
   176          */
       
   177         void SetAuthentication( TWapiAuth aWapiAuth );
       
   178         
       
   179         /**
       
   180          * Read the value of current key format
       
   181          */
       
   182         CWAPISecuritySettings::TWapiKeyFormat GetKeyFormat();
       
   183         
       
   184         /**
       
   185          * Sets the value of key format
       
   186          * @param aWapiKeyFormat Key format
       
   187          */
       
   188         void SetKeyFormat( CWAPISecuritySettings::TWapiKeyFormat aWapiKeyFormat ); 
       
   189         
       
   190         /**
       
   191          * Returns true if psk key is set
       
   192          */
       
   193         TBool hasWapiPSKKey();
       
   194         
       
   195         /**
       
   196          * Set the value of pre-shared wapi key
       
   197          * @param aWapiPSKKey Pre-shared key 
       
   198          */
       
   199         TInt SetWapiPSKKeyL( const TDesC& aWapiPSKKey );
       
   200         
       
   201         /**
       
   202          * Checks if current settings are valid.
       
   203          */
       
   204         TBool IsValid();
       
   205         
       
   206     private:
       
   207         /**
       
   208         * Checks whether the given string is a valid for current format
       
   209         * @param aPsk The string to be checked
       
   210         * @return ETrue if the string is a valid PSK, EFalse otherwise.
       
   211         */
       
   212         TBool IsValidPsk( const TDesC8& aPsk );
       
   213 
       
   214         /**
       
   215         * Checks whether the given string is a valid for given format
       
   216         * @param aWapiKeyFormat Format (ascii/hex)
       
   217         * @param aPsk The string to be checked
       
   218         * @return ETrue if the string is a valid PSK, EFalse otherwise.
       
   219         */
       
   220         TBool IsValidPsk( const CWAPISecuritySettings::TWapiKeyFormat aWapiKeyFormat,
       
   221                 const TDesC8& aPsk );
       
   222 
       
   223     private:    // Data 
       
   224 
       
   225         CWapiCertificates*                  iCertificateStore; //owned
       
   226 
       
   227         // Certificate label, identity and selected certificate.
       
   228         RArray<TBuf<KMaxLabelLength> >*     iUserCertificates; //owned
       
   229         RArray<TBuf8<KMaxIdentityLength> >*  iUserCertificateData; //owned
       
   230         TInt                                iUserCertInUse; // Index of certificate data
       
   231         RArray<TBuf<KMaxLabelLength> >*     iCACertificates; //owned
       
   232         RArray<TBuf8<KMaxIdentityLength> >*  iCACertificateData; //owned
       
   233         TInt                                iCACertInUse; // Index of certificate data
       
   234 
       
   235         // Stores authentication method.
       
   236         TWapiAuth                           iWapiAuth;
       
   237 
       
   238         // True if PSK key is set
       
   239         TBool                               iWapiPSKKeySet;
       
   240         
       
   241         // PSK key format
       
   242         CWAPISecuritySettings::TWapiKeyFormat iWapiKeyFormat;
       
   243         
       
   244         // Stores PSK key.
       
   245         TBuf8<KWapiMaxKeyLength>            iWapiPSKKey;
       
   246         
       
   247         // Caches wlan service id to allow later loading of certificates
       
   248         // (solves performance issue)
       
   249         TUint32                             iWlanServiceId;
       
   250 
       
   251         // True if certificates have been loaded.
       
   252         TBool                               iCertificatesLoaded;
       
   253     };
       
   254 
       
   255 // Include inline functions
       
   256 #include "wapisecuritysettingsimpl.inl"
       
   257 
       
   258 #endif