os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_swicertstoreactions.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-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 the License "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: 
    15 * Actions for testing additional metadata supplied by the SWI cert store, ie
    16 * capabilties, mandatory and systemupgrade flag: - get capabilities - get mandatory - get systemupgrade flag
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file 
    23  @internalTechnology
    24 */
    25 
    26 #ifndef __T_METADATAACTIONS_H__
    27 #define __T_METADATAACTIONS_H__
    28 
    29 #include "t_certstoreactions.h"
    30 
    31 class CSWICertStore;
    32 
    33 /**
    34  * Test action to initialise an instance of the SWI cert store.
    35  *
    36  * Delete is handled by the standard delete action.
    37  */
    38 class CInitSWICertStoreAction : public CCertStoreTestAction
    39 	{
    40 public:
    41 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
    42 							 const TTestActionSpec& aTestActionSpec);	
    43 
    44 protected:
    45 	// Implement test action methods
    46 	virtual void PerformAction(TRequestStatus& aStatus);
    47 	virtual void PerformCancel();
    48 	virtual void Reset();
    49 
    50 private:
    51 	CInitSWICertStoreAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
    52 	void ConstructL(const TTestActionSpec& aTestActionSpec);
    53 	
    54 	virtual void DoReportAction();
    55 	virtual void DoCheckResult(TInt aError);
    56 	
    57 private:
    58 	enum TState
    59 		{
    60 		EInitCertStore,
    61 		EFinished
    62 		};
    63 
    64 	TState iState;
    65 	RFs& iFs;
    66 
    67 	};
    68 
    69 /**
    70  * Base class for SWI cert store meta data test actions.
    71  */
    72 class CSWICertStoreTestAction : public CCertStoreTestAction
    73 	{
    74 public:
    75 	virtual ~CSWICertStoreTestAction();
    76 
    77 	// Implement test action methods
    78 	virtual void PerformAction(TRequestStatus& aStatus);
    79 	virtual void PerformCancel();
    80 	virtual void Reset();
    81 
    82 protected:
    83 	CSWICertStoreTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
    84 	void ConstructL(const TTestActionSpec& aTestActionSpec);
    85 
    86 	// Define interface for derived classes
    87 	virtual void DoConstructL(const TTestActionSpec& aTestActionSpec) = 0;
    88 	virtual void DoPerformActionL(CCTCertInfo& aCertInfo) = 0;
    89 	virtual void DoCancel() = 0;
    90 
    91 private:
    92 	enum TState
    93 		{
    94 		EGetCert,
    95 		EPerformAction,
    96 		EFinished
    97 		};
    98 
    99 private:
   100 	CCTCertInfo* FindCertificate();
   101 
   102 private:
   103 	TState iState;
   104 	TCertLabel iCertificateLabel;			///< The certificate we're acting on
   105 	RMPointerArray<CCTCertInfo> iCertInfos; ///< List of all certificates found
   106 	CCertAttributeFilter* iFilter;			///< Filter to use when listing certs
   107 	};
   108 
   109 /**
   110  * Test action to get the capabilties associated with a certificate.
   111  */
   112 class CGetCapabilitiesAction : public CSWICertStoreTestAction
   113 	{
   114 public:
   115 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
   116 							 const TTestActionSpec& aTestActionSpec);	
   117 	
   118 private:
   119 	CGetCapabilitiesAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   120 	virtual void DoConstructL(const TTestActionSpec& aTestActionSpec);
   121 	virtual void DoReportAction();
   122 	virtual void DoPerformActionL(CCTCertInfo& aCertInfo);
   123 	virtual void DoCheckResult(TInt aError);
   124 	virtual void DoCancel();
   125 
   126 private:
   127 	TCapabilitySet iExpectedCapapbilities;
   128 	TCapabilitySet iCapabilities;
   129 	};
   130 
   131 /**
   132  * Test action to get the mandatory flag associated with a certificate.
   133  */
   134 class CGetMandatoryAction : public CSWICertStoreTestAction
   135 	{
   136 public:
   137 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
   138 							 const TTestActionSpec& aTestActionSpec);	
   139 	
   140 private:
   141 	CGetMandatoryAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   142 	virtual void DoConstructL(const TTestActionSpec& aTestActionSpec);
   143 	virtual void DoReportAction();
   144 	virtual void DoPerformActionL(CCTCertInfo& aCertInfo);
   145 	virtual void DoCheckResult(TInt aError);
   146 	virtual void DoCancel();
   147 
   148 private:
   149 	TBool iExpectedValue;
   150 	TBool iValue;
   151 	};
   152 
   153 /**
   154  * Test action to get the systemupgrade flag associated with a certificate.
   155  */
   156 class CGetSystemUpgradeAction : public CSWICertStoreTestAction
   157 	{
   158 public:
   159 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
   160 							 const TTestActionSpec& aTestActionSpec);	
   161 	
   162 private:
   163 	CGetSystemUpgradeAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   164 	virtual void DoConstructL(const TTestActionSpec& aTestActionSpec);
   165 	virtual void DoReportAction();
   166 	virtual void DoPerformActionL(CCTCertInfo& aCertInfo);
   167 	virtual void DoCheckResult(TInt aError);
   168 	virtual void DoCancel();
   169 
   170 private:
   171 	TBool iExpectedSystemUpgradeValue;
   172 	TBool iSystemUpgradeValue;
   173 	};
   174 	
   175 /**
   176 * Test action to get the deletable flag associated with a certificate.
   177 */
   178  
   179 class CGetDeletionAction : public CSWICertStoreTestAction
   180 	{
   181 public:
   182 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
   183 							 const TTestActionSpec& aTestActionSpec);	
   184 	
   185 private:
   186 	CGetDeletionAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   187 	virtual void DoConstructL(const TTestActionSpec& aTestActionSpec);
   188 	virtual void DoReportAction();
   189 	virtual void DoPerformActionL(CCTCertInfo& aCertInfo);
   190 	virtual void DoCheckResult(TInt aError);
   191 	virtual void DoCancel();
   192 
   193 private:
   194 	TBool iExpectedDeletableValue;
   195 	TBool iDeletableValue;
   196 	};
   197 
   198 /**
   199 * Test action to verify multiple readers
   200 */
   201  
   202 class CMultipleReadersAction : public CSWICertStoreTestAction
   203        {
   204 public:
   205        static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut,
   206                                                         const TTestActionSpec& 
   207 TestActionSpec);       
   208        
   209 private:
   210        CMultipleReadersAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   211        virtual void DoConstructL(const TTestActionSpec& aTestActionSpec);
   212        virtual void DoReportAction();
   213        virtual void DoPerformActionL(CCTCertInfo& aCertInfo);
   214        virtual void DoCheckResult(TInt aError);
   215        virtual void DoCancel();
   216 
   217 private:
   218        TBool iExpectedValue;
   219        TBool iValue; 
   220        };
   221 	
   222 
   223 #endif