vpnengine/pkiservice/inc/pkisupport.h
changeset 0 33413c0669b9
child 1 c9c2ad51f972
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-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:   CPKISupport class implements the PKI interface for Symbian
       
    15 *                PKI storage.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __PKISUPPORT_H__
       
    22 #define __PKISUPPORT_H__
       
    23 
       
    24 #include <mctkeystore.h>
       
    25 #include "pkidefs.h"
       
    26 #include "eventmediatorapi.h" // for logging
       
    27 
       
    28 class CPKIWrapper;
       
    29 class CMapDescriptor;
       
    30 class TSecurityObjectDescriptor;
       
    31 class CUnifiedCertStore;
       
    32 class MCTWritableCertStore;
       
    33 class CCTCertInfo;
       
    34 class CCertAttributeFilter;
       
    35 
       
    36 enum TSubState
       
    37 {
       
    38     ESSComplete,
       
    39     ESSContinue,
       
    40     ESSCompleteRequest,
       
    41 };
       
    42 
       
    43 enum TInitPhaseState
       
    44 {
       
    45     EInitDone = 0,
       
    46     EInitContinueInitialize,
       
    47     EInitInitializeCertStore,
       
    48     EInitRetrieveCertList,
       
    49     EInitCompleteImportCerts,       
       
    50 };
       
    51 
       
    52 enum TPending
       
    53 {
       
    54     ENoPendingOperation,    
       
    55     EInitializeCertStore,    
       
    56     EListCerts,
       
    57     EListDevCerts,
       
    58     ECertAdd,
       
    59     ECertRetrieve,
       
    60     ECertRemove,
       
    61     ESetTrust,
       
    62     ETrusted,    
       
    63     ESetApplicability,
       
    64     EApplications,
       
    65     EIsApplicable,
       
    66 };
       
    67 
       
    68 
       
    69 /**
       
    70  *  Implements PKI support.
       
    71  *
       
    72  *  @lib (internal) pkiservice.exe
       
    73  *  @since S60 v3.0
       
    74  */
       
    75 class CPKISupport : public CActive
       
    76 {
       
    77     public:
       
    78 
       
    79         // Constructors, destructor
       
    80         static CPKISupport* NewL(
       
    81             CPKIMapper& aMapper, CPKIWrapper& aWrapper);
       
    82         static CPKISupport* NewLC(
       
    83             CPKIMapper& aMapper, CPKIWrapper& aWrapper);
       
    84         
       
    85         
       
    86         ~CPKISupport();
       
    87         
       
    88         void StartInitializeL(const RMessage2& aMessage);
       
    89         void SetCurrentFunction(TInt aFunc);
       
    90                         
       
    91         // Certificate Data manipulation
       
    92         void StoreCertificateL(const TDesC &aLabel, 
       
    93             TCertificateOwnerType aOwnerType, const TDesC8 &aBufferPtr, 
       
    94             const TBool& aIsDeletable, TRequestStatus& aStatus);
       
    95         
       
    96         void AttachCertificateL(const TDesC &aLabel, 
       
    97             const TPKIKeyIdentifier &aKeyId, 
       
    98             const TDesC8 &aBufferPtr, TRequestStatus& aStatus);
       
    99         
       
   100         void RetrieveCertificateL(const TDesC &aLabel, 
       
   101             TPtr8 &aBufferPtr, const TPKICertificateOwnerType& aType, 
       
   102             TRequestStatus& aStatus);
       
   103                     
       
   104         void RemoveCertificateL(const TDesC &aLabel, 
       
   105             TRequestStatus& aStatus);
       
   106                         
       
   107         void SelectCertificateL(const TDesC &aLabel, 
       
   108                                 const TPKICertificateOwnerType& aType = EPKICACertificate);
       
   109         
       
   110         // Asynchronous sertificate store request
       
   111         void GetCertificateStoreListAsync();
       
   112         
       
   113         // Helper methods
       
   114         TInt GetRequiredBufferSize();
       
   115         void SetCallerStatusPending(TRequestStatus& aStatus);
       
   116         void CompleteCallerStatus(TInt aError);
       
   117         void SetTrustL(
       
   118             const TDesC &aLabel, TBool aTrusted, TRequestStatus& aStatus);
       
   119         void TrustedL(const TDesC &aLabel, TRequestStatus& aStatus);
       
   120         void SetApplicabilityL(
       
   121             const TDesC &aLabel, const RArray<TUid>& aApplUids, 
       
   122             TRequestStatus& Status);
       
   123         void ApplicationsL(const TDesC &aLabel, TRequestStatus& Status);
       
   124                     
       
   125         inline void SetCertStoreType(TPkiServiceStoreType aStoreType) 
       
   126             {
       
   127             iCertStoreType = aStoreType;
       
   128             };
       
   129                     
       
   130         inline const TPkiServiceStoreType CertStoreType() const 
       
   131             {
       
   132             return iCertStoreType;
       
   133             };        
       
   134   
       
   135     private: // implementation
       
   136         CPKISupport(CPKIMapper& aMapper, CPKIWrapper& aWrapper);
       
   137         void ConstructL();
       
   138         
       
   139         void CancelCurrentOperation();
       
   140         CCTKeyInfo::EKeyAlgorithm ConvertPKIAlgorithm(TPKIKeyAlgorithm aAlg);
       
   141         TPKIKeyAlgorithm ConvertSymbianAlgorithm(CCTKeyInfo::EKeyAlgorithm aAlg);
       
   142         void FindInterfacesL();
       
   143         void ListAllCertificatesL();
       
   144         void ReadNextCertForImportL();
       
   145         void SaveCertInfoToCacheL();
       
   146 		TBool GetApplicationsOfCTFCertL();
       
   147         
       
   148         void ContinueStoreCertificateL();
       
   149         void ContinueRetrieveCertificate();
       
   150         void ContinueStoreCertifiedKeypairL();   
       
   151         void ContinueRemoveCertificate();
       
   152         void ContinueSetTrust();
       
   153         void ContinueSetApplicability();
       
   154         void ContinueApplications();        
       
   155         void ContinueTrusted();        
       
   156         void DoRunOperationL();
       
   157         void DoRunLoggedInOperationL();
       
   158         
       
   159         // Function to remove all MIDP2 certificates from the 
       
   160         // local listing (MIDP2 certs shouldn't be supported by VPN)
       
   161         void CleanupCertListL();
       
   162 
       
   163         // CActive methods
       
   164         void RunL();
       
   165         void DoCancel();
       
   166         TInt RunError(TInt aError);
       
   167         
       
   168         /**
       
   169          * Used for logging.
       
   170          * Exctracts certificate info from the parameters 
       
   171          * and inserts result into iCertInfoForLogging.
       
   172          * Result string looks like this:
       
   173          * \nLabel: <label> \nOwner: <owner> \nSubject: <subject> \nIssuer: <issuer>"
       
   174          * 
       
   175          * @param aLabel        Label of the certificate
       
   176          * @param aOwnerType    Owner of the certificate
       
   177          * @param aBufferPtr    The certificate
       
   178          */
       
   179         void ExtractCertInfoL(const TDesC& aLabel,
       
   180 				         	  const TCertificateOwnerType& aOwnerType,
       
   181 						      const TDesC8& aBufferPtr);
       
   182 						      
       
   183         /**
       
   184          * Logs certificate storing into VPN client UI log.
       
   185          * 
       
   186          * @param aError      0 if storing succeeded
       
   187          */
       
   188         void LogCertStoring(TInt aError);
       
   189                 
       
   190     private: // data        
       
   191         CPKIMapper                  &iMapper;
       
   192         CPKIWrapper                 &iWrapper;
       
   193         
       
   194         TPending                    iPending;
       
   195         TPtr8                       iImportCertDataPtr;                
       
   196                     
       
   197         RFs                         iFSession;
       
   198         CUnifiedCertStore           *iCertStore;
       
   199         MCTWritableCertStore        *iWritableCertStore;       
       
   200         TRequestStatus              *iCallerStatus;
       
   201         TInt                        iSupportStatus;
       
   202         TPtr8                       *iOutBufferPtr;        
       
   203         TInt                        iCurrentFunction;
       
   204         TInitPhaseState             iInitState;
       
   205         TSubState                   iSubState;        
       
   206         RMPointerArray<CCTCertInfo> *iCerts;
       
   207         CCertAttributeFilter        *iCertFilter;        
       
   208         RMessage2                   iMessage;
       
   209         TKeyIdentifier              iKeyId;
       
   210         TInt                        iRequiredBufferLength;
       
   211         TBool                       iTrusted;
       
   212         RArray<TUid>                iApplUids;
       
   213         TInt                        iImportCounter;
       
   214         CMapDescriptor              *iImportCertMapping;
       
   215         HBufC8                      *iImportCertData;
       
   216 		TBool						iToggleSwitch;		
       
   217 		
       
   218 		TPkiServiceStoreType        iCertStoreType;
       
   219 		TInt                        iDeviceCertStoreIndex;
       
   220         MCTWritableCertStore*       iWritableDeviceCertStore;
       
   221                 
       
   222         REventMediator              iEventMediator; // for logging
       
   223         HBufC8*                     iCertInfoForLogging;
       
   224 
       
   225 };
       
   226 #endif