sl@0: /* sl@0: * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * CAddCertificate and CImportKey class implementations sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __T_UNIFIEDCERTSTOREADD_H__ sl@0: #define __T_UNIFIEDCERTSTOREADD_H__ sl@0: sl@0: #include "t_certstoreactions.h" sl@0: #include "t_testactionspec.h" sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: * This class tests the addition of a certificate to the store. sl@0: */ sl@0: class CAddCertificate : public CSubscriberAction sl@0: { sl@0: public: sl@0: static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec); sl@0: ~CAddCertificate(); sl@0: virtual void PerformAction(TRequestStatus& aStatus); sl@0: virtual void PerformCancel(); sl@0: virtual void AfterOOMFailure(); sl@0: virtual void Reset(); sl@0: sl@0: private: sl@0: CAddCertificate(RFs& aFs, CConsoleBase& aConsole, Output& aOut); sl@0: void ConstructL(const TTestActionSpec& aTestActionSpec); sl@0: void DoReportAction(); sl@0: void DoCheckResult(TInt aError); sl@0: void WriteFormat(); sl@0: void WriteOwnerType(); sl@0: void SetKeyId(TKeyIdentifier& aKeyIdentifier, const TDesC8& aKeyInfo); sl@0: void SetDeletable(const TDesC8& aDeletable); sl@0: void SetCertFormatL(const TDesC8& aFormat); sl@0: void SetCertOwnerTypeL(const TDesC8& aOwnerType); sl@0: void SetCertLabelL(const TDesC8& aLabel); sl@0: void SetStoreToUse(const TDesC8& aStoreToUse); sl@0: void SetCertificateContentL(const TDesC8& aFileName); sl@0: void ConstructCertL(const TDesC8& aCert); sl@0: sl@0: private: sl@0: enum TState sl@0: { sl@0: EAdding, sl@0: ECheckNotification, sl@0: EFinished sl@0: }; sl@0: sl@0: private: sl@0: TState iState; sl@0: CCertificate* iCertificate; sl@0: HBufC8* iCertificateURL; sl@0: HBufC* iCertificateLabel; sl@0: TCertificateFormat iCertificateFormat; sl@0: TCertificateOwnerType iOwnerType; sl@0: TKeyIdentifier iIssuerKeyId; sl@0: TKeyIdentifier iSubjectKeyId; sl@0: TBool iDeletable; sl@0: TBool iDeletableFlagPresent; sl@0: TInt iStoreIndex; sl@0: sl@0: /** sl@0: * This is the data of the certificate, it is the data that will be written to sl@0: * the store for any kind of certificates (URL, X.509, WTLS...) sl@0: */ sl@0: HBufC8* iCertificateContent; sl@0: }; sl@0: sl@0: sl@0: class CImportKey : public CCertStoreTestAction sl@0: { sl@0: public: sl@0: static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec); sl@0: static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec); sl@0: ~CImportKey(); sl@0: virtual void PerformAction(TRequestStatus& aStatus); sl@0: virtual void PerformCancel(); sl@0: virtual void Reset(); sl@0: private: sl@0: TBool SetKeyUsage(const TDesC8& aKeyUsage); sl@0: void SetKeyLabel(const TDesC8& aKeyLabel); sl@0: TBool SetKeyAccessType(const TDesC8& aKeyAccessType); sl@0: void SetKeyDataFileL(const TDesC8& aDes); sl@0: void SetKeyPassphrase(const TDesC8& aDes); sl@0: private: sl@0: CImportKey(RFs& aFs, CConsoleBase& aConsole, Output& aOut); sl@0: void ConstructL(const TTestActionSpec& aTestActionSpec); sl@0: private: sl@0: void DoReportAction(); sl@0: void DoCheckResult(TInt aError); sl@0: private: sl@0: enum TState sl@0: { sl@0: EInitialise, sl@0: EImportKey, sl@0: EFinished sl@0: }; sl@0: private: sl@0: TState iState; sl@0: private: sl@0: TKeyUsagePKCS15 iUsage; sl@0: HBufC* iLabel; sl@0: HBufC8* iKeyData; sl@0: TInt iAccessType; sl@0: RFs iFs; sl@0: CUnifiedKeyStore* iUnifiedKeyStore; sl@0: CCTKeyInfo* iKeyInfo; sl@0: }; sl@0: sl@0: #endif