xmlsecurityengine/xmlseccertman/inc/xmlsecmsymbiancertstore.h
changeset 0 e35f40988205
child 8 e65204f75c47
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 /*
       
     2 * Copyright (c) 2009 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: An XmlSec interface to the Symbian Unified Certificate Store.       
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __XMLSECCERTMAN_SYMBIANCERTSTORE_H_
       
    19 #define __XMLSECCERTMAN_SYMBIANCERTSTORE_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <unifiedcertstore.h>
       
    23 #include <e32std.h>
       
    24 #include <signed.h>
       
    25 #include <mctwritablecertstore.h>
       
    26 
       
    27 class CSymbianCertStore : public CActive
       
    28     {
       
    29 public:        
       
    30   
       
    31     /**
       
    32      * Create new object.
       
    33      *
       
    34      * @since S60 v3.2
       
    35      * @return pointer to new object
       
    36      */
       
    37     IMPORT_C static CSymbianCertStore* NewL();
       
    38     
       
    39     /**
       
    40      * Create new object and put it on clean stack.
       
    41      *
       
    42      * @since S60 v3.2
       
    43      * @return pointer to new object
       
    44      */    
       
    45      IMPORT_C static CSymbianCertStore* NewLC();
       
    46         
       
    47     /**
       
    48      * Destructor.
       
    49      */
       
    50     virtual ~CSymbianCertStore();
       
    51         
       
    52     /**
       
    53      * Create Unified Cert Store
       
    54      *
       
    55      * @since  S60 v3.2
       
    56      */
       
    57     void CreateUnifiedCertStoreL();
       
    58             
       
    59     /**
       
    60      * Find a cert in the Unified Cert Store
       
    61      *
       
    62      * @since S60 v3.2 
       
    63      * @param aLabel The name of the cert to be found
       
    64      */
       
    65     IMPORT_C void FindCertL(const TDesC8 &aLabel);
       
    66         
       
    67     /**
       
    68      * List certs from the Unified Cert Store
       
    69      *
       
    70      * @since S60 v3.2 
       
    71      * @param aLabel The name of the cert to be found
       
    72      */
       
    73     IMPORT_C void ListCertL();
       
    74     
       
    75     /**
       
    76      * Get list of certs from SymbianCertStore
       
    77      *
       
    78      * @since  S60 v3.2
       
    79      * @return RMPointerArray<CCTCertInfo> list
       
    80      */            
       
    81     IMPORT_C RMPointerArray<CCTCertInfo> GetCertList();
       
    82   
       
    83     /**
       
    84      * Check if a cert is found in the Unified Cert Store
       
    85      *
       
    86      * @since  S60 v3.2
       
    87      * @return KErrNone if the cert is found
       
    88      * @return KErrNotFound if the cert is not found
       
    89      */     
       
    90     IMPORT_C TInt CSymbianCertStore::hasCert();
       
    91          
       
    92     /**
       
    93      * Sets iCert
       
    94      *
       
    95      * @since  S60 v3.2
       
    96      */  
       
    97     IMPORT_C void SetCert(CCTCertInfo* cert);
       
    98 
       
    99     /**
       
   100      * Get the size of the cert stored
       
   101      *
       
   102      * @since  S60 v3.2
       
   103      * @return TUint Size of the cert
       
   104      */            
       
   105     IMPORT_C TUint GetCertSize();
       
   106         
       
   107     /**
       
   108      * AddCert
       
   109      *
       
   110      * @since  S60 v3.2
       
   111      * @param aCertData The cert data
       
   112      * @param aCertName Name of the cert 
       
   113      */
       
   114     IMPORT_C void AddCert (const TDesC8 &aCertData, const TDesC8 &aCertName);
       
   115  
       
   116      /**
       
   117      * Retrieve Cert Data. Sets iCertData from iCert
       
   118      *
       
   119      * @since  S60 v3.2 
       
   120      */
       
   121     IMPORT_C void RetrieveCertDataL();
       
   122     
       
   123     /**
       
   124      * Get Cert Data.
       
   125      *
       
   126      * @since  S60 v3.2
       
   127      * @return the buffer with cert data 
       
   128      */      
       
   129     IMPORT_C HBufC8* GetRetrieveCertData();
       
   130      
       
   131      /**
       
   132      * Retrieve Cert Object. Sets iCertObject from iCert
       
   133      *
       
   134      * @since  S60 v3.2 
       
   135      */        
       
   136     IMPORT_C void RetrieveCertObjectL();
       
   137     
       
   138     /**
       
   139      * Get Cert Object.
       
   140      *
       
   141      * @since  S60 v3.2
       
   142      * @return reference to object type CCertificate 
       
   143      */            
       
   144     IMPORT_C CCertificate* GetRetrieveCertObject();
       
   145         
       
   146      /**
       
   147      * Get the error flag
       
   148      *
       
   149      * @since S60 v3.2
       
   150      * @return error code
       
   151      */           
       
   152     IMPORT_C TInt CSymbianCertStore::GetError();
       
   153 
       
   154 protected:
       
   155     /**
       
   156      * From CActive Callback function, invoked to handle responses from the server
       
   157      */
       
   158     void RunL();
       
   159     
       
   160     /**
       
   161      * This function is called as part of the active object's Cancel().
       
   162      */         
       
   163     void DoCancel();
       
   164     
       
   165     /**
       
   166      * Handles Leaves from RunL function.
       
   167      */        
       
   168     TInt RunError(TInt aError);
       
   169 
       
   170 private:
       
   171     /**
       
   172      * C++ default constructor.
       
   173      */
       
   174     CSymbianCertStore();
       
   175 
       
   176     /**
       
   177      * By default Symbian 2nd phase constructor is private.
       
   178      */
       
   179     void ConstructL();
       
   180     
       
   181     /**
       
   182      * Release all resources kept in iCerts array (exept for iCert
       
   183      * which is released separetly) and empty iCerts array
       
   184      */
       
   185     void ResetAndDestroyCertsArray();
       
   186     
       
   187     /**
       
   188      * Release all resources kept in iCerts array and empty iCerts array
       
   189      */
       
   190     void ResetCertsList();
       
   191 
       
   192     /**
       
   193      * To find matched key in the phase EFindingKeys
       
   194      */        
       
   195     void FindMatchedCert();
       
   196 
       
   197 private:
       
   198     /** 
       
   199      * State of active object. 
       
   200      * EUnitialized standard state
       
   201      * EInitializingCertStore during initialize certstore
       
   202      * EFindingCerts during finding cert
       
   203      * EListCerts during listing certs
       
   204      * EAddingCert during adding cert
       
   205      * ERetrievingCertData during retrieving cert data
       
   206      * ERetrievingCertObject during retrieving cert object
       
   207      */ 	
       
   208     enum TState
       
   209         {
       
   210             EUnitialized,
       
   211             EInitializingCertStore,
       
   212             EFindingCerts,  
       
   213             EListCerts,
       
   214             EAddingCert,
       
   215             ERetrievingCertData,
       
   216             ERetrievingCertObject
       
   217             };
       
   218 
       
   219 private:
       
   220     /**
       
   221      * A reference to the CUnifiedCertStore class
       
   222      */
       
   223     CUnifiedCertStore *iCertStore;
       
   224     
       
   225     /**
       
   226      * A reference to the WritableCertStore
       
   227      */
       
   228     MCTWritableCertStore *iWritableCertStore;
       
   229   
       
   230     /**
       
   231      * Store the retrived cert
       
   232      */
       
   233     CCTCertInfo *iCert;
       
   234 
       
   235     /** 
       
   236      * An internal state
       
   237      */
       
   238     TState iState;
       
   239 
       
   240     /** 
       
   241      * Store filter to search in SymbianCertStore
       
   242      */ 
       
   243    CCertAttributeFilter* iCertFilter; 
       
   244     
       
   245     /** 
       
   246      * To store the cert label
       
   247      */ 
       
   248     HBufC* iCertLabel;
       
   249    
       
   250     /** 
       
   251      * To store the cert data
       
   252      */ 
       
   253     HBufC8* iCertData;
       
   254     
       
   255     /** 
       
   256      * store the retrived parsed representation, derived object
       
   257      */
       
   258     CCertificate* iCertObject;
       
   259              
       
   260     /** 
       
   261      * Store the certs found
       
   262      */
       
   263     RMPointerArray< CCTCertInfo > iCerts;         
       
   264     
       
   265     /** 
       
   266      * A reference to the File Server Client
       
   267      */
       
   268     RFs iFs;
       
   269     
       
   270     /**
       
   271      * Error flag
       
   272      */ 
       
   273     TInt iError;
       
   274     };
       
   275 
       
   276 #endif      // __XMLSECCERTMAN_SYMBIANCERTSTORE_H__