vpnengine/pkiservice/inc/keymanager.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     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:   PKI server main module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_KEYMANAGER_H
       
    22 #define C_KEYMANAGER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <unifiedkeystore.h>
       
    26 #include "pkidefs.h"
       
    27 
       
    28 class CUnifiedKeyStore;
       
    29 class CCTKeyInfo;
       
    30 class CLogonServices;
       
    31 
       
    32 /**
       
    33  * A class that handles simple access to the keypairs.
       
    34  *
       
    35  * This class provieds following simple key access functionality:
       
    36  * key pair removal, key pair generation, key pair import and public key
       
    37  * export.
       
    38  */
       
    39 class CKeyManager : public CActive
       
    40     {
       
    41 public:
       
    42     static CKeyManager* NewL(CLogonServices& aLogonServices);
       
    43     ~CKeyManager();
       
    44 
       
    45     void RemoveKeyPair(const TPKIKeyIdentifier& aKeyId,                        
       
    46                        CUnifiedKeyStore& aUnifiedKeyStore,
       
    47                        TInt aUsedKeyStore,
       
    48                        TRequestStatus& aClientStatus);
       
    49                        
       
    50     void GenerateKeyPair(CUnifiedKeyStore& aUnifiedKeyStore,
       
    51                          TInt aUsedKeyStore, 
       
    52                          const TUint aKeySize, 
       
    53                          TPKIKeyAlgorithm aKeyAlgorithm,
       
    54                          TPKIKeyIdentifier& aKeyId,
       
    55                          TRequestStatus& aClientStatus);                          
       
    56                          
       
    57     void ImportKeyPair(CUnifiedKeyStore& aUnifiedKeyStore,
       
    58                        TInt aUsedKeyStore, 
       
    59                        const TDesC8& aKeyData,
       
    60                        TPKIKeyIdentifier& aKeyId,
       
    61                        TRequestStatus& aClientStatus);                          
       
    62                        
       
    63     void ExportPublicKey(CUnifiedKeyStore& aUnifiedKeyStore,
       
    64                          TInt aUsedKeyStore,                          
       
    65                          const TPKIKeyIdentifier& aKeyId,
       
    66                          HBufC8*& aPublicKeyData,
       
    67                          TRequestStatus& aClientStatus);                          
       
    68                        
       
    69 
       
    70 protected:
       
    71 
       
    72     void RunL();
       
    73     void DoCancel();
       
    74     void RunError();
       
    75 
       
    76 private:
       
    77     enum TKeyManagerState
       
    78         {
       
    79         EKeyManagerIdle = 0,
       
    80         ERetrievingKeyPairForRemove,
       
    81         ERemovingKeyPair,
       
    82         EGeneratingKeyPair,
       
    83         EImportingKeyPair,
       
    84         ESettingManagementPolicy,
       
    85         ESettingUsePolicy,
       
    86         ERetrievingKeyListForExport,
       
    87         EExportingPublicKey
       
    88         };
       
    89 
       
    90     CKeyManager(CLogonServices& aLogonServices);
       
    91     void ConstructL();    
       
    92     void Cleanup();
       
    93     
       
    94     TInt GetKeyIndex(TInt aUsedKeyStore, const RMPointerArray<CCTKeyInfo>& aKeysList) const;
       
    95     
       
    96     HBufC* GetUniqueNameL() const;
       
    97     CCTKeyInfo::EKeyAlgorithm ConvertPKIAlgorithm(TPKIKeyAlgorithm aAlg) const;
       
    98     
       
    99     CLogonServices&  iLogonServices;
       
   100     TKeyManagerState iState;
       
   101     
       
   102     TRequestStatus* iClientStatus;    
       
   103     CUnifiedKeyStore* iUnifiedKeyStore; //Not owned by this class
       
   104     RMPointerArray<CCTKeyInfo> iKeysList;
       
   105     
       
   106     TInt iUsedKeyStore;
       
   107     
       
   108     HBufC*             iObjectName;
       
   109     HBufC8**           iPublicKeyData; //Now owned by this class
       
   110     TPKIKeyIdentifier* iKeyId; //Not owned by this class    
       
   111     CCTKeyInfo*        iKeyInfo; //Not owned by this class           
       
   112     };
       
   113 
       
   114 #endif //C_KEYMANAGER_H