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