os/security/cryptoservices/certificateandkeymgmt/tcertstore/t_unifiedcertstoreadd.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 * CAddCertificate and CImportKey class implementations
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file 
    22  @internalTechnology
    23 */
    24  
    25 #ifndef __T_UNIFIEDCERTSTOREADD_H__
    26 #define __T_UNIFIEDCERTSTOREADD_H__
    27 
    28 #include "t_certstoreactions.h"
    29 #include "t_testactionspec.h"
    30 #include <mctkeystore.h>
    31 #include <unifiedkeystore.h>
    32 
    33 /** 
    34  * This class tests the addition of a certificate to the store.
    35  */
    36 class CAddCertificate : public CSubscriberAction
    37 	{
    38 public:
    39 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, 
    40 		const TTestActionSpec& aTestActionSpec);
    41 	~CAddCertificate();
    42 	virtual void PerformAction(TRequestStatus& aStatus);
    43 	virtual void PerformCancel();
    44 	virtual void AfterOOMFailure();
    45 	virtual void Reset();
    46 
    47 private:
    48 	CAddCertificate(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
    49 	void ConstructL(const TTestActionSpec& aTestActionSpec);
    50 	void DoReportAction();
    51 	void DoCheckResult(TInt aError);
    52 	void WriteFormat();
    53 	void WriteOwnerType();
    54 	void SetKeyId(TKeyIdentifier& aKeyIdentifier, const TDesC8& aKeyInfo);
    55 	void SetDeletable(const TDesC8& aDeletable);
    56 	void SetCertFormatL(const TDesC8& aFormat);
    57 	void SetCertOwnerTypeL(const TDesC8& aOwnerType);
    58 	void SetCertLabelL(const TDesC8& aLabel);
    59 	void SetStoreToUse(const TDesC8& aStoreToUse);
    60 	void SetCertificateContentL(const TDesC8& aFileName);
    61 	void ConstructCertL(const TDesC8& aCert);
    62 
    63 private:
    64 	enum TState
    65 		{
    66 		EAdding,
    67 		ECheckNotification,
    68 		EFinished
    69 		};
    70 
    71 private:
    72 	TState iState;
    73 	CCertificate* iCertificate;
    74 	HBufC8* iCertificateURL;
    75 	HBufC* iCertificateLabel;
    76 	TCertificateFormat iCertificateFormat;
    77 	TCertificateOwnerType iOwnerType;
    78 	TKeyIdentifier iIssuerKeyId;
    79 	TKeyIdentifier iSubjectKeyId;
    80 	TBool iDeletable;
    81 	TBool iDeletableFlagPresent;
    82 	TInt iStoreIndex;
    83 
    84 	/**
    85 	 * This is the data of the certificate, it is the data that will be written to
    86 	 * the store for any kind of certificates (URL, X.509, WTLS...)
    87 	 */
    88 	HBufC8* iCertificateContent;
    89 	};
    90 
    91 
    92 class CImportKey : public CCertStoreTestAction
    93 {
    94 public:
    95 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec);
    96 	static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec);
    97 	~CImportKey();
    98 	virtual void PerformAction(TRequestStatus& aStatus);
    99 	virtual void PerformCancel();
   100 	virtual void Reset();
   101 private:
   102 	TBool SetKeyUsage(const TDesC8& aKeyUsage);
   103 	void SetKeyLabel(const TDesC8& aKeyLabel);
   104 	TBool SetKeyAccessType(const TDesC8& aKeyAccessType);
   105 	void SetKeyDataFileL(const TDesC8& aDes);
   106 	void SetKeyPassphrase(const TDesC8& aDes);
   107 private:
   108 	CImportKey(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   109 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   110 private:
   111 	void DoReportAction();
   112 	void DoCheckResult(TInt aError);
   113 private:
   114 	enum TState
   115 		{
   116 		EInitialise,
   117 		EImportKey,
   118 		EFinished
   119 		};
   120 private:
   121 	TState iState;
   122 private:
   123 	TKeyUsagePKCS15 iUsage;
   124 	HBufC* iLabel;
   125 	HBufC8* iKeyData;
   126 	TInt iAccessType;
   127 	RFs iFs;
   128 	CUnifiedKeyStore* iUnifiedKeyStore;
   129 	CCTKeyInfo* iKeyInfo;
   130 };
   131 
   132 #endif