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