os/security/cryptoservices/filebasedcertificateandkeystores/test/certtool/certtool_commands.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/certtool/certtool_commands.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,310 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __CERTTOOL_COMMANDS_H_
    1.23 +#define __CERTTOOL_COMMANDS_H_
    1.24 +
    1.25 +#include <e32base.h>
    1.26 +#include <ct/rmpointerarray.h>
    1.27 +#include <unifiedcertstore.h>
    1.28 +#include <badesca.h>
    1.29 +//#include <e32cmn.h>
    1.30 +
    1.31 +#include <keytool.rsg>
    1.32 +
    1.33 +#include "keytool_commands.h"
    1.34 +
    1.35 +class CCertToolController;
    1.36 +
    1.37 +/**
    1.38 + * Interface that every keytool command class must implement.
    1.39 + */
    1.40 +class CCertToolCommand : public CActive
    1.41 +	{
    1.42 +	public:
    1.43 +		virtual void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam) = 0;
    1.44 +		
    1.45 +	protected:
    1.46 +		CCertToolCommand(CCertToolController* aController);
    1.47 +
    1.48 +	protected:
    1.49 +		CCertToolController* iController;
    1.50 +		CKeyToolParameters* iParams; // we do not own this!		
    1.51 +	};
    1.52 +	
    1.53 +	
    1.54 +/**
    1.55 + * Implements the certtool display usage action.
    1.56 + */
    1.57 +class CCertToolUsage : public CCertToolCommand
    1.58 +	{
    1.59 +public:
    1.60 +	static CCertToolUsage* NewLC(CCertToolController* aController);
    1.61 +	static CCertToolUsage* NewL(CCertToolController* aController);
    1.62 +	~CCertToolUsage();
    1.63 +	void ConstructL();
    1.64 +
    1.65 +public: // From CCertToolCommand
    1.66 +	void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
    1.67 +	
    1.68 +public: // From CActive
    1.69 +	void RunL();
    1.70 +	void DoCancel();
    1.71 +	
    1.72 +protected:
    1.73 +	CCertToolUsage(CCertToolController* aController);			
    1.74 +	};
    1.75 +	
    1.76 +
    1.77 +/**
    1.78 + * Implements the certtool display usage action.
    1.79 + */
    1.80 +class CCertToolListStores : public CCertToolCommand
    1.81 +	{
    1.82 +public:
    1.83 +	static CCertToolListStores* NewLC(CCertToolController* aController);
    1.84 +	static CCertToolListStores* NewL(CCertToolController* aController);
    1.85 +	~CCertToolListStores();
    1.86 +	void ConstructL();
    1.87 +
    1.88 +public: // From CCertToolCommand
    1.89 +	void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
    1.90 +	
    1.91 +public: // From CActive
    1.92 +	void RunL();
    1.93 +	void DoCancel();
    1.94 +	
    1.95 +protected:
    1.96 +	CCertToolListStores(CCertToolController* aController);			
    1.97 +	
    1.98 +private:
    1.99 +	RArray<MCTCertStore> iCertStoreList; 
   1.100 +	};
   1.101 +	
   1.102 +
   1.103 +typedef RArray<TUid> RUidArray;
   1.104 +
   1.105 +/**
   1.106 + * Implements the keytool list action. This is an active object as listing is asynchronous.
   1.107 + */
   1.108 +class CCertToolList : public CCertToolCommand
   1.109 +	{
   1.110 +public:
   1.111 +	static CCertToolList* NewLC(CCertToolController* aController);
   1.112 +	static CCertToolList* NewL(CCertToolController* aController);
   1.113 +	~CCertToolList();
   1.114 +	void ConstructL();
   1.115 +	void InitializeIterations();	
   1.116 +
   1.117 +public: // From CCertToolCommand
   1.118 +	void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
   1.119 +		
   1.120 +public: // From CActive
   1.121 +	void RunL();
   1.122 +	void DoCancel();
   1.123 +	TInt RunError(TInt aError);	
   1.124 +	
   1.125 +protected:
   1.126 +	CCertToolList(CCertToolController* aController);
   1.127 +
   1.128 +protected:
   1.129 +	CUnifiedCertStore* iCertStore;
   1.130 +	MCertStore* iCertStoreImp;
   1.131 +	
   1.132 +	TInt iIndex;
   1.133 +	CCertificate* iCertificate;
   1.134 +
   1.135 +	RUidArray iApps;
   1.136 +	TBool iTrust;
   1.137 +	RArray<RUidArray> iCertApps;
   1.138 +	RArray<TBool> iCertTrust;
   1.139 +	RPointerArray<CCertificate> iParsedCerts;
   1.140 +	RMPointerArray<CCTCertInfo> iCertInfos;	
   1.141 +	CCertAttributeFilter* iFilter;
   1.142 +
   1.143 +	enum TState
   1.144 +		{
   1.145 +		EListCerts,
   1.146 +		ERetrieve,
   1.147 +		EGetApps,
   1.148 +		ESetTrust,
   1.149 +		EFinished,
   1.150 +		EIntermediate,
   1.151 +		EGetTrust,
   1.152 +		} iState;			
   1.153 +
   1.154 +	// Number of certificates that have to be listed up to the current iteration.
   1.155 +	TInt iCurrentListCount;	
   1.156 +	// Keeps track of the number of iterations left.
   1.157 +	TInt iNumberOfIterationsLeft;
   1.158 +	// List offset for the last iteration if total number of certificates is not an exact
   1.159 +	// multiple of default LIST_COUNT.
   1.160 +	TInt iLastIterationOffset;
   1.161 +	// Default list offset for each iteration.
   1.162 +	TInt iCurrentListOffset;
   1.163 +	};
   1.164 +	
   1.165 +
   1.166 +
   1.167 +
   1.168 +/**
   1.169 + * Implements the keytool import action.
   1.170 + */
   1.171 +class CCertToolAdd : public CCertToolCommand
   1.172 +	{
   1.173 +public:
   1.174 +	static CCertToolAdd* NewLC(CCertToolController* aController);
   1.175 +	static CCertToolAdd* NewL(CCertToolController* aController);
   1.176 +	~CCertToolAdd();
   1.177 +	void ConstructL();
   1.178 +
   1.179 +public: // From CKeyToolCommand
   1.180 +	void DoCommandL(CUnifiedCertStore& aCertStore, CKeyToolParameters* aParam);
   1.181 +	
   1.182 +public: // From CActive
   1.183 +	void RunL();
   1.184 +	void DoCancel();
   1.185 +	TInt RunError(TInt aError);
   1.186 +	
   1.187 +private:
   1.188 +	CCertToolAdd(CCertToolController* aController);
   1.189 +
   1.190 +	TCertificateFormat DoRecognizeL(const TDesC8& iData);
   1.191 +
   1.192 +protected:
   1.193 +	enum TState
   1.194 +		{
   1.195 +		EIntermediate,
   1.196 +		EFinish
   1.197 +		} iState;
   1.198 +	
   1.199 +private:
   1.200 +	HBufC8*	iCertData;
   1.201 +	CUnifiedCertStore* iCertStore;	
   1.202 +	TBool iIsDeletable;
   1.203 +	};
   1.204 +
   1.205 +
   1.206 +
   1.207 +/**
   1.208 + * Implements the certtool remove action. 
   1.209 + */
   1.210 +class CCertToolRemove : public CCertToolList
   1.211 +	{
   1.212 +public:
   1.213 +	static CCertToolRemove* NewLC(CCertToolController* aController);
   1.214 +	static CCertToolRemove* NewL(CCertToolController* aController);
   1.215 +	~CCertToolRemove();
   1.216 +	
   1.217 +public: // From CActive
   1.218 +	void RunL();
   1.219 +	TInt RunError(TInt aError);    
   1.220 +protected:
   1.221 +
   1.222 +private:
   1.223 +	CCertToolRemove(CCertToolController* aController);
   1.224 +
   1.225 +private:
   1.226 +
   1.227 +	};
   1.228 +
   1.229 +
   1.230 +/**
   1.231 +*
   1.232 +*/
   1.233 +class CCertToolSetApps : public CCertToolList
   1.234 +	{
   1.235 +public:
   1.236 +	static CCertToolSetApps* NewLC(CCertToolController* aController);
   1.237 +	static CCertToolSetApps* NewL(CCertToolController* aController);
   1.238 +	~CCertToolSetApps();
   1.239 +
   1.240 +public: // From CActive
   1.241 +	void RunL();
   1.242 +	TInt RunError(TInt aError);	
   1.243 +protected:
   1.244 +
   1.245 +private:
   1.246 +	CCertToolSetApps(CCertToolController* aController);
   1.247 +	TInt iCertIndex;
   1.248 +	};
   1.249 +	
   1.250 +	
   1.251 +/**
   1.252 +*
   1.253 +*/
   1.254 +class CCertToolAddApps : public CCertToolList
   1.255 +	{
   1.256 +public:
   1.257 +	static CCertToolAddApps* NewLC(CCertToolController* aController);
   1.258 +	static CCertToolAddApps* NewL(CCertToolController* aController);
   1.259 +	~CCertToolAddApps();
   1.260 +
   1.261 +public: // From CActive
   1.262 +	void RunL();
   1.263 +	TInt RunError(TInt aError);	
   1.264 +
   1.265 +protected:
   1.266 +	enum TState
   1.267 +		{
   1.268 +		EListCerts,
   1.269 +		ERetrieve,
   1.270 +		EGetApps,
   1.271 +		ESetApps,
   1.272 +		ESetTrust,
   1.273 +		EFinished,
   1.274 +		EIntermediate
   1.275 +		} iState;
   1.276 +
   1.277 +private:
   1.278 +	CCertToolAddApps(CCertToolController* aController);
   1.279 +	TInt iCertIndex;
   1.280 +	};
   1.281 +	
   1.282 +/**
   1.283 +*
   1.284 +*/
   1.285 +class CCertToolRemoveApps : public CCertToolList
   1.286 +	{
   1.287 +public:
   1.288 +	static CCertToolRemoveApps* NewLC(CCertToolController* aController);
   1.289 +	static CCertToolRemoveApps* NewL(CCertToolController* aController);
   1.290 +	~CCertToolRemoveApps();
   1.291 +
   1.292 +public: // From CActive
   1.293 +	void RunL();
   1.294 +	TInt RunError(TInt aError);	
   1.295 +
   1.296 +protected:
   1.297 +	enum TState
   1.298 +		{
   1.299 +		EListCerts,
   1.300 +		ERetrieve,
   1.301 +		EGetApps,
   1.302 +		ERemoveApps,
   1.303 +		EFinished,
   1.304 +		EIntermediate
   1.305 +		} iState;
   1.306 +
   1.307 +private:
   1.308 +	CCertToolRemoveApps(CCertToolController* aController);
   1.309 +	
   1.310 +	};
   1.311 +
   1.312 +#endif
   1.313 +