cryptoservices/filebasedcertificateandkeystores/test/keytool/keytool_commands.h
changeset 8 35751d3474b7
parent 0 2c201484c85f
child 19 ece3df019add
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
    22 #include <e32base.h>
    22 #include <e32base.h>
    23 #include <ct/rmpointerarray.h>
    23 #include <ct/rmpointerarray.h>
    24 #include <mctkeystore.h>
    24 #include <mctkeystore.h>
    25 #include <unifiedkeystore.h>
    25 #include <unifiedkeystore.h>
    26 #include <badesca.h>
    26 #include <badesca.h>
    27 //#include <e32cmn.h>
    27 
    28 
    28 #ifdef KEYTOOL
       
    29 #include <authserver/authtypes.h>
       
    30 #include <authserver/identity.h>
       
    31 #include <authserver/authclient.h>
       
    32 #endif // KEYTOOL
    29 
    33 
    30 class CController;
    34 class CController;
    31 class CKeyToolController;
    35 class CKeyToolController;
    32 
    36 #ifdef KEYTOOL
       
    37 class CKeyInfo;
       
    38 class CFileKeyData;
       
    39 class CPermanentFileStore;
       
    40 class CKeyStoreCenrep;
       
    41 class CPassphrase;
       
    42 #endif // KEYTOOL
    33 
    43 
    34 /** 
    44 /** 
    35  * This class wraps up the command line parameters
    45  * This class wraps up the command line parameters
    36  * which affect the keystore command to be executed.
    46  * which affect the keystore command to be executed.
    37  * E.g. the key label we refer to, the key store to use, etc.
    47  * E.g. the key label we refer to, the key store to use, etc.
    39 class CKeyToolParameters : public CBase
    49 class CKeyToolParameters : public CBase
    40 	{
    50 	{
    41 	public:
    51 	public:
    42 		static CKeyToolParameters* NewLC();
    52 		static CKeyToolParameters* NewLC();
    43 		~CKeyToolParameters();
    53 		~CKeyToolParameters();
       
    54 #ifdef KEYTOOL
       
    55 		enum TErrors
       
    56 			{
       
    57 			EMandatoryArgumentMissing=1,
       
    58 			};
       
    59 #endif // KEYTOOL
    44 	enum TSetPolicy
    60 	enum TSetPolicy
    45 		{
    61 		{
    46 		ENone =0,
    62 		ENone =0,
    47 		ESetUserPolicy,
    63 		ESetUserPolicy,
    48 		ESetManagerPolicy,
    64 		ESetManagerPolicy,
    68 		RArray<TUid>				iUIDs;
    84 		RArray<TUid>				iUIDs;
    69 		HBufC* 						iOwnerType;
    85 		HBufC* 						iOwnerType;
    70 		TBool 						iPageWise;
    86 		TBool 						iPageWise;
    71 		TBool						iRemoveKey;
    87 		TBool						iRemoveKey;
    72 		TSetPolicy					iPolicy;
    88 		TSetPolicy					iPolicy;
       
    89 #ifdef KEYTOOL
       
    90 		HBufC*						iOldKeyFile;
       
    91 		HBufC*						iNewKeyFile;
       
    92 		HBufC* 						iAuthExpression;
       
    93 		TInt						iFreshness;
       
    94 		HBufC*						iPassphrase;
       
    95 #endif // KEYTOOL
    73 	};
    96 	};
    74 
    97 
    75 
    98 
    76 /**
    99 /**
    77  * Interface that every keytool command class must implement.
   100  * Interface that every keytool command class must implement.
   262 	CCTKeyInfo* iKey;
   285 	CCTKeyInfo* iKey;
   263 	TInt idx;
   286 	TInt idx;
   264 	};
   287 	};
   265 
   288 
   266 
   289 
       
   290 #ifdef KEYTOOL
       
   291 
       
   292 /**
       
   293  * Implements the migration of old keystore to the new keystore format 
       
   294  * which uses the authentication server. 
       
   295  */
       
   296 class CKeytoolMigrateStore : public CActive
       
   297 	{
       
   298 	
       
   299 private:
       
   300 	enum TMigrateStoreState
       
   301 		{
       
   302 		EAfterAuthentication,
       
   303 		
       
   304 		};
       
   305 public:
       
   306 	static CKeytoolMigrateStore* NewLC(CKeyToolParameters* aParams);
       
   307 	static CKeytoolMigrateStore* NewL(CKeyToolParameters* aParams);
       
   308 	~CKeytoolMigrateStore();
       
   309 	void ConstructL(CKeyToolParameters* aParams);
       
   310 
       
   311 public: // From CKeyToolCommand
       
   312 	void DoCommandL();
       
   313 
       
   314 public: // From CActive
       
   315 	void RunL();
       
   316 	void DoCancel();
       
   317 	TInt RunError(TInt aError);	
       
   318 	
       
   319 private:
       
   320 	CKeytoolMigrateStore();
       
   321 	void WriteKeyL(	const CKeyInfo& aKeyInfo, 
       
   322 					RStoreWriteStream& aWriteInfoStream );
       
   323 
       
   324 	void WriteAuthDetailsL( RStoreWriteStream& aWriteInfoStream );
       
   325 	void RevertStore(TAny* aStore);
       
   326 	void InitializeDefaultParams();
       
   327 	void WriteKeyInformationL();
       
   328 	template <class T> inline void EncryptAndStoreL(const T& aKey, RStoreWriteStream& aStream );
       
   329 	void StoreKeyL(const TDesC8& aKeyData, RStoreWriteStream& aStream);
       
   330 	template <class T> void RetrieveAndStorePublicKeyL( CFileKeyData* aKeyData, T* aPublicKey );
       
   331 	template <class T> void RetrieveAndStorePrivateKeyL( CFileKeyData* aKeyData, T* aPrivateKey );
       
   332 	static void CleanKeyInfo(TAny* aKeyInfo);
       
   333 	
       
   334 private:
       
   335 	AuthServer::TIdentityId iIdentityId;
       
   336 	AuthServer::RAuthClient iAuthClient; 
       
   337 	CPermanentFileStore* iWriteFileStore;
       
   338 	CPermanentFileStore* iReadFileStore;
       
   339 	TStreamId iWriteLookupStreamId;
       
   340 	CKeyToolParameters* iParams;
       
   341 	RFs iFs;
       
   342 	CKeyStoreCenrep* iKeyStoreCenrep;
       
   343 	CPassphrase* iPassphrase;
       
   344 	AuthServer::CIdentity* iUserIdentity;
       
   345 	TMigrateStoreState iState;
       
   346 	
       
   347 	RPointerArray<CFileKeyData> iKeyList;
       
   348 	};
       
   349 
       
   350 #endif // KEYTOOL
   267 #endif
   351 #endif
       
   352