cpsecplugins/cpadvancedsecplugin/inc/cpcertmanuisyncwrapper.h
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
child 23 94da73d93b58
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
     1 /*
       
     2 * Copyright (c) 2010 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:   Wrapper class for Symbian's Security Framework's calls
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef     CPCERTMANUISYNCWRAPPER_H
       
    20 #define     CPCERTMANUISYNCWRAPPER_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 // FORWARD DECLERATIONS
       
    27 class CCertificate;
       
    28 class CPKIXValidationResult;
       
    29 class CPKIXCertChain;
       
    30 class CUnifiedCertStore;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  Wrapper class for Symbian's Security Framework's calls.
       
    36 *  Shows error notes if an error happenes.
       
    37 *
       
    38 *  @lib certmanui.dll
       
    39 *  @since S60 2.0
       
    40 */
       
    41 class CpCertManUISyncWrapper : public CActive
       
    42     {
       
    43     public:
       
    44 
       
    45         /**
       
    46         * Two-phased constructor.
       
    47         */
       
    48         static CpCertManUISyncWrapper* NewLC();
       
    49 
       
    50         /**
       
    51         * Two-phased constructor.
       
    52         */
       
    53         static CpCertManUISyncWrapper* NewL();
       
    54 
       
    55         /**
       
    56         * Destructor.
       
    57         */
       
    58         ~CpCertManUISyncWrapper();
       
    59 
       
    60     public: // New functions
       
    61 
       
    62         /**
       
    63         * TInt ListL
       
    64         * @param aStore reference to store where operation is done.
       
    65         * @param aArray Keys are stored here.
       
    66         * @param aFilter Information on what kind keys are looked.
       
    67         */
       
    68 
       
    69         void ListL( CUnifiedKeyStore*& aStore,
       
    70             RMPointerArray<CCTKeyInfo>* aArray,
       
    71             const TCTKeyAttributeFilter& aFilter );
       
    72 
       
    73         /**
       
    74         * TInt ListL
       
    75         * @param aStore reference to store where operation is done.
       
    76         * @param aArray Keys are stored here.
       
    77         * @param aFilter Information on what kind keys are looked.
       
    78         * @param aTokenUid Token UID of key store
       
    79         */
       
    80 
       
    81         void ListL( CUnifiedKeyStore*& aStore,
       
    82             RMPointerArray<CCTKeyInfo>* aArray,
       
    83             const TCTKeyAttributeFilter& aFilter,
       
    84             const TUid aTokenUid );
       
    85 
       
    86         /**
       
    87         * TInt ListL
       
    88         * @param aStore reference to store where operation is done.
       
    89         * @param aArray certificates are stored here.
       
    90         * @param aFilter Information on what kind certificates are looked.
       
    91         */
       
    92         void ListL( CUnifiedCertStore*& aStore,
       
    93             RMPointerArray<CCTCertInfo>* aArray,
       
    94             const CCertAttributeFilter& aFilter );
       
    95 
       
    96         /**
       
    97         * TInt ListL
       
    98         * @param aStore reference to store where operation is done.
       
    99         * @param aArray certificates are stored here.
       
   100         * @param aFilter Information on what kind certificates are looked.
       
   101         * @param aTokenUid Token UID of certificate store
       
   102         */
       
   103         void ListL( CUnifiedCertStore*& aStore,
       
   104             RMPointerArray<CCTCertInfo>* aArray,
       
   105             const CCertAttributeFilter& aFilter,
       
   106             const TUid aTokenUid );
       
   107 
       
   108 
       
   109         /**
       
   110         * TInt GetCertificateL
       
   111         * @param aStore reference to store where operation is done.
       
   112         * @param aCertInfo Certificate that's detailed information is fetched.
       
   113         * @param aCert Fetched certificate.
       
   114         */
       
   115         void GetCertificateL( CUnifiedCertStore*& aStore,
       
   116             const CCTCertInfo& aCertInfo, CCertificate*& aCert );
       
   117 
       
   118         /**
       
   119         * TInt GetCertificateL
       
   120         * @param aStore reference to store where operation is done.
       
   121         * @param aCertInfo Certificate that's detailed information is fetched.
       
   122         * @param aCert Fetched certificate.
       
   123         */
       
   124         void GetCertificateL( CUnifiedCertStore*& aStore,
       
   125             const CCTCertInfo& aCertInfo, CCertificate*& aCert, TUid aTokenUid );
       
   126 
       
   127 
       
   128         /**
       
   129         * TInt GetUrlCertificateL
       
   130         * @param aStore reference to store where operation is done.
       
   131         * @param aCertInfo Certificate that's detailed information is fetched.
       
   132         * @param aUrl Fetched URL.
       
   133         */
       
   134         void GetUrlCertificateL(
       
   135             CUnifiedCertStore*& aStore,
       
   136             const CCTCertInfo& aCertInfo,
       
   137             TDes8& aUrl)            ;
       
   138 
       
   139         /**
       
   140         * TInt GetApplicationsL
       
   141         * @param aStore reference to store where operation is done.
       
   142         * @param aCertInfo Certificate that applications are fetched.
       
   143         * @param Certificates applications are stoted here.
       
   144         */
       
   145         void GetApplicationsL( CUnifiedCertStore*& aStore,
       
   146             const CCTCertInfo& aCertInfo, RArray<TUid>& aApps );
       
   147 
       
   148         /**
       
   149         * TInt ValidateX509RootCertificateL
       
   150         * @param aValidationResult Result of validation.
       
   151         * @param aValidationTime Time of validation.
       
   152         * @param aChain Chain to be validated.
       
   153         */
       
   154         void ValidateX509RootCertificateL(
       
   155             CPKIXValidationResult*& aValidationResult,
       
   156             const TTime& aValidationTime, CPKIXCertChain*& aChain );
       
   157 
       
   158         /**
       
   159         * TInt InitStoreL
       
   160         * @param aStore reference to store to be initialized.
       
   161         */
       
   162         void InitStoreL( CUnifiedCertStore*& aStore );
       
   163 
       
   164         /**
       
   165         * void InitStoreL
       
   166         * @param aStore reference to store to be initialized.
       
   167         */
       
   168         void InitStoreL( CUnifiedKeyStore*& aStore );
       
   169 
       
   170         /**
       
   171         * TInt DeleteCertL
       
   172         * @param aStore reference to store where operation is done.
       
   173         * @param aCertInfo Certificate to be deleted.
       
   174         */
       
   175         void DeleteCertL( CUnifiedCertStore*& aStore,
       
   176             const CCTCertInfo& aCertInfo );
       
   177 
       
   178         /**
       
   179         * TInt DeleteCertL
       
   180         * @param aStore reference to store where operation is done.
       
   181         * @param aCertInfo Certificate to be deleted.
       
   182         */
       
   183         void DeleteCertL( CUnifiedCertStore*& aStore,
       
   184             const CCTCertInfo& aCertInfo,
       
   185             TUid aTokenUid );
       
   186 
       
   187         /**
       
   188         * TInt IsApplicableL
       
   189         * @since S60 2.0
       
   190         * @param aStore reference to store where operation is done.
       
   191         * @param aCertInfo Certificate thats applicability is queried.
       
   192         * @param aApplication Application that's status is queried.
       
   193         * @param aIsApplicable ETrue if applcable.
       
   194         * @return TInt Status Symbian's API's call.
       
   195         */
       
   196         TInt IsApplicableL( CUnifiedCertStore*& aStore,
       
   197             const CCTCertInfo& aCertInfo, TUid aApplication,
       
   198         TBool& aIsApplicable );
       
   199 
       
   200         /**
       
   201         * TInt IsTrustedL
       
   202         * @since S60 2.0
       
   203         * @param aStore reference to store where operation is done.
       
   204         * @param aCertInfo Certificate that's trust status is queried.
       
   205         * @param aTrusted ETrue if trusted.
       
   206         * @return TInt Status Symbian's API's call.
       
   207         */
       
   208         TInt IsTrustedL( CUnifiedCertStore*& aStore,
       
   209             const CCTCertInfo& aCertInfo, TBool& aTrusted );
       
   210 
       
   211         /**
       
   212         * TInt SetApplicabilityL
       
   213         * @param aStore reference to store where operation is done.
       
   214         * @param aCertInfo Certificate thats applicability is set.
       
   215         * @param aApplications New applicability settings.
       
   216         */
       
   217         void SetApplicabilityL( CUnifiedCertStore*& aStore,
       
   218             const CCTCertInfo& aCertInfo,
       
   219             RArray<TUid>& aApplications );
       
   220 
       
   221       /**
       
   222         * void MoveCertL
       
   223         * @since S60 3.2
       
   224         * @param aStore reference to store where operation is done
       
   225         * @param aCertInfo Certificate info
       
   226         * @param aSourceStore UID of source certificate store
       
   227         * @param aTargetStore UID of source certificate store
       
   228         * @return TInt Number of moved certificates
       
   229         */
       
   230         TInt MoveCertL( CUnifiedCertStore*& aStore,
       
   231             const CCTCertInfo& aCertInfo,
       
   232             const TUid aSourceTokenId,
       
   233             const TUid aTargetTokenId );
       
   234 
       
   235       /**
       
   236         * void MoveKeyL
       
   237         * @param aStore reference to store where operation is done
       
   238         * @param CCTKeyInfo Key info
       
   239         * @param aSourceStore UID of source key store
       
   240         * @param aTargetStore UID of source key store
       
   241         */
       
   242         void MoveKeyL( CUnifiedKeyStore*& aStore,
       
   243             const TCTKeyAttributeFilter& aFilter,
       
   244             const TUid aSourceTokenId,
       
   245             const TUid aTargetTokenId );
       
   246 
       
   247         /**
       
   248         * TInt GetInterface
       
   249         * @since S60 3.0
       
   250         * @param aToken reference to token
       
   251         * @param aTokenInterface Pointer to returned interface
       
   252         * @return TInt Status Symbian's API's call.
       
   253         */
       
   254         TInt GetInterface( TUid aRequiredInterface,
       
   255             MCTToken& aToken,
       
   256             MCTTokenInterface*& aReturnedInterface );
       
   257 
       
   258     protected:
       
   259 
       
   260         void DoCancel();
       
   261         void RunL();
       
   262 
       
   263     private:
       
   264 
       
   265         CpCertManUISyncWrapper();
       
   266         void ConstructL();
       
   267 
       
   268         void HandleErrorL();
       
   269 
       
   270     private:    //Data
       
   271 
       
   272         // Internal operation states.
       
   273         enum TOperation
       
   274             {
       
   275             EOperationNone,
       
   276             EOperationInit,
       
   277             EOperationList,
       
   278             EGetCertificate,
       
   279             EAddCertificate,
       
   280             ERetriveURLCertificate,
       
   281             EOperationDelete,
       
   282             EOperationGetApps,
       
   283             EOperationIsApplicable,
       
   284             EOperationIsTrusted,
       
   285             EOperationSetApplicability,
       
   286             EOperationSetToTrusted,
       
   287             EOperationValidateX509Root,
       
   288             EShowErrorNote,
       
   289             EOperationInitKeyStore,
       
   290             EOperationKeyList,
       
   291             EOperationGetInterface,
       
   292             EOperationExportKey,
       
   293             EOperationImportKey,
       
   294             EOperationDeleteKey
       
   295             };
       
   296 
       
   297         // For wrapping asynchronous calls.
       
   298         CActiveSchedulerWait    iWait;
       
   299 
       
   300         // Internal state of operation.
       
   301         TOperation              iOperation;
       
   302 
       
   303         // Just for cancelling a operation. Does not own.
       
   304         CUnifiedCertStore*      iStore;
       
   305 
       
   306         // Just for cancelling a operation. Does not own.
       
   307         CUnifiedKeyStore*       iKeyStore;
       
   308 
       
   309         // Just for cancelling a operation. Does not own.
       
   310         CPKIXCertChain*         iChain;
       
   311 
       
   312         // For retrieving a certificate.
       
   313         TPtr8                   iCertPtr;
       
   314 
       
   315     };
       
   316 
       
   317 #endif // CPCERTMANUISYNCWRAPPER_H
       
   318 
       
   319 // End of File