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