os/security/cryptoservices/certificateandkeymgmt/tpkixcert/tactionvalidate.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) 1998-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 *
    16 */
    17 
    18 
    19 /**
    20  @file 
    21  @internalTechnology
    22 */
    23  
    24 #ifndef __TACTIONVALIDATE_H__
    25 #define __TACTIONVALIDATE_H__
    26 
    27 #include "t_testaction.h"
    28 #include "tpkixcertval.h"
    29 #include <unifiedcertstore.h>
    30 #include "tcertutils.h"
    31 
    32 class CActionValidate : public CTestAction
    33 {
    34 public:
    35 	virtual void DoPerformPrerequisite(TRequestStatus& aStatus) = 0;
    36 	virtual void DoPerformPostrequisite(TRequestStatus& aStatus) = 0;
    37 	virtual void PerformAction(TRequestStatus& aStatus);
    38 	TBool TestResult(TInt aError);
    39 	virtual void PerformCancel();
    40 	virtual void AfterOOMFailure();
    41 	virtual void Reset();
    42 
    43 	virtual void DoReportAction();
    44 	virtual void DoCheckResult(TInt aError);
    45 	virtual ~CActionValidate();
    46 protected:
    47 	void ConstructL(const TTestActionSpec& aTestActionSpec);
    48 	virtual void CreateChainL() = 0;
    49 	TBool AddParametersL(const TDesC& aBuf, TInt& aPos);
    50 	void WritePolicies(const CDesCArray& aPolicySet);
    51 	CActionValidate(RFs& aFs, CConsoleBase& aConsole,Output& aOut);
    52 protected:
    53 	enum TState
    54 		{
    55 		ERemoveCertsBeforeTest,
    56 		EAddRoot,
    57 		EAddIntermediateCerts,
    58 		EDoValidateTestStart,
    59 		EDoValidateTestValidate,
    60 		EDoValidateTestValidated,
    61 		EDoValidateTestFinished,
    62 		ERemoveCertsAfterTest,
    63 		EEnd
    64 		};
    65 
    66 	TState iState;
    67 	RFs& iFs;
    68 	CCertUtils* iCertUtils;
    69 
    70 	CTestChain* iTestChain;
    71 	CTestParameters* iTestIO;
    72 
    73 	/**
    74 	 * The certificate chain initialized based on whether the certificates are user supplied or to be retrieved
    75 	 * from the certificate store.
    76 	 */
    77 	CPKIXCertChain* iChain;
    78 
    79 	/**
    80 	 * The policies extracted from the test case and passed as argument to Validate
    81 	 */
    82 	CArrayPtrFlat<HBufC>* iPolicies;
    83 
    84 	/**
    85 	 * The result of the validation test. Used for the validation and the build tests.
    86 	 */
    87 	CPKIXValidationResult* iValidationResult;
    88 
    89 	/**
    90 	 * The time, it is used to check if the certifcate is within its validity
    91 	 * period. Used for the validation and the build tests.
    92 	 */
    93 	TTime iTime;
    94 	TBuf<128> iCertPath;
    95 };
    96 
    97 class CActionValidateWithStore : public CActionValidate
    98 	{
    99 public:
   100 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole,
   101 		Output& aOut, const TTestActionSpec& aTestActionSpec);
   102 	static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole,
   103 		Output& aOut, const TTestActionSpec& aTestActionSpec);
   104 
   105 private:
   106 	CActionValidateWithStore(RFs& aFs, CConsoleBase& aConsole,Output& aOut);
   107 	virtual void DoPerformPrerequisite(TRequestStatus& aStatus);
   108 	virtual void DoPerformPostrequisite(TRequestStatus& aStatus);
   109 	virtual void CreateChainL();
   110 	};
   111 
   112 class CActionValidateWithSuppliedCerts : public CActionValidate
   113 	{
   114 public:
   115 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole,
   116 		Output& aOut, const TTestActionSpec& aTestActionSpec);
   117 	static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole,
   118 		Output& aOut, const TTestActionSpec& aTestActionSpec);
   119 	virtual ~CActionValidateWithSuppliedCerts();
   120 private:
   121 	CActionValidateWithSuppliedCerts(RFs& aFs, CConsoleBase& aConsole,Output& aOut);
   122 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   123 	virtual void DoPerformPrerequisite(TRequestStatus& aStatus);
   124 	virtual void DoPerformPostrequisite(TRequestStatus& aStatus);
   125 	virtual void CreateChainL();
   126 private:
   127 	RPointerArray<CX509Certificate>* iRootCerts;
   128 	HBufC8* iEndEntityAndIntermediateCerts;
   129 	};
   130 
   131 #endif
   132